C # Methods for importing Excel files to Oracle

Source: Internet
Author: User

When you normally import Excel into Oracle, here's how to summarize:

1. Use OLE mode:

        stringConnStr ="provider=microsoft.jet.oledb.4.0;"+"Data source="+ file. xls+"; Extended Properties=excel 8.0"; OleDbConnection Conn=NewOleDbConnection (CONNSTR); Conn.        Open (); DataTable DT=NewDataTable (); OleDbDataAdapter Odda=NewOleDbDataAdapter ("select * FROM [sheet1$]", conn); Odda.        Fill (DT); returnDt
..... Follow-up action ...

2, first turn Excel into TXT document, in the stream to read, code more, only record the specific steps:

(1) Start the word process to convert Excel to TXT, and then quit Word to delete the Excel file

(2) Use StreamReader to read each line of TXT and then split it to each column with "\ T"

Note: If it is a very standard word segmentation should be no problem, if it is artificial may appear carriage return, then use the system comes with StreamReader to resolve each row, then the problem may occur, at this time my own method is to judge the number of rows, and then get the value of the row

(3) Get the line number, column value, build your own DataTable

(4) Subsequent storage

These two methods from the use of feeling the first more convenient, if it is very standard word so the first convenient, fast; the second slow, but good adaptability, directly to the text file preservation of the original format, suitable for human-built tables

These two methods are used temporarily in the work, if there are new additions in the

C # Methods for importing Excel files to Oracle

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.