aspose file tools*
The moose likes I/O and Streams and the fly likes POI- Log file to xlsx -writing data in unreadable format and i think this is due to wrong encodeing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "POI- Log file to xlsx -writing data in unreadable format and i think this is due to wrong encodeing" Watch "POI- Log file to xlsx -writing data in unreadable format and i think this is due to wrong encodeing" New topic
Author

POI- Log file to xlsx -writing data in unreadable format and i think this is due to wrong encodeing

Thakur Sachin Singh
Ranch Hand

Joined: Jun 15, 2010
Posts: 232

Hi All,

When I am trying to read data from BufferedReader and writing into excel using FileOutputStream object with POI APIs then i am getting the data in excel file in bad formats. you can check the log file and excel file attached for more information.

Here my problem is I cannot use BufferedWriter in place of FileOutputStream because POI class XSSFWorkbook only have one write method and we can only pass FileOutputStream class objet there.

Please have a look the code and suggest me how i can proceed further.




[Thumbnail for xslx file output.JPG]


[Thumbnail for logfiledata.JPG]



SCJP 6- 91%, IBM DB2, IBM RAD Certified
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42276
    
  64
The first thing I would fix is the name of the file encoding - there is no "UTF8", it's called "UTF-8".

The obvious thing to do would be to print out the values of "lineData" to check whether they are what you think they are.


Ping & DNS - my free Android networking tools app
Thakur Sachin Singh
Ranch Hand

Joined: Jun 15, 2010
Posts: 232

Thanks Ulf - that was very silly mistake but now I have modify my code and have another problem:

Do you have any idea why getEncoding() method giving me UTF8 instead of UTF-8?

I am using eclipse and i think my old code is calling now. do you know how to fix this?

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42276
    
  64
Do you have any idea why getEncoding() method giving me UTF8 instead of UTF-8?

I don't. The java.nio.charset.Charset javadocs make it clear which charsets need to be supported. I did a quick grep through the Java source code, and it looks like some parts of it may accept "UTF8" instead of "UTF-8" (the XML parser, for example, although that may be required by the XML spec), but not all of it. And in particular, probably not the java.io package.
Thakur Sachin Singh
Ranch Hand

Joined: Jun 15, 2010
Posts: 232

BTW UTF-16 is working for me.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: POI- Log file to xlsx -writing data in unreadable format and i think this is due to wrong encodeing