Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

POIFS: creating document from string..what am i missing?  RSS feed

 
Ty Hill
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All! First time poster so I'll try to make it a good one.
I have a requirement to build a set of java classes that will create "reports" in a Word, Excel and HTML format. The HTML is no problem and I think I have enough information about HSSF to create effective Excel-format reports. My question is about using POIFS to create a Word-style document. 2 things:
1) It seems that POIFS just handles the reading and writing of a document but doesn't really do anything with the formatting of the data. Is that correct? Is there a port that handles the formatting such as font, size, heading style, etc.? How would I create a doc with nice formatting?
2) Below is the code I am using to create a document from a String I am passing in getting the new filename from a property. Streams and Readers haven't really clicked with me yet so please feel free to point me to a good tutorial if you know of one.
public void createDocument(String message) throws CMTSEmailException {

try {
message = message.trim();
POIFSFileSystem fs = new POIFSFileSystem();
String fileName = CMTSProperties.getInstance().getProperty("poifs.testdoc");
FileOutputStream out = new FileOutputStream(fileName);
InputStream in = new ByteArrayInputStream(message.getBytes("UTF-8"));

fs.createDocument(in, fileName);
fs.writeFilesystem(out);
Results (partial):
������������ ������������ Open Cases
Number: 1Summary: this would be the summary if the server was up.�������������������������������������������������������������������������
����������������������������������������������������������������������������
����������������������������������������������������������������������������
����������������������������������������������������������������������������
����������������������������������������������������������������������������
��������������������������������������������������������
What am I doing wrong?
Thanks in advance!
[added line breaks for readability - Jim]
[ March 17, 2004: Message edited by: Jim Yingst ]
 
Ty Hill
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
was my first post too long? did i post it in the wrong forum?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!