Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C# Read Data From Excel
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01368976
Message ID:
01369000
Views:
5
My best suggestion is to use VB.Net because it can use named parameters and C# cannot (currently -- this feature is being added in C# 4.0).

>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.
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Previous
Reply
Map
View

Click here to load this message in the networking platform