简体   繁体   中英

How do I preserve the leading 0 of a number using Unoconv when converting from a .csv file to a .xls file?

I have a 3 column csv file. The 2nd column contains numbers with a leading zero. For example:

044934343

I need to convert a .csv file into a .xls and to do that I'm using the command line tool called 'unoconv'.

It's converting as expected, however when I load up the .xls in Excel instead of showing '04493434', the cell shows '4493434' (the leading 0 has been removed).

I have tried surrounding the number in the .csv file with a single quote and a double quote however the leading 0 is still removed after conversion.

Is there a way to tell unoconv that a particular column should be of a TEXT type? I've tried to read the man page of unocov however the options are little confusing.

Any help would be greatly appreciated.

Perhaps I came too late at the scene, but just in case someone is looking for an answer for a similar question this is how to do:

unoconv -i FilterOptions=44,34,76,1,1/1/2/2/3/1 --format xls <csvFileName>

The key here is "1/1/2/2/3/1" part, which tells unoconv that the second column's type should be "TEXT", leaving the first and third as "Standard".

You can find more info here: https://wiki.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Filter_Options#Token_7.2C_csv_import

BTW this is my first post here...

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