Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8363655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:14:04+00:00 2026-06-09T12:14:04+00:00

I need to export tables and generate reports from my application using pure java.

  • 0

I need to export tables and generate reports from my application using pure java. Using COM or anything that needs pre-installed applications is not allowed. I definitely need .doc format. docx format is optional.

To export table means just to create simple table in word document with data. To generate report is to replace placeholders with some values in a template table. It also involves inserting new subtables in a template table or merging cells and rows.

So, the task is:

  • create tables in MS Word documents
  • insert subtables into table cells
  • merge table cells and rows
  • replace text in documents leaving the formatting

    I’ve tried to search the net but I managed to find Apache POI and Aspose libraries to do the job. Aspose seems to be ok but unfortunately I can’t afford this. POI has very poor documentation and I can’t really figure out whether it suits or not.

    Moreover I tried to insert simple table into the document. But it just corrups document. Check out the code below:

        POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("poi.doc"));
        HWPFDocument doc = new HWPFDocument(fs);        
        Range range = doc.getRange();
    
        Table table = range.insertTableBefore((short)5, 5);
        table.getRow(0).getCell(0).replaceText("cell", true);       
        doc.write(new FileOutputStream("poi_out.doc"));
    

    So i have three questions by that moment:

  • Am I doing something wrong in this example?
  • Is POI applicable for the tasks I mentioned?
  • What other free libraries you can suggest

    Thanks for your replies

    P.S. I’ve read some posts on this site about that topic. None of them really helped me. Moreover all of them are old. Some new features probably changed since that time.

    • 1 1 Answer
    • 0 Views
    • 0 Followers
    • 0
    Share
    • Facebook
    • Report

    Leave an answer
    Cancel reply

    You must login to add an answer.

    Forgot Password?

    Need An Account, Sign Up Here

    1 Answer

    • Voted
    • Oldest
    • Recent
    • Random
    1. Editorial Team
      Editorial Team
      2026-06-09T12:14:05+00:00Added an answer on June 9, 2026 at 12:14 pm

      There are 2 ways you can do this:

      1. This I really recommend since this solves your problem of replacing template placeholders with actual values, easily:

      Create a HTML file with the stuff you need. Use velocity as your templating engine. Now, after you replace the placeholders with values in your code, save the file with an extension of ‘.doc’ or ‘.docx’. The resultant file will open in word nicely. It will open in the web layout and the user can switch to the print layout if he likes.

      http://velocity.apache.org/engine/releases/velocity-1.5/user-guide.html

      1. Look at docx4j.

      http://www.docx4java.org/trac/docx4j

      But for this you will have understand how the MS Office Word docs XML structure works. And it might be really complicated putting a table inside another table.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
        • Report

    Sidebar

    Related Questions

    I need to export data from several tables in SQL Server 2008 using SSMS.
    I need to export some data from SAS to CSV, so that I can
    I need to generate a ms-word document from a pl/sql query to export a
    In my work we need to generate contract documents that dynamically extract information from
    I need to export the data from 36 SQL tables containing 24GB of data
    I need to export a matrix of regression results from Stata to MATLAB. I
    Do I really need to export the private key from my computer and pass
    Using Toad for Oracle, I can generate full DDL files describing all tables, views,
    I need to export data from a table in database A, then import it
    Possible Duplicate: How can I export tables to excel from a webpage EDIT: Just

    Explore

    • Home
    • Add group
    • Groups page
    • Communities
    • Questions
      • New Questions
      • Trending Questions
      • Must read Questions
      • Hot Questions
    • Polls
    • Tags
    • Badges
    • Users
    • Help
    • SEARCH

    Footer

    © 2021 The Archive Base. All Rights Reserved
    With Love by The Archive Base

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.