2009-09-10 8 views

Répondre

8

Si vous utilisez EPPlus, il est aussi simple que cela:

public void ImportExcelXls(HttpPostedFileBase fileBase) 
{ 
    using (var package = new ExcelPackage(fileBase.InputStream)) 
    { 
     // get the first worksheet in the workbook 
     ExcelWorksheet worksheet = package.Workbook.Worksheets[1]; 
     int col = 1; 

     for (int row = 1; worksheet.Cells[row, col].Value != null; row++) 
     { 
      // do something with worksheet.Cells[row, col].Value      
     } 
    } // the using 
} 
+0

http://rajandmello.blogspot.com/2010/07/get-excel-data-by-passing-file-stream.html – rjdmello

+1

Dans mon environnement, il lance '" Une erreur de disque s'est produite pendant une opération d'écriture. (Exception de HRESULT: 0x8003001D (STG_E_WRITEFAULT)) "' Erreur sur le second formulaire. – Muflix

Questions connexes