C # import Excel three way, 64-bit machine does not support the first kind

Source: Internet
Author: User

This article originates from the network collection, if has the inappropriate place, please leave a message.

The first way:

Using OLE DB to get the data for an Excel file and then a dataset to SQL Server, this approach has the advantage of being flexible enough to do what the user needs for each cell in the Excel table.

string Connexcel = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + FilePath + ";  Extended properties=excel 8.0 ";

The second way:

By means of COM components

The Third Way:

Through third-party plugins such as Aspose.cells

Aspose.Cells.Workbook Workbook = new Aspose.Cells.Workbook (); Workbook.                Open (strFileName); Aspose.Cells.Worksheets wsts = workbook.                worksheets; for (int i = 0; I<wsts. Count; i++) {Aspose.Cells.Worksheet WST= Wsts[i]; int MaxR= Wst.                    Cells.maxrow; int MaxC= Wst.                    Cells.maxcolumn; if (MaxR>0 && MaxC > 0) {DataTable dt = Wst.                        Cells.exportdatatableasstring (0, 0, MaxR + 1, MaxC + 1, true); Ds.                                          Tables.add (DT); }                }

C # import Excel three way, 64-bit machine does not support the first kind

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.