Forums Register Login

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

+Pie Number of slices to send: Send
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 ]
+Pie Number of slices to send: Send
was my first post too long? did i post it in the wrong forum?
What could go wrong in a swell place like "The Evil Eye"? Or with this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 727 times.
Similar Threads
Is it possible to read an ArrayList and write to an XLS file using POIFSFileSystem
insert header and footer with POI HWPF?
poi problem with reading and writing in the same word file
Reading Word Doc
jsp with POI FILE System concept.
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 05:23:07.