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

Asked

Viewed 399 times

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

The data from the Datatable are typed with string. The data is displayed in a DatagridView.

Before they are exported, they appear as expected.

1 answer

7


Prefix the data with a single quote ' on export.

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

A single quote, when in the first character, does not appear in the display.

Important:

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.