Resolves an issue where the data type changes when importing a database from Excel into a DataTable (such as the number type becomes scientific notation and the percentage becomes a decimal)

Source: Internet
Author: User

When doing the project, C # reads the Excel data into a DataTable or dataset, sets breakpoints to view the DataTable, A field that finds Excel displayed as a number of long digits, such as 0.000012, is shown in the DataTable as scientific notation 1.2E-05, while a percentage such as 143% appears in the DataTable as 1.43. But I want to show in Excel what data, read to a DataTable or DataSet and excel in exactly the same way, the solution is as follows:

1) Open the Excel you want to import, select all the data (Ctrl + a)----copy (ctrl + C);

2) Create a new Notepad file, open it, paste it up (Ctrl + V);

3) Return the open Excel document, delete all the data inside, then select All (Ctrl + a) and right-click on ' Format Cells '----point ' text '----OK to exit the dialog box;

4) Then paste all the data in the open Notepad into Excel and save the small green triangle in the upper left corner of the data cell;

5) Once you have done this, all the data in Excel is stored in text format, and then the import is no problem.

Reference Document: http://blog.csdn.net/hcf_force/article/details/7824058

Resolves an issue where the data type changes when importing a database from Excel into a DataTable (such as the number type becomes scientific notation and the percentage becomes a decimal)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.