This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript 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?
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!