Get list of sheet names from Excel file
int get_excel_sheet_names( LPCSTR lpcszFile, StringArray * pNames, IntArray * pRows = NULL, bool bCheckBinaryFormat = false, IntArray * pMainheader = NULL, IntArray * pSubheader = NULL )
return 0 if fail, else return the number of sheet
EX1
#include <oExtFile.h> void impxls(string strFile, bool bheading = true, int nSheet = 0, bool bCellStyles = false) { vector<string> vsSheets; int nn = get_excel_sheet_names(strFile, &vsSheets); if(nn <= 0) { out_str("not a valid Excel file"); return; } Worksheet wks = Project.ActiveLayer(); ExcelImportOptions stR; stR.xlsctrl.m_dwRXC = RXC_RESET_FORMAT | RXC_VALUE | RXC_VALUE_FORMAT | RXC_AUTO_RENAME_SHEET; if(bCellStyles) stR.xlsctrl.m_dwRXC |= RXC_STYLE; if(bheading) { stR.header.SubheaderLines = -1; stR.header.LongName = 1; } int nC2=-1;//to receive output actual last column //destination columns stR.xlsctrl.m_nStartColIndex = 0; stR.xlsctrl.m_pnLastColIndex = &nC2; int nErr = wks.ImportExcel(strFile, nSheet, &stR, true); if(nErr != 0) out_int("failed: ", nErr); }
oExtFile.h