Excel Data Import problem (adding single quotation marks before data ')

Source: Internet
Author: User

When I imported Excel Data yesterday, I accidentally found that some of the data could not be imported normally. Later I found that the data item content was already null when I imported it to dataset. It seems that it was an Excel Data source problem, after you view the data items that cannot be normally imported in a targeted manner, you can find the difference. The data format of the null cells is different from that of other cells, and there is no green triangle in the upper left corner. Follow these steps to modify the cell format, then the operation is OK. It seems that the format of the cell is caused.

 

The procedure is as follows:
1. Select any cell in the worksheet. For example, select C5 cell and enter '1' in the cell.
2. Select the C5 cell and click the "Start" tab → "format brush" under the "Clipboard" group. The mouse changes to a small brush shape.
3. Select cell A1: A18 and use this brush to fl the area.
4. Select cell A1: A18, click the "column" button in the "data tools" group under the "data" tab → next → select "text" in "column data format" → complete.
 

The import code is as follows:

Dataset dsexcel;
Httppostedfile file;
String strfilepath, strexe;
Strfilepath = string. empty;
If (fileupload1.hasfile)
{
File = fileupload1.postedfile;
Strexe = path. getextension (file. filename );
If (! Strexe. toupper (). Equals (". xls "))
{
Share. promptmessage (this, "the file format is incorrect! Select the correct Excel file! ");
Return false;
}
Strfilepath = configurationmanager. deleetpipeline ["affixpath"];
If (! Directory. exists (strfilepath ))
Directory. createdirectory (strfilepath );

Strfilepath + = "//" + m_excelfilename;
File. saveas (strfilepath );
}

If (! File. exists (strfilepath ))
{
Share. promptmessage (this, "An error occurred while uploading the Excel file! ");
Return false;
}

Dsexcel = excelmanage. exceltods (strfilepath );
If (dsexcel! = NULL & dsexcel. Tables [0]. Rows. Count> 0)
{
Import Operation .......
}

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.