Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Struts store form data into word document

Have Programming Question? Ask it here!
 
 
 


suresh kumar
store form data into word document
1 Answer(s)      2 years and 7 months ago
Posted in : Struts


i want form page data, ex username phone number.. to store it in a word document file


Advertisement
View Answers

December 28, 2011 at 12:07 PM


We are providing you a program that will store java swing form data into word file using POI API.

import java.io.*;
import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.usermodel.*;
import org.apache.poi.hwpf.usermodel.Range;
import org.apache.poi.poifs.filesystem.*;
class Form extends JFrame{

JButton ADD;
JPanel panel,pan;
JLabel label1,label2,label3,label4;
final JTextField text1,text2,text3,text4;
Form() {
label1 = new JLabel();
label1.setText("Student Id:");
text1 = new JTextField(20);

label2 = new JLabel();
label2.setText("Name:");
text2 = new JTextField(20);

label3 = new JLabel();
label3.setText("Address:");
text3 = new JTextField(20);

label4 = new JLabel();
label4.setText("City:");
text4 = new JTextField(20);
ADD=new JButton("Add");

panel=new JPanel(new GridLayout(5,2));
panel.add(label1);
panel.add(text1);
panel.add(label2);
panel.add(text2);
panel.add(label3);
panel.add(text3);
panel.add(label4);
panel.add(text4);
panel.add(ADD);
add(panel,BorderLayout.CENTER);
setTitle("FORM");

ADD.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
String data="STUDENT ADMISSION FORM\n\n\nSTUDENT ID: "+text1.getText()+"\nNAME: "+text2.getText()+"\nADDRESS: "+text3.getText()+"\nCITY: "+text4.getText();
writeToFile(data, "Employee.doc");
try{
Runtime rt = Runtime.getRuntime();
rt.exec("cmd.exe /C start Employee.doc");
}
catch(Exception e){}
}
});
}
private static void writeToFile(String content, String path) {
try{
POIFSFileSystem fs = new POIFSFileSystem();
DirectoryEntry directory = fs.getRoot();
directory.createDocument("WordDocument", new ByteArrayInputStream(content.getBytes()));
FileOutputStream out = new FileOutputStream(path);

fs.writeFilesystem(out);
out.close();
}
catch(Exception ex){
System.out.println(ex.getMessage());
}
}
}
class InsertToFile{
public static void main(String arg[]) {
try
{
Form frame=new Form();
frame.setSize(300,300);
frame.setVisible(true);
}
catch(Exception e)
{}
}
}

Hope that it will be helpful for you.



Related Tutorials/Questions & Answers:
store form data into word document
store form data into word document  i want form page data, ex username phone number.. to store it in a word document file
open word document
. It will be helpful for you to read data from word document...open word document  how to open a word document ??   Please go through the following link: Java Read word document file The above link
Advertisements
open word document
. It will be helpful for you to read data from word document...open word document  how to open a word document ??   Please go through the following link: Java Read word document file The above link
open word document
. It will be helpful for you to read data from word document...open word document  how to open a word document ??   Please go through the following link: Java Read word document file The above link
Write String in Word document
Write String in Word document  How to read and write strings in word document
Scanning a word in a TEXT document......
Scanning a word in a TEXT document......  Hi Genius persons... I'm having many resumes in my FOLDER called HARISH in D:(colon) i want to scan... by searching the JAVA and .net words present in the files..if JAVA word is present means
Scanning a word in a TEXT document......
Scanning a word in a TEXT document......  Hi Genius persons... I'm having many resumes in my FOLDER called HARISH in D:(colon) i want to scan... by searching the JAVA and .net words present in the files..if JAVA word is present means
JTextArea to Word Document
JTextArea to Word Document Jakarta POI has provided several classes that enable us to perform read, write operations with ms word file. Here we are going to write the data into word document file through a swing component. You can
convert word document to pdf
convert word document to pdf  Hi, Could you please help me write a java code that converts the word docuemnt into PDF? I have to save the generated PDFs also. I got a code like the below, and i am unable to download the office
word document reading - Development process
word document reading  I am in the midst of reading a word document while reading charts(EMF or WMF) pictures i am not able to do so can u suggest one class for this to accomplish
POI Word document (Letter Template)
POI Word document (Letter Template)  Dear Team, i need code for generating word document(letter format). i am unable to get the code for formats, font settings, letter type settings. please help me for the same. Thanks
export to word document - Java Beginners
export to word document  hi sir,when i am click on a button under the jtable,for example (print button),then i want to print that jtable in word document,automatically,plz provide program sir  Hi Friend, Try
How to merge two word document using java
How to merge two word document using java   how to merge two word document using java
How to merge two word document using java
How to merge two word document using java   how to merge two word document using java
java code to open and display MS-word document
java code to open and display MS-word document  java code to open and display MS-word document
upload and retrieve a word document - JSP-Servlet
with uploading a word document to My sql database to a BLOB data type variable. And also unable to retrieve the word document from database. I am writing the code...("multipart/form-data") >= 0)) { DataInputStream in = new DataInputStream
store and retrieve data
store and retrieve data  sir,i want to store the entering data in a word file and retrieve it when i need.i am try to develop a video portal.in which... Write data into word file For this, poi-scratchpad-3.7-20101029.jar is needed
APACHE.POI -- Create word Document - Development process
APACHE.POI -- Create word Document  Hi, Could any one please post the code which creates the word document having different paragraphs and two... this code everywhere. But i need to write more to the document like Table inserting
Creating MS Word document in java - Struts
Creating MS Word document in java  I have one template in MS Word which has some content. Now i want to read this doc file and wants to add some content and also i need to set header and footer in doc file. That is, reading
Display the data to MS word
Display the data to MS word  i want help with displaying data on to ms word.When i click the button my web page my servlet should get the data from the database(say im searching using an id) and should display it on the ms word
How to hide text in Word Document using Apache POI library
How to hide text in Word Document using Apache POI library  Is it possible to hide text in MS Word Document using Apache POI library? If yes, please let me know how. I am able to create and read the document using POI library
to store form vaues in database - JDBC
to store form vaues in database  sir i have created one form with two... in textboxea the data must be stored in MYSQLdatabase please provide the code   Hi friend, Code to insert the data into database
Store ResultSt Data in a Map
Store ResultSt Data in a Map  i want to store data in a hash Map .Please solve my problem as soon as possible
Open Text or Word Document on JButton Click in Java - Java Beginners
Open Text or Word Document on JButton Click in Java  How to open Word document or Text File on JButton Click in java  Hi Friend, Try... org.apache.poi.hwpf.usermodel.Range; import org.apache.poi.poifs.filesystem.*; class Form extends
iPad App to store data
iPad App to store data  Hi, How to add data support iPad application? Thanks
store pagination form fields - Struts
store pagination form fields   hi,iam working online exams project . my intention is to save data that has been asnwered by client/student into db... to populate all the data that has been answered by client intothe db. how can i
HTML Form data into .CSV?
HTML Form data into .CSV?  how to store data from html form to csvfile in java
Java Xml Data Store
be followed up and/or purchased. You will need to store the data in a local binary... the implementation needs to change later on (perhaps they might decide to store the data...Java Xml Data Store  I have to do this project and i'm finding it so
Using poi hwpf,how to create table in word document. - Java Beginners
Using poi hwpf,how to create table in word document.  Can you please tell me how to create a table in the word document in java using Apache poi hwpf.its very urgent.Please send some sample code.Thanks in advance
ResultSet Object data to Ms-Word Doc
ResultSet Object data to Ms-Word Doc   help me , i don't know how to write data from oracle database into MSWord document using servlet or jsp
Edit word document Headers and Footers using POI Library in java?
Edit word document Headers and Footers using POI Library in java?  Hi All, I need code to modify the Header and Footer contents of a ms-word template using POI or JACOB libraries. Could any one help me? Thanks Advance
to store data entered in html page
to store data entered in html page  i want to a job site... submit we have to move to form 2 on there we have enter text data in the textfield after that by clicking submit button data enter in form 1 and 2 should
servlet program for data store in oracle?
servlet program for data store in oracle?  how to store data in oracle through servlet program
Getting Data from XML File (Document)
Getting Data from XML File (Document)       In this section, you will learn to retrieve the data from a XML file. All xml files store the data. You can add and modify the data
how to store,retrieve,modify the data
how to store,retrieve,modify the data  hello sir ,how to store,retrieve,modify the data using the swing please help me
for store data in data base - JSP-Servlet
.. and on 3rd form i use submit button... data of form 1 and 2 can also be store...for store data in data base  i want to a job site, in this site user can registered by a form.. in this form there are his information... i use
Storing Data (Retrieved from a XML Document) to a File
to store data (retrieved from the XML document) to a specified file (with ... Storing Data (Retrieved from a XML Document) to a File... that helps you in storing the data to a specified file in different format. After
to fetch data from ms word and storing into database
to fetch data from ms word and storing into database  i want to know how to fetch datafields from ms word and storing into database??? please answer soon .its urgent
store data from a variable in mysql?
store data from a variable in mysql?  sir last time asked you tell me how to retrieve data from a database mysql and store it in an int variable in order to apply some calculation on it, but now i want to store the result
JSP and XML .data store nd retrieve
JSP and XML .data store nd retrieve  I have made a form in jsp having emp id, projectname and emp name.I want to store data related to employee in xml file.How can i store data entered by user in XML file and later retrieve data
project in JSP and XML(to store data)
project in JSP and XML(to store data)  I need to complete an assignment in JSP and using XML as Database ,Please help me to complete this assignment.Ill be very very thankful to you,i am new to JSP.Please provide full code
How to set a microsoft word document PASSWORD by using Visual Basic 2008 express?
How to set a microsoft word document PASSWORD by using Visual Basic 2008 express?   How to set a microsoft word document PASSWORD by using Visual Basic 2008 express
Process HTML FORM data
Process HTML FORM data  Can a JSP page process HTML FORM data?   Yes. Preemptive termination of request processing on an error condition is a good way to maximize the throughput of a high-volume JSP engine. The trick
how to store data in a text file - Java Beginners
how to store data in a text file  Hi friends, I want to know, how we can save the data in a .txt file using swings....... for example, i want to store the arraylist data of swing program into a text file.......and also i want
how to store data in XML file - JSP-Servlet
how to store data in XML file  hi i have to store the data for example user id and password in a xml file the input userid and password will be coming from jsp middle ware servlet how to do that?   Hi friend
validating a form before data is entered.
validating a form before data is entered.  How can I avoid validating a form before data is entered
read text file and store the data in mysql - JDBC
read text file and store the data in mysql  when we store the data in mysql table from text file its store the data from new line to new column. how to store the data in different column from a single line of text file. 
retrieve data from mysql database and store it in a variable ?
retrieve data from mysql database and store it in a variable ?  sir , I am working on a project , in which I have to apply operation on input data... to store that data in int variable. how to do this ?   Here is an example
data type used to store name.(getting an error)
data type used to store name.(getting an error)    Statement stm=con.createStatement(); String query="select * from employee where ename=\'"+ename+"\'"; ResultSet rs=stm.executeQuery(query
create , edit MS WORD like document file using Java Swing - Swing AWT
create , edit MS WORD like document file using Java Swing   In my..., font style etc. I want this text in JTextArea to be saved to MS WORD like document file. Then how should I create, edit , retrieve this document file
Advertisements
 

 

 

DMCA.com