Wednesday, June 22, 2016

Bypass excel csv formula conversion on fields starting with + or -

When you create a csv file with some entry start character is minus(-) or plus(+)  it will not open correctly in Microsoft EXCEL.

I have found few solutions for that and you can try out any format which will suits for you.

I java coding I tried "StringEscapeUtils.escapeCsv(String args)"  method which comes with apache "commons-lang.jar" and it did not resolve that.

Some how I found the correct manipulation


The csv entry I have is
------------------------------------------------------------------------
1,ERROR,- no file(s) to resolve.,null
------------------------------------------------------------------------

This will not show correctly. most of the time excel cell will look like "#NAME?"

to get the correct excel file conversion from csv, we can do following

1. add space before minus(-)
2. add space before minus and put the whole line within quotes
3. add equal sign(=) before also

so solution will looks like

----------------------------------------------------------------------------
1,ERROR, - no file(s) to resolve.,null
1,ERROR," - no file(s) to resolve.",null
1,ERROR,=" - no file(s) to resolve.",null

----------------------------------------------------------------------------


you can do same with plus sign(+)

No comments:

Post a Comment