2
votes

I'm performing my first try of tackling Excel Services in SharePoint 2010. I'm trying to open an Excel file that I've uploaded to my shared documents. I have verified that I can manually open the file via the browser using the following url:

http://myserver/Shared%20Documents/Adds2011.xls

However when passing this to the following web routine I receive an error. Here is the routine:

Private Sub OpenExcel(myurl As String)
    Dim xlApp As New exServices.ExcelService
    xlApp.Credentials = System.Net.CredentialCache.DefaultCredentials
    Dim status(10) As exServices.Status
    Dim sessionID As String = ""
    Try
        sessionID = xlApp.OpenWorkbook(myurl, "en-US", "en-US", status)

        Dim sheetInfo() As exServices.SheetInfo = xlApp.GetSheetNames(sessionID, status)

        Dim cell As Object = xlApp.GetCell(sessionID, sheetInfo(0).Name, 1, 1, True, status)
    Catch ex As Exception
        Debug.WriteLine(ex.ToString)
    End Try
    If sessionID <> "" Then
        xlApp.CloseWorkbook(sessionID)
    End If

End Sub

I receive the following error:

A first chance exception of type 'System.Web.Services.Protocols.SoapException' occurred in System.Web.Services.dll System.Web.Services.Protocols.SoapException: The workbook that you selected cannot be opened.

The workbook may be in an unsupported file format, or it may be corrupt. at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at SMSMInventory.exServices.ExcelService.OpenWorkbook(String workbookPath, String uiCultureName, String dataCultureName, Status[]& status) at SMSMInventory.LoadSpreadsheetUserControl.OpenExcel(SPFile mySpFile) Auto-attach to process '[4292] w3wp.exe' on machine 'FS-CHI-SPDEV' succeeded. A first chance exception of type 'System.Web.Services.Protocols.SoapException' occurred in System.Web.Services.dll

Can anyone tell me what I'm doing wrong?

1

1 Answers

1
votes

After contacting Microsoft support, they pointed out my Error:

You cannot open a .xls in the browser (see below URL):

Differences between using a workbook in Excel and Excel Services http://office.microsoft.com/en-us/excel-help/differences-between-using-a-workbook-in-excel-and-excel-services-HA010021716.aspx

All other Microsoft Office Excel file formats are unsupported, including Office Excel 2007 Macro-Enabled Workbook (.xlsm) and Office Excel 2007 97-2003 Workbook (.xls).

Save as .xlsx and try again.

Using the recommended format solved my problem.