Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88111

C# Convert Number stored as Text to Number when exporting to Excel

$
0
0

I export data from datagried 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?

 Microsoft.Office.Interop.Excel.Range rangeOfValues = worksheet.Range["E5", "E5"].EntireColumn;
 rangeOfValues.Cells.NumberFormat = "# ##0,00";
 rangeOfValues.Value = rangeOfValues.Value;

I also tried this code, but then column headers are moved up and data is broken.

  worksheet.Range["E5", "E5"].EntireColumn.TextToColumns();
  worksheet.Columns[5].NumberFormat = "# ##0,00";

Viewing all articles
Browse latest Browse all 88111

Trending Articles



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