How To Create MS-Word Document in JAVA ?
I want to create a MS-Word Document using JAVA.
then i want to create table in that document.
is there any way through which i can create a Object of MS-Word in JAVA.
As far as I know. There is no support. And you can't get the file format specification for MS Word documents.
My advice is to look in to RTF, the spec is out there, although its not very nice.
I think you can do tables in RTF, and you just need to write your output as text and MS word will load it.
One thing to do is create a table in Word and save it as RTF, then look at the text and try to see whats going on. Although it won't be pretty !! Good luck
Similar Messages
-
How to create a word document on iPAD?
How to create a word doc on iPAD
Look at the Rccharles answer on this post.
https://discussions.apple.com/thread/6033082?tstart=0
Also, you can download these free MS Office apps (Word, Excel, PowerPoint) to view these files.
https://itunes.apple.com/us/app/microsoft-word-for-ipad/id586447913?mt=8
https://itunes.apple.com/us/app/microsoft-excel-for-ipad/id586683407?mt=8
https://itunes.apple.com/us/app/microsoft-powerpoint-for-ipad/id586449534?mt=8
Microsoft Office for iPad:Early Reviews of Word, PowerPoint & Excel Apps
http://ipadacademy.com/2014/03/microsoft-office-for-ipad-early-reviews-of-the-wo rd-powerpoint-excel-apps
Cheers, Tom -
How to create a word document or a pdf through webdynpro java
Hi All,
I have a requirement where in i need to create a word/pdf document with a certain template form.
When the user clicks on a button then the word document with a template should be created and saved in his/her desktop.
I need to know what is the procedure to create a document.
If anyone has worked on it then please help me out.
Thanks and Regards,
PradeepHi Pradeep,
For creating PDF documents in Webdynpro Java you can use "iText.jar" .
to know more about creating PDF using iText refer these links.
http://www.brothersoft.com/downloads/itext-jar.html
http://www.lowagie.com/iText/download.html
Regards
Sridhar -
Creating Excel + word document i java
Creating an MS Word+Excel Document in java
I am doing a project in jbuilder an using a mysql db on a remote server what i want to do is to generate reports either in ms word an or ms excel after executing a query for example if I search for students aged 20+ I want to generate an excel sheet with all the records ....
Does anyone knows how to do that or is there a good tutorial on the web that explains this issue
Your help is appreciated many thanks...........First you should read the post about how to use these forums. Before you post it does not take much to see if your question has already been asked and answered. This question has appeared a few times in the last two days. It was asked and answered on this very forum only a couple of hours ago.
Try here:
http://jakarta.apache.org/poi/ -
How to print a word document using java?
Hi All,
is it possible to write a java program that takes input and directs it to printer.
I specifically want it for word document.
i already have a program that works for images but not for word document.
Plz guide me where i am wrong or help me with some links or code snippets.
Any kind of help will be really appreciated.
// program is below
import java.io.FileInputStream;
import javax.print.Doc;
import javax.print.DocFlavor;
import javax.print.DocPrintJob;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.ServiceUI;
import javax.print.SimpleDoc;
import javax.print.attribute.DocAttributeSet;
import javax.print.attribute.HashDocAttributeSet;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
public class Convert{
* @param args
Convert(){
DocFlavor psFlavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
FileInputStream fis = null;
// Creates a new attribute set
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
try{
fis = new FileInputStream("d:\\print\\new.txt");
System.out.println("doc taken...");
if (fis == null) {
System.out.println("No File");
return;
}catch(Exception e){
System.out.println("No Such Doc..."+e);
PrintService printService[] = PrintServiceLookup.lookupPrintServices(psFlavor, aset);
//System.out.println("Default Printer: ");
PrintService services = null;
try{
services = PrintServiceLookup.lookupDefaultPrintService();//ookupPrintServices(psFlavor, aset);
}catch(Exception e){
System.out.println("print exp ");
e.printStackTrace();
System.out.println("Default Printer: "+ services.getName());
System.out.println(services+" services taken..."+services.isDocFlavorSupported(psFlavor));
PrintService service = ServiceUI.printDialog(null, 250, 250, printService, services, psFlavor, aset);
if (service != null) {
DocPrintJob job = service.createPrintJob();
try {
DocAttributeSet d = new HashDocAttributeSet();
// Doc doc=new
Doc doc = new SimpleDoc(fis, psFlavor, d);
System.out.print("doc prepared...");
System.out.println("printing starts...");
job.print(doc,aset);
System.out.println("printing done...");
catch (Throwable pe) {
pe.printStackTrace();
}else{
System.out.print("else...");
public static void main(String[] args) {
// TODO Auto-generated method stub
new Convert();
}anamupota wrote:
JoachimSauer wrote:
Desktop.print() is the simplest way. Everything else will get tricky really fast.I wonder if one could print .doc file though.Desktop.print() simply tells the OS to do whatever it usually does to print the file. If Word is installed, it should start word with the file as an argument and whatever parameter it takes to tell Word to print it.
If you don't have anything installed that can view/print words files (or the correct entries are missing in the registry), then it won't work, of course. -
Create Word document with Java
I want to create a Word Document with Java. But I don't know how can I insert text in a Word document.
I searched and found JXWord (probably limited to Windows): http://www.geocities.com/picmapicma/
I'm interrested to know if it works fine...:) -
Create a word document with TOC, table,etc
Hi,
How to create a word document with Table of content(TOC),header, footer, table, etc?
Help me with any APIs or examples. I have already tried with POI API, but couldnt create TOC.. So any other api or any solution is available to create complex word document.
Thank youHi BIJ001,
Thanks for your valuable suggestion.
Open standards WordprocessingML format is supports by Microsoft word. It is typical xml format of designing word document. But creating document with TOC,tables, different styles of paragraphs are complex. Using this format, i have created simple docs. I never tried with complex formats like TOC. The generating File should be in ".doc or .docx" format only.
Hi gimbal2,
I am parallely looking to find solution in OpenOffice format also. But i never try out ".docx" file format. I will try to look out this option.
Thanks for the input.
Edited by: user13735134 on May 24, 2011 6:55 AM -
I've created a Word document from a pdf file. How do i make it editable?
I've created a Word document from a pdf file. How do i make it editable?
Hi Kaz1,
The Word document should be editable after the conversion is complete. What happens when you try to edit it?
Thanks,
David -
How to Append two word documents into single using java
How to Append two word documents into single using java
we tried this but it's not append the one word document to other
source code:public class AppendTwoWordFiles {
public static void main(String []arg)throws IOException
FileInputStream fi=null;
FileOutputStream fo=null;
try {
System.out.println("Enter the source file name u want to append");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
File f1=new File(br.readLine().toString());
System.out.println("Enter the Destination file name ");
File f2=new File(br.readLine().toString());
fi = new FileInputStream(f1);
fo = new FileOutputStream(f2,true);
byte b[]=new byte[2];
while((fi.read(b))!=-1);
fo.write(b);
System.out.println("Successfully append the file");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
finally{
fi.close();
fo.close();
plz reply me quickly ,,,what can i followUse this code ..
and give the path of the both file like this.....
source file ---- C:/workspace/Practice/src/com/moksha/ws/test/practice.text
destination file ---- C:/workspace/City/src/com/moksha/ws/test/practice1.text
import java.io.*;
public class AppendTwoWordFiles {
public static void main(String[] arg) throws IOException {
FileInputStream fi = null;
FileOutputStream fo = null;
try {
System.out.println("Enter the source file name u want to append");
BufferedReader br = new BufferedReader(new InputStreamReader(
System.in));
File f1 = new File(br.readLine().toString());
System.out.println("Enter the Destination file name ");
File f2 = new File(br.readLine().toString());
fi = new FileInputStream(f1);
fo = new FileOutputStream(f2, true);
byte b[] = new byte[2];
int len = 0;
while ((len = fi.read(b)) > 0) {
fo.write(b, 0, len);
System.out.println("Successfully append the file");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
fi.close();
fo.close();
} -
HOW TO OPEN WORD DOCUMENT FROM JAVA???
hi everyone! Can you please help me to come with this problem? Let me to set my main target I want to achieve:
1) In my program user should first press a button;
2) Then already created Word Document should be opened (I DO NOT NEED to open that Word Document in Java or something like JField). Just simply it should be opened as a Microsoft Word Document.
I DO NEED YOUR HELP! PLEASE HELP ME....!Running cmd using the exec is also a windows only solution, there is no "more" or "less" it that solution compared to the rundll.
Since word is a windows format its pretty obvious that the application is ran under windows platform.
If you are running on a different platform (maybe using open office you can open word documents, i'm not sure) you might want to use the JDIC library (https://jdic.dev.java.net/) which enables you to open/edit/browse such files using the default viewer/editor/browser of the system you are working on.
Look at the org.jdesktop.jdic.desktop.Desktop object for these methods.
You can also find the Desktop object in J2SE6 but its still in beta. -
Generating reports in .doc format (Word Document) using Java POI - HWPF
Hi
Can anybody help me how to generate the report in .doc format using POI API?
Please share the sample code, if you have.
Thanks in Advance
DhilipHi,
I dont think that your requirement has to do with ADF capabilities.
You want to edit a word document with JAVA. For that reason, you will need an API, as the suggestions above.
You can do it without ADF and by using standard JAVA and the API of your choice. a static void main will do for that matter.
ADF comes into the game when you want to handle the document with your ADF application.
This means that you either want to get your new data to be placed on your doc from BC or any other DataControl or you want to do something else with ADF..
My guess is that you want to get data from ADF into your Doc.
You could create an API on handling your Doc and then use it into your ADF application.
Regards,
Dimitris. -
How to insert a word document or an RTF document into RichTextEditor?
How to insert a word document or an RTF document into af:richTextEditor. I am using Apache POI for reading the Word document and getting its contents. I am able to display the whole content of the document except the table and image within the document. The data in the table is getting displayed as a string and not as a table inside the editor.
Can we insert a word/RTF document into a rich text editor?
Can we insert images into the rich text editor?
The following is the code that I used. On clicking a button the word document has to be inserted into the <af:richTextEditor>.
<af:richTextEditor id="rte1" autoSubmit="true"
immediate="true"
columns="110" rows="20">
<af:dropTarget dropListener="#{SendEmail.richTextEditorDrop}">
<af:dataFlavor flavorClass="java.lang.String"/>
</af:dropTarget>
</af:richTextEditor>
<af:commandButton text="Insert at position" id="cb2">
<af:richTextEditorInsertBehavior for="rte1" value="#{RichTextEditorUtil.docFile}"/>
</af:commandButton>
Java Code: I am using Apache POI for reading the word document.
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.extractor.WordExtractor;
public String getDocFile() {
File docFile = null;
WordExtractor docExtractor = null ;
WordExtractor exprExtractor = null ;
try {
docFile = new File("C:/temp/test.doc");
//A FileInputStream obtains input bytes from a file.
FileInputStream fis=new FileInputStream(docFile.getAbsolutePath());
//A HWPFDocument used to read document file from FileInputStream
HWPFDocument doc=new HWPFDocument(fis);
docExtractor = new WordExtractor(doc);
catch(Exception exep)
System.out.println(exep.getMessage());
//This Array stores each line from the document file.
String [] docArray = docExtractor.getParagraphText();
String fileContent = "";
for(int i=0;i<docArray.length;i++)
if(docArray[i] != null)
System.out.println("Line "+ i +" : " + docArray);
fileContent += docArray[i] + "\n";
System.out.println(fileContent);
return fileContent;Hi,
images are not yet supported. Its an open enhancement request for the rich text editor.
For tables, it seems they are supported but in a basic way (just HTML 4 style) if I interpret the tag documentation correct
http://download.oracle.com/docs/cd/E15523_01/apirefs.1111/e12419/tagdoc/af_richTextEditor.html
Frank -
How to create an XML document from a String.
Can anyone help,
In the Microsoft XML Document DOM there is a load function load(string) which will create an XML document, but now we are switching to Java and I do not know how to create and XML document from a string, this string �xml document� is passed to my program from a webservice and I need to read several xml elements form it in a web server.
This string is a well formatted XML document:
<?xml version="1.0" encoding="UTF-8"?>
<Countries NumberOfRecords="1" LanguageID="en-us">
<Country>
<CountryCode>AU</CountryCode>
<CountryName>AUSTRALIA</CountryName>
</Country>
</Countries>Thanks PC!
I made it work using:
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
factory.setIgnoringComments(true); // We want to ignore comments
// Now use the factory to create a DOM parser
DocumentBuilder parser = factory.newDocumentBuilder();
//TransformThisStringBuffer is a string buffer wich contain the 'XML document (String)'
InputStream in = new ByteArrayInputStream(TransformThisStringBuffer.toString().getBytes());
// Parse the InputStream and build the document
Document document = parser.parse(in);
But which one is faster InputSource or InputStream, were would you put the "new InputSource(new StringReader(yourString))" in the above code? -
Writing to word document using java
hi,
i want to retrieve the values from database and then write to .doc file. how can i write to a word document using java?
thanks in advanceGoogle for "java write to word file"
and behold the magic results -
How to create an Oracle DATABASE through Java Programming Language.. ?
How to create an Oracle DATABASE through Java Programming Language.. ?
Oracle database administrators tend to be control freaks, especially in financial institutions where security is paramount.
In general, they will supply you with a database, but require you to supply all the DDL scripts to create tables, indexes, views etc.
So a certain amount of manual installation will always be required.
Typically you would supply the SQL scripts, and a detailled installation document too.
regards,
Owen
Maybe you are looking for
-
Move Library from old drive to new drive on the same computer
I have installed a new drive on my current computer system and I somehow can't seem to locate my music library on my old drive. Is there a way to locate the itunes library without having to delete or erase any music? Please help!
-
Trouble opening Final Cut Express
I'm borrowing a friends imac while my macbook pro is off for service. When I first got it the Final Cut Express worked perfectly. Now whenever I try to open Final Cut Express I get the message that the camera is not connected and when I tell it to co
-
I keep getting a "Save As" prompt after waking pc from sleep mode. Prompt wants to save PDF file as "NsPdf" and no matter what I do--save, cancel, or "x out" the prompt returns next time I wake computer. Restart has not worked. Saving file as a di
-
Connecting to OS X file shares from Linux
I need to connect to file shares on an OS X computer and mount them on a Linux server. Every resource I've seen seems to try to do this the other way around. I can ping the OS X computer so I know it can see it. I have enable SMB under sharing and se
-
Files not updating from default.dwt
NONE of my pages are updating from the template that I created them from. To create them I did the following: File>New>Templates>Site Name>Template Name>Create... Then I'd save the file to whatever I was creating..... such as, index.htm I have done t