0

I need to read the data of particular range in excel file and upload them in database.

The required data does not start at A1 cell instead, they start at A15 and A14 is the header row for columns. there are seven columns with headers.

(I tried to read cells via "get_Range" option)

We need to read the data in each cell and do a row by row update in database.

There are thousands of files of same type in a specific folder.

I am trying to achieve this as C# Console app because this is just a one time job.

lollol
  • 95
  • 1
  • 2
  • 13
  • 2
    Your question is very vague. What have you tried? – Tim Schmelter Feb 12 '13 at 10:18
  • Look here - http://stackoverflow.com/questions/15828/reading-excel-files-from-c-sharp – Snixtor Feb 12 '13 at 10:19
  • @Tim Schmelter : I tried looping through each file in the given folder and tried to copy the cell values. i am successful in looping the files but i couldn't go to the specific cells. :( – lollol Feb 12 '13 at 10:22
  • @ommuruganandam: It's still difficult to tell what you've done wrong. Please edit your question to add more informations. What rdbms are you using, how does your data and your table look like, how did you try to read the excel files, what kind of application are you creating? It's a difference whether you create a winforma app that runs once a month or a windows-service that runs at night or an app that is used heavily. – Tim Schmelter Feb 12 '13 at 10:27
  • Edited. please let me know whether this is clear ? – lollol Feb 12 '13 at 10:35
  • What technology are you using to get the data from the workbooks? Interop, OleDB? You have to provide more information if you expect an answer. – Sid Holland Feb 14 '13 at 16:25

1 Answers1

0

Here is the answer i found.

step 1 : Loop through each file in the source directory.

Step 2 : Add Excel Interop Reference. and Create Excel Application Class Object, and also for Workbook, and Range(for used range).

Step 3 : Use the Get Range() function and read the rows. (since this is solution is specific for a problem, the start and end ranges of rows and columns are well known)

Step 4 : Each read row can be constructed as a string till the end of the file. OR Insert can be done after reading each row.

step 5 : Get Connection String and Create SQLConnection Object to perform insert. Better to use Transaction-Commit.

Done. Thanks to all.

lollol
  • 95
  • 1
  • 2
  • 13