I export data from datagrid to Excel and one column with numbers is with error 'numbers stored as text'. I am trying to convert them using following code, but its not working. Could you suggest?
The problem is that then column headers are moved up and data is broken.
worksheet.Range["E5", "E5"].EntireColumn.TextToColumns();
worksheet.Columns[5].NumberFormat = "# ##0,00";
This code converts numbers stored in text format to number format. If you want to use it to opposite direction set the fieldinfo to { 1, 2 }.
Range rng = Worksheet.Range["A1:A10""];
rng.TextToColumns(rng, XlTextParsingType.xlDelimited, XlTextQualifier.xlTextQualifierDoubleQuote, Tab: true, FieldInfo: new int[] { 1, 1 }, TrailingMinusNumbers: true);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.