We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose Cells CSV not maintaining leading zeros

we are working on one of the requirement where in we are using Aspose cells to create CSV from database. one of the column is having value with leading zeros for example 0008797.however the CSV created does not display leading zeros.

we have tried
loadOptions.ConvertNumericData = false;
we have also tried setting PreserveString as true but it doesn’t work.
if we open CSV in notepad, it does show leading zeros, however, if we open it by clicking it, it does not display leading zeros.

any help in this regard would be appreciated.


I think you cannot do it in CSV file format, numbers formattings applied in a CSV file is not saved as this is only simple text format. you may try to create a simple CSV file. Right-click on a cell (e.g A1) and click "Format Cells..." options, now select "Text" from the category. Enter a value i.e. "0008797". Now, save/resave the CSV file, you got the error, anyways kindly save it. Now close the file. Again reopen the file into MS Excel and you will see that the leading zeros are gone. So, this is not possible in MS Excel either. You have to choose other file formats e.g XLS/XLSX etc.

If you still think that this is possible in MS Excel, please create such a CSV file (having values with leading zeros) in MS Excel manually and post it here, we will check it soon.

Thank you.