Reputation: 3747
Having worked with COM Interop Excel before and having the same problem, which was solved here. I now face the same issue with the EPPlus library (version 4.0.4.0).
This code should format the numbers in the outputfile:
for (int i = 10; i > 27; i += 4) {
//worksheetOut.Cells[String.Format("{0}:{1}", i, i + 1)].Style.Numberformat.Format = null;
worksheetOut.Cells[String.Format("{0}:{1}", i, i + 1)].Style.Numberformat.Format = "€###.###.###";
}
gives this result
I don't know how to use the solution from the question listed above, seeing that the 'only' way to set this format is by a string so I can't add culture settings.
Edit:
apparently you can't place a number-format on an entire row. I tried this code:
//range with only numbers, so no empty values or 'General' values
worksheetOut.Cells["A18:F19"].Style.Numberformat.Format = "###.###.###";
gives this result, I don't think I can change the decimal seperator to ,
and thousand separator to .
Upvotes: 0
Views: 1355
Reputation:
Should be I think (remove Format from the end)
worksheetOut.Cells[String.Format("{0}:{1}", i, i + 1)].Style.NumberFormat= "€###.###.###";
Upvotes: 1