简体   繁体   中英

Convert .txt file to .xls in java

I'm using mallet to do some topic modeling experiment and now I got the keys.txt and doc.txt which I can open using microsoft excel but when I used POI api to read the content it just didn't work and give me the result as invalid header.

I tried to open the files in excel and save them the second time in xls format and this time it worked. So I guess though I specified in mallet command that it should be saved as xls it didn't work.

Is there any way that I can convert a txt to xls format in java? Or I can use java to open call microsoft excel to open the .txt file and save them again?

Thanks.

Maybe mallet is generated CSV (comma separated value) or TSV (tab separated value) files. You could try a library like opencsv to read the file, create an XLS file from the data using POI. If my assumption is true, you may find more help in this thread .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM