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

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
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
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
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
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
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
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
HTML Form data into .CSV?
HTML Form data into .CSV?  how to store data from html form to csvfile in java
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
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
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
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
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
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
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
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
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
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
iPad App to store data
iPad App to store data  Hi, How to add data support iPad application? Thanks
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
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
servlet program for data store in oracle?
servlet program for data store in oracle?  how to store data in oracle through servlet program
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
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
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
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
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
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
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
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
org.apache.jackrabbit - oak-store-document version 1.8.4 Maven dependency. How to use oak-store-document version 1.8.4 in pom.xml?
org.apache.jackrabbit  - Version 1.8.4 of oak-store-document Maven...-document in pom.xml? How to use oak-store-document version 1.8.4 in pom.xml... org.apache.jackrabbit  - Version 1.8.4 of oak-store-document in project
org.apache.jackrabbit - oak-store-document version 1.22.2 Maven dependency. How to use oak-store-document version 1.22.2 in pom.xml?
org.apache.jackrabbit  - Version 1.22.2 of oak-store-document Maven...-store-document in pom.xml? How to use oak-store-document version 1.22.2 in pom.xml... org.apache.jackrabbit  - Version 1.22.2 of oak-store-document in project
org.apache.jackrabbit - oak-store-document version 1.8.3 Maven dependency. How to use oak-store-document version 1.8.3 in pom.xml?
org.apache.jackrabbit  - Version 1.8.3 of oak-store-document Maven...-document in pom.xml? How to use oak-store-document version 1.8.3 in pom.xml... org.apache.jackrabbit  - Version 1.8.3 of oak-store-document in project
org.apache.jackrabbit - oak-store-document version 1.8.23 Maven dependency. How to use oak-store-document version 1.8.23 in pom.xml?
org.apache.jackrabbit  - Version 1.8.23 of oak-store-document Maven...-store-document in pom.xml? How to use oak-store-document version 1.8.23 in pom.xml... org.apache.jackrabbit  - Version 1.8.23 of oak-store-document in project
Maven Repository/Dependency: org.apache.jackrabbit | oak-store-document
Maven Repository/Dependency of Group ID org.apache.jackrabbit and Artifact ID oak-store-document. Latest version of org.apache.jackrabbit:oak-store-document dependencies. # Version Release Date
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... simple program that helps you in storing the data to a specified file in different
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
ModuleNotFoundError: No module named 'nifeng-data-store'
ModuleNotFoundError: No module named 'nifeng-data-store'  Hi, My... named 'nifeng-data-store' How to remove the ModuleNotFoundError: No module named 'nifeng-data-store' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'wrattler-data-store'
ModuleNotFoundError: No module named 'wrattler-data-store'  Hi, My... named 'wrattler-data-store' How to remove the ModuleNotFoundError: No module named 'wrattler-data-store' error? Thanks   Hi

Ads