Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
C# Read Data From Excel
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
C# Read Data From Excel
Divers
Thread ID:
01368976
Message ID:
01368976
Vues:
57
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform