I am writing a program in C# that needs to export a List<MyObject>
into Excel and I'm using EPPlus for doing so.
My challenge is that my object has a property:
string Prop1 { get; set; }
And, one of the values I need to export has a value that, for example, is of the form of Prop1 = "123E4"
.
The challenge is that the EPPlus LoadFromCollection
method exports this to Excel, but Excel converts it into a number using scientific notation (Outputted value = 1.23E+06
or 1230000
).
I've tried setting the entire column to .Style.Numberformat.Format = "@"
(and any other style I could think of) and I've even tried setting the style before and after the LoadFromCollection
method is called.
I also tried preceding the string with a '
character, but that actually keeps that character in each cell within that column which then makes the values incorrect for analysis.
I'm playing around with converting my List to a DataTable so as to use the LoadFromDataTable
method, but even that seems to not be working.
Any ideas / suggestions on how I can export this as pure text
"123E4"
into a number1230000
. Disabling the warning doesn't stop the conversion from happening, sadly :/ – Mitzi