Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

The ExcelPackage object does not return sheets

$
0
0

I am trying to upload an excel file to a hosted Blazor webassembly application, for which I am using the following code:

string path= @"D:\Otros\LibrosExcel\ReferenciasDotación.xls";FileInfo fileInfo = new FileInfo(path);ExcelPackage.LicenseContext = LicenseContext.NonCommercial;using (ExcelPackage excelPackage = new OfficeOpenXml.ExcelPackage(fileInfo)){    //loop all worksheets    ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets.FirstOrDefault();    //loop all rows    for (int i = 1; i <= worksheet.Dimension.End.Row; i++)    {        //loop all columns in a row        for (int j = 1; j <= worksheet.Dimension.End.Column; j++)        {            //add the cell data to the List            if (worksheet.Cells[i, j].Value != null)            {                excelData.Add(worksheet.Cells[i, j].Value.ToString());            }        }    }}return excelData;

but the line of code

ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets.FirstOrDefault ();

returns null


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>