Share via


ExcelService.GetWorkbook Method

Gets the contents of the entire open workbook.

Namespace:  Microsoft.Office.Excel.Server.WebServices
Assembly:  Microsoft.Office.Excel.Server.WebServices (in Microsoft.Office.Excel.Server.WebServices.dll)

Syntax

'Declaration
<WebMethodAttribute> _
Public Function GetWorkbook ( _
    sessionId As String, _
    workbookType As WorkbookType, _
    <OutAttribute> ByRef status As Status() _
) As Byte()
'Usage
Dim instance As ExcelService
Dim sessionId As String
Dim workbookType As WorkbookType
Dim status As Status()
Dim returnValue As Byte()

returnValue = instance.GetWorkbook(sessionId, _
    workbookType, status)
[WebMethodAttribute]
public byte[] GetWorkbook(
    string sessionId,
    WorkbookType workbookType,
    out Status[] status
)

Parameters

  • sessionId
    Type: System.String
    The Excel Web Services session ID.
  • status
    Type: []
    Alert information.

Return Value

Type: []
The entire workbook loaded in the session.

Remarks

This method returns a byte array, with the same file format that was loaded into the session. Supported file formats are Excel Workbook (*.xlsx) and Excel Binary Workbook (*.xlsb).

Examples

            // Instantiate the Web service
            ExcelService xlSrv = new ExcelService();
            Status[] status;
            // Set the credentials for requests
            // In this example, the default credentials are used
            xlSrv.Credentials = System.Net.CredentialCache.DefaultCredentials;

            //Open the workbook, call GetWorkbook and close the session.
            string sessionId = xlSrv.OpenWorkbook(args[0], "en-US", "en-US", out status);
            byte[] wb = xlSrv.GetWorkbook(sessionId, WorkbookType.FullSnapshot, out status);
            status = xlSrv.CloseWorkbook(sessionId);

See Also

Reference

ExcelService Class

ExcelService Members

Microsoft.Office.Excel.Server.WebServices Namespace