I'm using C# and EPPlus to import .csv
data into a workbook. My only issue is that after the import into Excel, I am losing trailing zeroes on the data.
For example:
- in the
.CSV
file, the data is this: 1250.80 - in the
.xlsx
file, the data ends up being 1250.8
Seems minor but I need this to compare workbook to workbook and not see all of these diffs.
Here is the read routine
string[] csvInputfile = File.ReadAllLines(filePathName);
Here is how I am trying to put double quotes around the data
for (int idx = 0; idx < csvInputfile.Length; idx++)
{
csvInputfile[idx] = csvInputfile[idx].Replace(",", ",\"");
}
Here I am writing the contents to the Excel instance
for (int i = 0; i < csvInputfile.Length; i++)
{
ExcelWorksheet curWorksheet = excelPackage.Workbook.Worksheets.Add(csvInputfile[outerLoopCnt]);
for (int j = 0; j < csvInputfile.Length; j++)
{
innerLoopCnt++;
curWorksheet.Cells[j + 1, 1, j + 1, 100].Style.Numberformat.Format = "@";
curWorksheet.Cells[j + 1, 1].LoadFromText(csvInputfile[innerLoopCnt], format);
if (csvInputfile[innerLoopCnt + 1] == "")
{
outerLoopCnt = innerLoopCnt + 2;
innerLoopCnt += 2;
break;
}
}
if (innerLoopCnt == csvInputfile.Length)
{
break;
}
}
Here I save the file:
excelPackage.SaveAs(file);
This is the general idea and its not working very well. This is a crude approach but I'm not sure how else to make this work, I would appreciate any help