Hi,
Thanks for replying back.
Hi Ishan,
The code snippet provided in our previous post works equally good if you are save the result in CSV format. Please check the following code snippet and it’s resultant file.
C#
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
var cells = worksheet.Cells;
Range range = cells.CreateRange("A1", "B3");
range[0, 0].PutValue("01-01-2001");
range[1, 0].PutValue("01-10-2003");
range[2, 0].PutValue("11-03-2004");
range[0, 1].PutValue("01-01-2001");
range[1, 1].PutValue("01-10-2003");
range[2, 1].PutValue("11-03-2004");
Style style = workbook.CreateStyle();
style.Custom = "@"; //Set the display format as Text/string
StyleFlag flag = new StyleFlag();
flag.NumberFormat = true; //Make the numbers formatting on
range.ApplyStyle(style, flag);
workbook.Save("C:/temp/output.csv");
That said, please confirm where are you loading the CSV to inspect the result. If you are loading it in Excel then it may format the values according to your locale, where the actual values are different therefore please use notepad to check the result.