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
Title:
C# Read Data From Excel
Miscellaneous
Thread ID:
01368976
Message ID:
01368976
Views:
59
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.
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Next
Reply
Map
View

Click here to load this message in the networking platform