// Open a file in Excel OleAutoObj openExcelFile(string sFileName, bool bVisible) { OleAutoObj oleWorkbooks = null OleAutoObj oleExcel = null OleAutoArgs autoArgs = create oleExcel = oleGetAutoObject("Excel.Application") if (null oleExcel) { oleExcel = oleCreateAutoObject("Excel.Application") if(null oleExcel) { errorBox("Unable to open excel application") } olePut (oleExcel, "Visible", bVisible) // Get workbooks and open file clear autoArgs oleGet(oleExcel,"Workbooks", oleWorkbooks) put(autoArgs,"Filename", sFileName) oleMethod(oleWorkbooks,"Open",autoArgs) } delete autoArgs return oleExcel } //Get the worksheets OleAutoObj excelGetWorksheet(OleAutoObj oleExcel, int iSheetNumber) { OleAutoObj objExcelSheet = null string sSheetNumber = "Sheet" iSheetNumber "" OleAutoArgs autoArgs = create put(autoArgs ,sSheetNumber) oleGet(oleExcel,"WorkSheets",autoArgs ,objExcelSheet) delete autoArgs return objExcelSheet } string getCellValue(OleAutoObj objExcelSheet, int iRow, int iCol) { string sValue = null OleAutoObj objCell = null OleAutoArgs autoArgs = create put(autoArgs,iRow) put(autoArgs,iCol) oleGet(objExcelSheet,"Cells",autoArgs,objCell) if (!null objCell) { // Get the value oleGet(objCell,"Value",sValue) } delete autoArgs return sValue } //close excel void excelQuit(OleAutoObj oleExcel) { oleMethod(oleExcel, "Quit") oleCloseAutoObject(oleExcel) } // Main OleAutoObj oleExcel = openExcelFile("c:/temp/myFile.xls", false) OleAutoObj objExcelSheet = excelGetWorksheet(oleExcel, 1) string s = null s = getCellValue(objExcelSheet, 1, 1) print s "Row 1, Column 1: " s "\n" s = getCellValue(objExcelSheet, 2, 3) print s "Row 2, Column 3: " s "\n" excelQuit(oleExcel) " s "\n" excelQuit(oleEx