views:

193

answers:

3

went and got a file that already "works" from here: xls to csv

Note, I wanted a tab delimited format, so I just went in and changed "," to "\t" and then removed a bunch of the extra formatting, such as naming the workbook. The problem is, however, that this code I found splits some Excel rows into 2+ lines.

These are the rows where I have several columns filled then several columns that are empty, followed by more data, basically a row that has a gap between entries.

Everything is still aligned correctly, but I can't figure out how to correctly match the records.

It is vitally important that in my tab delimited file that the rows remain as they were in excel.

Suggestions?

A: 

Are you sure about the split in 2 thing? Sure it's not your editor show a line in 2 parts because the row is too long? And are you sure you didn't introduce some funky new misfeature while "cleaning" the code? Did you try to process with the base version, ie with the comma's? What did it look like?

On the other hand, I think the Listener based approach of HSSF is a bit overkill for you application, and that the iterating approach may be enough, and much shorter and easier to grasp.

And you could also have a look at JExcelAPI which I think is simpler and lighter than HSSF.

fvu
A: 

Maybe you can try SmartXLS.

It is another java excel component which can also read/write csv files.

liya
A: 

It ended up being a bug in the system and the guys on the project confirmed it. They didn't correctly account for blank cells.

I ended up using a different library.

Kirk