2.1.13.18 og_get_excel_sheet_names


Description

Read Excel file to get list of sheet names

Syntax

int og_get_excel_sheet_names( LPCSTR lpcszFilename, StringArray * psaSheets )

Parameters

lpcszFilename
[input] full path Excel file name
psaSheets
[output] array of sheet names

Return

Number of sheets if success, EXCEL_ERR_FILE_NO_FOUND if file not found

Examples

EX1

#include <oExtFile.h>
//run by
//dlgfile g:=*.xlsx;ee(fname$);
void ee(string strFile)
{
    vector<string> vsSheets;

    //extract sheet names from the given Excel file
    int nn = get_excel_sheet_names(strFile, &vsSheets);
    if(nn <= 0)
        //if no sheets found or file is invalid
        out_str("not found");
    else {
        //loop and print sheet names to Script Window
    	for(int ii = 0; ii < vsSheets.GetSize(); ii++) {
    		printf("%d: %s\n", ii+1, vsSheets[ii]);
    	}
    }
}

Remark

See Also

Header to Include

oExtFile.h

Reference