How to export a Datatable to Excel without formatting the information?

8

I need to export a number to Excel, but it always formats in an inappropriate way.

Expected form: -8,0902322222234

Received: -809.023.222.222.234

Column data for Datatable is typed with string. Data is displayed in DatagridView .

Before they are exported, they appear as expected.

    
asked by anonymous 02.01.2016 / 00:14

1 answer

7

Prefix the data with a single ' in the export.

For Excel, a data prefixed by ' is interpreted as text, and will not be formatted or interpreted.

The single quotation mark, when the 1st character does not appear in the display.

Important:

Being strings , numeric data will no longer be right aligned by default in LTR languages, nor will dates and percentages work as such.

    
02.01.2016 / 00:39