Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C# Read Data From Excel
Message
From
20/12/2008 17:40:28
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01368976
Message ID:
01368993
Views:
6
>I'm trying to read data in from excel into variables. This is what I have so far:
>
>
>public void ImportData()
>{
>    string sCustomer = "";
>    string sFile = @"C:\NSS\Excel Files\contract spares nss.xls";
>
>    Excel.ApplicationClass oExcel = new ApplicationClass();
>
>    Excel.Workbook oWorkBook = oExcel.Workbooks.Open(sFile, 0, true, 5, "", "",
>        true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true);
>
>    Excel.Worksheet oSheet = (Excel.Worksheet)oWorkBook.ActiveSheet;
>
>    for (int iRow = 0; iRow < oSheet.Rows.Count; iRow++)
>    {
>        sCustomer = oSheet.Cells[iRow, 1].ToString();
>    }
>    
>}
>
>
>
>On the line inside the loop I'm getting "Exception from HRESULT: 0x800A03EC"
>
>Anyone have an example of how to read data in from Excel using C#? Please don't point me to Google. I've been there all moring and not finding what works.

Kevin,
Check http://www.foxite.com/archives/0000153776.htm

Code is for VFP but you already have VFP background and it is very easy to change ADODB.Connection with OleDbConnection and such.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform