Hello,
I’ve got a problem I’m trying to solve for a long time.
I want to save my worksheet, with imported data table, as .csv file.
One of data table’s column has values with leading zeros. This column is type of string.
When I open created file in text editor it is all fine - leading zeros are there.
But when I do open this file in Excel, leading zeros are missing.
I guess it is because cells are ‘general’ type.
Unfortunately I can’t figure out how to change their type. Is that because it is .csv file? I was able to do it when save format was .xls or .xlsx.
Pieces of my code, I tried many variations of something like these, but nothing happens.
Style style = document.CreateStyle();
style.Number = 49;
// style.Custom = “@”;
document.Worksheets[0].Cells[“N13”].SetStyle(style1, new StyleFlag() { NumberFormat = true, CellShading = true });
Style s = document.Worksheets[0].Cells[“N13”].GetStyle();
s.Number = 49;
document.Worksheets[0].Cells[“N13”].SetStyle(style2, new StyleFlag() { NumberFormat = true, CellShading = true });
Also tried:
Workbook document = new Workbook(FileFormatType.CSV);
document.DefaultStyle.Custom = “@”;
// document.DefaultStyle.Number = 49;
Saving code:
TxtSaveOptions opts = new TxtSaveOptions();
opts.Separator = ‘;’;
opts.Encoding = System.Text.Encoding.UTF8;
document.Save(saveFileName, opts);
Can this be achieved at all for .csv saving format?
Thanks for reply!
Dawid