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 advance

Google for "java write to word file"
and behold the magic results

Similar Messages

  • 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
    Dhilip

    Hi,
    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 open Word Document using java?

    Respected Sir/ Madam,
    I am doing my project in Network Security using java. I have to transfer the files from server to the client. Each transferred file should have some of the access privileges such as read, write and exeucte. If the transferred file is a word document means then automatically the client should open Microsoft word and if the file is having Read Permission alone then the save, Save As, cut,copy, paste options in the MS - Word should be disabled. This is similar for all the files that i have transferred. That is if the transferred file is excel, audio, video,txt file the corresponding application should be opened properly. How could I acheive this. If the file is having write permission then if the user clicks the save option then the contents of the file should be saved in the server machine not in the client machine, Could we achieve this???? Can anyone help me regarding this? Please give me your views about this query?

    Respected Sir / Madam,
    Thank you very much for your reply. Could we use Microsoft API inside java program to achieve my doubts?? Could U explain it more????

  • 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.

  • 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

  • How To open a MS Word/Excel document using Java

    How do i open a MS-Word/Excel document using Java Code.

    Get SDK (which is freeware) at
    http://www.simtel.net/product.php?id=60701&sekid=0&SiteID=simtel.net
    http://shareware.pcmag.com/product.php?id=60701&SiteID=pcmag
    http://downloads.suntimes.com/product.php?id=60701&SiteID=suntimes
    There you will find examples for MSWord and Excel (example sources are packed with binaries).

  • Api POI read and replace my word document with java

    Hi
    Everyone
    I�d like to know if someone has a piece of code reading a word document with api POI to send me?
    I need read replace the word document wiht java j2ee.
    Thanks

    Hello,
    You have to use the Office Integration Library. Please, follow the documentation below:
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/32853febec3c17e10000000a114084/frameset.htm
    I hope this helps you.
    Regards,
    Blanca

  • Reading Microsoft Word Document in JAVA

    Hi friends,
    im using follwing code to read word document in java using apache poi package..
    import org.apache.poi.poifs.filesystem.*;
    import org.apache.poi.hwpf.*;
    import org.apache.poi.hwpf.extractor.*;
    import java.io.*;
    public class readDoc
    public static void main( String[] args )
    String filesname = "Hello.doc";
    POIFSFileSystem fs = null;
    try
    fs = new POIFSFileSystem(new FileInputStream(filesname;
    //Couldn't close the braces at the end as my site did not allow it to close
    HWPFDocument doc = new HWPFDocument(fs);
    WordExtractor we = new WordExtractor(doc);
    String[] paragraphs = we.getParagraphText();
    System.out.println( "Word Document has " + paragraphs.length + " paragraphs" );
    for( int i=0; i<paragraphs .length; i++ ) {
    paragraphs[i] = paragraphs.replaceAll("\\cM?\r?\n","");
    System.out.println( "Length:"+paragraphs[ i ].length());
    catch(Exception e) {
    e.printStackTrace();
    but im getting exception that
    java.io.IOException: Unable to read entire header; -1 bytes read; expected 512 bytes
    at org.apache.poi.poifs.storage.HeaderBlockReader.<in it>(HeaderBlockReader.java:78)
    at org.apache.poi.poifs.filesystem.POIFSFileSystem.<i nit>(POIFSFileSystem.java:83)
    how to solve this issue.. please suggest me .. its urgent..
    Add to satheeshtech's Reputation

    You might do better consulting [http://www.nabble.com/Apache-POI-f298.html|http://www.nabble.com/Apache-POI-f298.html] .

  • 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.

  • I have a MacBook Pro and can't print pdf files or word documents using my HP Wireless Photosmart Printer.  It will print files from the internet.  Any suggestions or ideas will be greatly appreciated.  Thank you.

    I have a MacBook Pro and can't print pdf files or word documents using my HP Wireless Photosmart Printer.  It will print files from the internet.  Any suggestions or ideas will be greatly appreciated.  Thank you.

    Hello, SoonerAnesthetist. 
    Thank you for visiting Apple Support Communities.
    Here is an article that I would recommend going through when experiencing this issue.
    OS X Mavericks: Solve printing problems
    http://support.apple.com/kb/PH14142
    Cheers,
    Jason H.

  • I am trying to convert a PDF to a Word document using Acrobat Pro 9 but am unable to find "Content to edit" under tools.  Do I need a newer version?

    I am trying to convert a PDF to a Word document using Acrobat Pro 9 but am unable to find "Content to edit" under tools.  Do I need a newer version?

    Acrobat 9 Pro (not Standard) can export ("convert") PDF to Word, RTF, or other text formats.
    Click-path:  File - Export
    Take your pick.
    With install of Acrobat 9 the Help PDF is installed also.
    From the this PDF's Bookmarks expand Chapter 5's bookmark and select "Convert PDFs to Word".
    Be well...

  • HI I'm having real trouble opening my word documents (using Office:Mac 2008)  Have tried repair disk options as I saw this advice on another blog, seemed to work for a while now its stared happening again.  Any help MUCH appreciated

    HI I'm having real trouble opening my word documents (using Office:Mac 2008)  Have tried repair disk options as I saw this advice on another blog, seemed to work for a while now its stared happening again.  Any help MUCH appreciated

    http://answers.microsoft.com/en-us/mac

  • 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...:)

  • Printing a PDF document using Java 1.4 Printing API

    Hi,
    When I tried to print a PDF document using JAVA 1.4 Printing API, I got the following exception.
    Exception in thread "main" sun.print.PrintJobFlavorException: invalid flavor
    at sun.print.Win32PrintJob.print(Win32PrintJob.java:290)
    at Printing.main(Printing.java:40)
    I am able to print the same PDF document using Acrobat reader.
    Is PDF format not supported in JAVA 1.4 printing API? or is something wrong in my code?
    here is the sample JAVA program that I was using
    import javax.print.*;
    import javax.print.attribute.*;
    import java.io.*;
    public class Printing {
    public static void main(String args[]) throws Exception {
    String filename = args[0];
    PrintRequestAttributeSet pras =
    new HashPrintRequestAttributeSet();
    DocFlavor flavor = DocFlavor.INPUT_STREAM.PDF;
    PrintService defaultService =
    PrintServiceLookup.lookupDefaultPrintService();
    DocPrintJob job = defaultService.createPrintJob();
    FileInputStream fis = new FileInputStream(filename);
    DocAttributeSet das = new HashDocAttributeSet();
    Doc doc = new SimpleDoc(fis, flavor, das);
    job.print(doc, pras);
    Thread.sleep(10000);
    System.exit(0);
    Thank you
    Sumana

    Here's a pure Java solution (that works!):
    http://www.mycgiserver.com/~zhouwu/pdf/readme.html
    The caveats are:
    - prints only to the default printer
    - requires a properties file located in the home directory
    my workaround for the last:
         * Print a PDF file to the default printer (might consume lots of memory!).
         * <p>
         * <b>Required:</b>
         * <ul>
         * <li>a file "acrobat.properties" needs to be in the working directory. The content is:
    <table align="center" bgcolor="#E0E0E0" border=1 cellpadding="10" cellspacing="0"><tr><td><pre style="margin-top:0; margin-bottom:0">
    #com.adobe.acrobat.Viewer Properties
    #Wed Oct 29 20:34:05 PST 2003
    com.adobe.acrobat.AcceptedLicAgreement=true
    com.adobe.acrobat.Fax_Fine_Mode=true
    com.adobe.acrobat.Find\:FindAll=false
    com.adobe.acrobat.Find\:FindBackwards=false
    com.adobe.acrobat.Find\:FindWholeWord=false
    com.adobe.acrobat.Find\:MatchCase=false
    com.adobe.acrobat.Open_Dialog_Directory=C\:\\temp\\
    com.adobe.acrobat.Open_Dialog_File=itext.pdf
    com.adobe.acrobat.Print_Method_Known=true
    com.adobe.acrobat.Shrink_To_Fit=false
    com.adobe.acrobat.SitePreferencesURL=file\://localhost/C\:/pdf/acrobat-site.properties
    com.adobe.acrobat.Use_Print_Server=false
    com.adobe.acrobat.util.fontDirectories=C\:\\Winnt\\Fonts
    com.adobe.acrobat.util.fontIgnoreExtensions=.fon;.pfm;.ini;.lst;.txt;.doc;.ttmap;.z;.enc;.dir;.afm;.f3b;.pfa;.spd;.ps;.bepf;.map;.alias;.scale;.all;.upr
    </pre></td></tr></table>
         * <li>The JAR files PDFPrinter.jar, acrobat.jar and MRJToolkitStubs.zip in the CLASSPATH.
         * </ul>
         * <p>
         * Note: the file "acrobat.properties" is expected to be in the user's home directory. As this is not always feasible,
         * the system property "user.home" is mapped to "user.dir" for the time of execution.
         * @param fileName Name of PDF file to print.
         * @throws Exception on error.
         * @see <a href="http://www.mycgiserver.com/~zhouwu/pdf/readme.html">PDF Server (Silent) Printing</a>
        public void printPDF(String fileName) throws Exception {
            String oldHome = System.getProperty("user.home");
            System.setProperty("user.home", System.getProperty("user.dir"));
            PDFPrinter vi = new PDFPrinter();
            vi.activate();
            vi.setDocumentInputStream(new FileInputStream(fileName));
            vi.printAll();
            System.setProperty("user.home", oldHome);
        }//printPDF()I just need the following additional files in my CLASSPATH: PDFPrinter.jar, acrobat.jar and MRJToolkitStubs.zip. Despite the note at the site above that "printing quality is not very good", i can't agree: the print quality is quite good. Not perfect, but acceptable for most uses.
    (Tested on Windows 2000 SP4, J2SE 1.4.2_03, hp laserjet 2300dn)

  • Can I convert PDFs to Word documents using Creative Suite?

    Our office has CS6 -- Is there a way to convert easily convert a .pdf to a word document using Creative Suite?

    FIle --> Save as --> Microsoft Word in Acrobat.
    Mylenium

Maybe you are looking for

  • My bank wants me to get antivirus  for my iMac is it possible

    My bank wants me to get antivirus for my iMac is it possible

  • Sold on false promo

    I could not be more livid and appalled at Verizon's customer service. In Feb of this year, I called to speak with Verizon, to get quotes on calling plans for 2 lines and what promotions they were running, as our contracts were ending with sprint (aft

  • Change Primary email address, delete Microsoft acc...

    I have a stupid Microsoft account which I never wanted in the first place but somehow was forced into it with my new Windows 8 laptop. I want to get rid of this email address. But first I need to remove all accounts associated with it. SO...I would l

  • WHILE RESTORING I PHONE 4S SHOWING ERROR 2009

    FIRST MY I PHONE 4S SHOWS SEARCHING  IN NETWORK EITHER THERE IS SIM OR NOT. LATER WHEN I APPORCH TO SERVICE CENTER THEY SAID MY PHONE IS SHOWING ERROR  -1. BUT NOW IT SHOWING ERROR 2009. NOT UNDERSTANDING WAT TO DO

  • Download pics from droid to use on ebay  HELP!!!

    I am trying to download my pics to my computer, with no luck.  Can someone tell me how.  I want to use them on ebay.  I can not find my user manual. Thanks!