Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

New Post: How do I stop getting the "number stored as text" message?

$
0
0
I am having a similar issue. I have an Oracle datasource that I'm importing into a datatable (via ODP.NET).

I can create the spreadsheet, but I always get the "number stored as text" message. I have been using a workaround, but now I have a data set that's just too big.

Here is how I'm currently trying to solve the issue: (formatCols is a list of NameActionDictionary, which contains column name, position and format)
       foreach (NameActionDictionary numCol in formatCols)
       {
            ws.Cell(1, numCol.ColLoc).Value = 0;
            ws.Column(numCol.ColLoc).DataType = (numCol.ColType == "date") ? XLCellValues.DateTime : XLCellValues.Number;
            if (numCol.ColType != "date" && numCol.ColType != "number")
            {
                ws.Column(numCol.ColLoc).Style.NumberFormat.Format = getNumberFormatType(numCol.ColType);
            }
            ws.Cell(1, numCol.ColLoc).DataType = XLCellValues.Text;
            ws.Cell(1, numCol.ColLoc).Value = numCol.ColHead;
        }
Is there anyway I can solve this problem? I want dates and numbers to be stored as such.

Thanks.

Viewing all articles
Browse latest Browse all 1877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>