Error while uploading .xlsx file using ExcelDataReader

1.1k views Asked by At

I am working on asp.net MVC project.

I use ExcelDataReader component to read excel file records.

Now when I published my project to server and upload a .xlsx file with uploader I get below mentioned exception message. There are no errors with local deployment but server.

Access to the path '\Microsoft Corporation\Internet Information Services\7.5.7600.16385' is denied.

and code where I am getting error is:

if (personsFile.FileExtension == ".xls")
{
     Stream st = new MemoryStream(personsFile.FileArray);
     reader = ExcelReaderFactory.CreateBinaryReader(st);
}
else if (personsFile.FileExtension == ".xlsx")
{
     Stream st = new MemoryStream(personsFile.FileArray);
     //exception occured on under line
     reader = ExcelReaderFactory.CreateOpenXmlReader(st);
}

But when I upload a .xls file, I dont have any error.

How to resolve issue with .xlsx extenstion?

1

There are 1 answers

0
Johan Appelgren On

This is most likely due to ExcelDataReader 2.x extracting the xlsx archive to %TEMP% before processing it. The current pre-alpha of 3.0 no longer does this. See https://github.com/ExcelDataReader/ExcelDataReader/releases.