1

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";

Problem shown

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
marijapt
  • 13
  • 5

1 Answers1

1

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);