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;
8
  • What library are you using to read it? Commented May 31, 2017 at 4:00
  • Possible duplicate of Create Excel (.XLS and .XLSX) file from C# Commented May 31, 2017 at 4:34
  • @JoePhillips using Excel = Microsoft.Office.Interop.Excel; Commented May 31, 2017 at 4:40
  • Can you include the error which is being returned, and which line of code it occurs on ? Commented May 31, 2017 at 4:51
  • You need to install Excel on the server but it would be better to use a decent library instead of interop Commented May 31, 2017 at 5:10

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.