WorksheetPage::ExcelSheet

Description

Connects to the Excel sheet named lpcszSheetName.


Connects to the Excel sheet having the index nSheetNumber.

Syntax

BOOL ExcelSheet( LPCSTR lpcszSheetName, int nColsNeeded = 0 )

string ExcelSheet( int nSheetNumber, int nColsNeeded = 0 )

Parameters

lpcszSheetName
[input]The name of the sheet to connect.
nColsNeeded
[input]Optionally specifies the minimum number of the underlying Origin columns to create (as many columns as there are data in the Excel sheet will automatically be created)

nSheetNumber
[input]The index (0 offset) of the sheet to connect.
nColsNeeded
[input]Optionally specifies the minimum number of the underlying Origin columns to create (as many columns as there are data in the Excel sheet will automatically be created)

Return

Returns TRUE on successful exit and FALSE on failure.


Returns the name of the sheet on successful exit and an empty string on failure.

Examples

EX1

// For this example to run an Excel window with at least three sheets 
// must exist and be the active window in Origin.
int WorksheetPage_ExcelSheet_ex1()
{
    WorksheetPage wp = Project.ActiveLayer().GetPage();
    if( !wp )
    {
        out_str("Invalid page!");
        return 0;
    }
    string strSheet = wp.ExcelSheet(2);
    BOOL bOK = wp.ExcelSheet(strSheet, 25);
    out_int("OK = ", bOK);
    Worksheet wks = wp.Layers(strSheet);
    if( !wks )
    {
        out_str("Invalid sheet!");
        return 0;
    }
    Column col = wks.Columns(24);
    if( !col )
    {
        out_str("Invalid column!");
        return 0;
    }
    Dataset ds(col);
    if( !ds )
    {
        out_str("Invalid dataset!");
        return 0;
    }
    ds.SetSize(100);
    ds = 1;
    ds[3] = 765.234;
    return 0;
}

Remark

Connects to the Excel sheet having the index nSheetNumber and adds columns as needed so that there are at least nColsNeeded columns in the underlying Layer object.

See Also

WorksheetPage::OpenExcel

header to Include

origin.h