Open excel file from Sharepoint 2007 Document Library with C#

2

I'm trying to open an excel file from a Sharepoint Document Library. My application searches for the specific file, gets its link and uses it to download and further opening.

My app works on my machine and on test server, but when i send it to quality assurance servers, problems start.

I don't have access, and it won't be given, to QA machines. All i have is a bunch of Console.writes to see what happens.

From what i can tell, all works just fine until it tries to open the excel giving the following error:

Old format or invalid type library. (Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD))

From my search this is some bug related to the OS language, or difference between 2 OS languages that have this workaround http://support.microsoft.com/kb/320369.

The question is, all OS language properties are the same in all machines, if this would be the issue, i wouldn't be able to open the excel in neither my machine or test server. Also, in the workaround they use InvokeMember? Can't really see why would i do such thing.

Code: (I'm using Microsoft.Office.Interop.Excel;)

MSExcel.Application MyExcel = new MSExcel.ApplicationClass();
MSExcel.Workbook wb = MyExcel.Workbooks.Open(link, 0, true, 5, "", "", false, XlPlatform.xlWindows, "", true, false, 0, true, true, false);//Add(pathExcel);
MSExcel.Worksheet MyWS = (MSExcel.Worksheet)wb.Worksheets.get_Item(1);

Where link is the full url for the file.

I would appreciate any light on the subject. If anyone has another way to do the same i would also appreciate.

Thanks in advance.

c#
excel
sharepoint-2007
excel-interop
asked on Stack Overflow Dec 19, 2012 by FEST

1 Answer

0

User contributions licensed under CC BY-SA 3.0