This project has moved and is read-only. For the latest updates, please go here.

AutoFitColumns error: Not a legal OleAut date

Jun 12, 2017 at 5:07 PM
I am getting an error, the message is: "Not a legal OleAut date".

I get this error when I call this function: Worksheet.Cells.AutoFitColumns().

I have some columns with values that are beign represented as date, when I comment the AutoFitColumns function I get the excel exported but with wrong values:

Original value Excel value
1171-2 -266229
1.1 42736
1.2 42767
1.3 42795
2.1 42737
2.2 42768

I am trying to set format like this:

Worksheet.Cells[row, column].Style.Numberformat.Format = "@"

to process the value as text, but it is not working.

How can I avoid values being represented as date?