EPPlus icon indicating copy to clipboard operation
EPPlus copied to clipboard

BigInteger are shown as text in Excel

Open sebcom opened this issue 3 years ago • 1 comments

I had encountered a strange behavior in EPPlus 6.0.3 with BigIntegers.

By filling the sheet with LoadFromCollection where the list contains members of type BigInteger the corresponding columns in the Excel sheet are stored as text and Excel is warning with "Number stored as Text" -> https://stackoverflow.com/questions/33381121/how-can-i-remove-number-stored-as-text-prompt-upon-export-to-excel-using-epplu

After casting the BigInteger fields into regular integers everything works as expected.

public struct BigIntegerTest { public BigInteger Value { get; set; } };

worksheet.Cells[1, 1].LoadFromCollection(new BigIntegerTest[] { new BigIntegerTest { Value = 1 }, new BigIntegerTest { Value = 2 } }.ToList());

sebcom avatar Jun 01 '22 15:06 sebcom

EPPlus will use the public instance members of the class/struct if not specified in the MemberInfo. In this case BigInteger has the following properties if set to for example 2: {2} IsEven: true IsOne: false IsPowerOfTwo: true IsZero: false Sign: 1

I suggest that you, if possible, converts your list to double instead as Excel and EPPlus works with double's anyway.

JanKallman avatar Jun 02 '22 06:06 JanKallman