reading excel cell
Posted: Mon Nov 29, 2021 12:50 pm
I have problem reading excel cell. Here is my code:
LOCAL cExelFile AS STRING
LOCAL oExcel AS Microsoft.Office.Interop.Excel.Application
LOCAL oWorkbook AS Workbook
LOCAL oWorksheet AS Worksheet
oExcel := Microsoft.Office.Interop.Excel.Application{}
oExcel:Visible := FALSE
oWorkbook := oExcel:Workbooks:Open(Path.Combine( cDataPath, cExelFile ))
oWorksheet := oWorkbook:ActiveSheet // error XS0266
TRY
SELF:oPrTextBox:Text := oWorksheet:Cells[3, 5]:Value:ToString() // error XS1061
CATCH oEx AS Exception
MessageBox:Show(oEx:ToString())
FINALLY
oWorkbook:Close()
END TRY
error XS0266: Cannot implicitly convert type 'object' to 'Microsoft.Office.Interop.Excel.Worksheet'. An explicit conversion exists (are you missing a cast?)
error XS1061: 'object' does not contain a definition for 'Value' and no accessible extension method 'Value' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
Compilation failed (2 errors)
Does anybody have any idea?
Zeljko
LOCAL cExelFile AS STRING
LOCAL oExcel AS Microsoft.Office.Interop.Excel.Application
LOCAL oWorkbook AS Workbook
LOCAL oWorksheet AS Worksheet
oExcel := Microsoft.Office.Interop.Excel.Application{}
oExcel:Visible := FALSE
oWorkbook := oExcel:Workbooks:Open(Path.Combine( cDataPath, cExelFile ))
oWorksheet := oWorkbook:ActiveSheet // error XS0266
TRY
SELF:oPrTextBox:Text := oWorksheet:Cells[3, 5]:Value:ToString() // error XS1061
CATCH oEx AS Exception
MessageBox:Show(oEx:ToString())
FINALLY
oWorkbook:Close()
END TRY
error XS0266: Cannot implicitly convert type 'object' to 'Microsoft.Office.Interop.Excel.Worksheet'. An explicit conversion exists (are you missing a cast?)
error XS1061: 'object' does not contain a definition for 'Value' and no accessible extension method 'Value' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
Compilation failed (2 errors)
Does anybody have any idea?
Zeljko