0

Below is my code to read a excel file. This works fine in the local machine. But I move this to the server it return error.

            Excel.Application xlApp = new Excel.Application();
            Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(@""+Path);
            Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1];
            Excel.Range xlRange = xlWorksheet.UsedRange;
shan
  • 9
  • 2

1 Answers1

2

The reason is because server-side Automation of Office is not supported.

There can be so many things that can go wrong with this. Its why Microsoft has employed the XML format starting with Office 2003.

If you want to process Excel files on the server use an XML library like ClosedXML or OLEDB as the Knowledge Base article suggests.

Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321