• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Creating word documents file from templates.

 
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi, I have req. to create word documents files using templates. Please let me know which API or third party tool to use.
Thanks in advance.

Rahul
 
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does it have to be Word? RTF would be so much easier, since it's all text that you can work with using search/replace. If you really need Word, the Apache POI library may be the way to go: http://faq.javaranch.com/java/CreateWordDocument
 
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Apache POI: http://poi.apache.org/
OpenOffice UNO: http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/OpenOffice.org_Developers_Guide
 
Rahul Ba
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ya, I just have concern regarding Apachee POI..wheneter we can generate reports from template in POI? I did not find any example hence writing.

And how's experience with OpenOffice?
 
Peter Taucher
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I never used the Open Office API, and POI only related to XLS documents. In that case there's a Workbook constructor that takes a 'template workbook' as parameter ... I think that's pretty simple. So maybe for other types of documents the handling could be similar.
-> http://stackoverflow.com/questions/714172/poi-using-excel-templates
-> https://coderanch.com/t/436727/open-source/create-MS-Word-Doc-HWPF
 
Rahul Ba
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I think I should go with Apache POI...but just want to check I have template and want to create word document only.
In template I have something $date$ where I have to put current date. Any Idea how to proceed with it.

I wrote a sample code, but it's not working



pages.dot template contains $date$, but in resultant text it's not filling the expected data.

and another thing is that In Template only I have table, I have to put the dynamicly generated data in front of Main System and File Name which I will get it from db.

so, below format is in Template file:

--------------------------------------------------------------
Main System :
--------------------------------------------------------------
File Name :
---------------------------------------------------------------

Thanks in advance as usual.
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not a POI user but does the s.replaceText("date", "Hi Hello"); method truly reference the $date$ variable?
 
We can walk to school together. And we can both read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic