Auslesen einer Excel-Tabelle mit SQL
Michael Böhme
Halloich würde gerne eine Excel-Tabelle mittels einer SQL-Query auslesen. Habe aber bereits die Aussage bekommen das dieses unter einem 64Bit System nicht funktioniert.
Hat jemand auch diese Erfahrung gemacht und wenn nicht eine kurze Anleitung wie es dann doch funktioniert?
Ziel ist es in einer Excel-Tabelle, in einer definierten Spalte einen Eintrag zu finden und auszulesen. Zusätzlich ggf. auch weitere Einträge in der gleichen gefundenen Reihe in folgenden Spalten auszulesen.
Schon einmal vielen Dank für Eure Mühe....
Paul Witmond
Hi Michael,We have developed a working solution using the Excel com object
Excel.Application excelApp = new Excel.ApplicationClass();
Excel.Workbook excelWorkbook = excelApp.Workbooks.Open(fileName);
Excel.Sheets excelSheets = excelWorkbook.Worksheets;
Excel.Worksheet worksheet;
string[] SheetArray = new string[excelSheets.Count];
for (int teller = 1; teller <= excelSheets.Count; teller++)
{
worksheet = (Excel.Worksheet)excelSheets.get_Item(teller);
SheetArray[teller - 1] = worksheet.Name;
}
step 1 is getting a list of all worksheets
step 2 is selecting the worksheet and list all columns
step 3 is reading the excel sheet (using get_range) and inserting this into SQL
HTH
Paul
Michael Böhme
Hi Paul,thank you for your answer. Is this a SQL-Statement or CS-Code? I dont understand it. Is it possible to get a complete code from you? I need only a small kick.....
Thank you !
Paul Witmond
please mail me[email="paul.witmond@swsolutions.nl"]paul.witmond@swsolutions.nl[/email]
Comments
Please sign in to leave a comment.