Excel2CSV Removes leading zeros for timevalues

Hi,
when using cells for save a excel-file to a csv-file, the leading zeros for time-values are not in the csv-output-file.
Excel-Value: 01:59
CSV-Value: 1:59

The use of the properties display value and cell value make no difference.

Manuel

@manuel.memenga,

This is MS Excel behavior that does omit leading zeros with numeric or DateTime values. Anyways, please zip your template Excel file and post us, we will check if we can workaround it.

Attached is the example file:Example_File.7z (848.6 KB)

@manuel.memenga,

Thanks for the sample file.

There are no leading zeros for the time part of DateTime values pasted in the first column in your attached file, I could not find any leading zeros for the time part of the values in the cells of the first column. The column is formatted with custom string: “m/d/yyyy h:mm”. Could you please provide correct file or share a screenshot to highlight those values (when opening the file into MS Excel manually). Also, share your current code that you are using. We will check and assist you accordingly.

Attached is a screenshot of the Excel formats and code:
Example.7z (902.9 KB)

@manuel.memenga,

Thanks for the screenshot, sample file and sample code snippet.

Surprisingly when I open your Excel file into MS Excel (English) manually in us-english locale/regional settings, it shows the custom formatting (for the DateTime cells) as “m/d/yyyy h:mm”, see the screenshot attached.
sc_shot1.png (119.6 KB)

Could you please give us environment details with locale/regional settings and MS Excel language and version information. We will evaluate your issue further.

Hi,

Here is the information about the region and Excel version. I hope the information is sufficientInfos.zip (36.1 KB)

@manuel.memenga,

Thanks for providing us locale/regional settings details.

Could you please add the following line (in bold) to your code segment and then give it a try again, it should work fine:
e.g.
Sample code:

Using wb = New Workbook(“Example-File.xlsx”)
wb.Settings.Region = CountryCode.Germany
Dim saveOptions = New TxtSaveOptions(SaveFormat.CSV) With {
.SeparatorString = “;”
}
wb.Save(“Example-File.csv”, saveOptions)
End Using

Let us know if you still find the issue.

Thanks for the suggested solution.
Unfortunately that doesn’t work either. I’ve called up the value before and it’s already on the country code Germany.

@manuel.memenga,
We have fixed the issue with the time format and can achieve the desired results through the following code.

Workbook wb = new Workbook(filePath + "Example_File.xlsx");
wb.Settings.Region = CountryCode.Germany;
TxtSaveOptions saveOptions = new TxtSaveOptions(SaveFormat.Csv);
saveOptions.SeparatorString = ";";
wb.Save(filePath + "out.csv", saveOptions);

Please refer to the attachment. (189.1 KB)
Aspose.Cells 23.7 will include this fix.

@manuel.memenga,
Would you like to test again with the latest version Aspose.Cells 23.6? We have tested and found that Aspose.Cells 23.6 can also obtain the correct results.

It’s working! Thanks

@manuel.memenga
You are welcome. If you have any other issues, please feel free to contact us.