Hi!
This is an example for excel.
Procedure SnimiXLSTSI()
LOCAL oExcel, oHoja, nRows, nCols, cDatXls
LOCAL aCampos:={}, nRow, nCol
Private POZR
cDatXls := GetStartUpFolder() + "\" +"example.xls"
msginfo(cDatXls)
oExcel := CreateObject( "Excel.Application")
if Ole2TxtError() != 'S_OK'
MsgInfo('Excel nije instaliran','Upozorenje')
Return
endif
oExcel:Visible := .T.
oExcel:Workbooks:Open( cDatXls)
oExcel:Set("data",.F.) //
oExcel:Sheets("data"):Select()
oHoja:=oExcel:Get( "ActiveSheet" )
oHoja:Range("B3"):Value := "data"
*** New Sheets***
oExcel:Set("PodDada",.F.) //
oExcel:Sheets("PodData"):Select()
oHoja:=oExcel:Get( "ActiveSheet" )
oHoja:Cells( 17, 11 ):Value := 2563
* oExcel:Quit()
* oHoja:End()
* oExcel:End()
Return
This is an example for calcl.
Procedure SnimiCalc()
local oServiceManager,oDesktop,oDocument,oSchedule,oSheet,oCell,oColums,oColumn,cDatXls
// inicijalizacija
IF ( oServiceManager := TOleAuto():New("com.sun.star.ServiceManager") ) != NIL
oDesktop := oServiceManager:createInstance("com.sun.star.frame.Desktop")
IF oDesktop = NIL
MsgStop('OpenOffice Calc nije instaliran','error')
RETURN Nil
ENDIF
cDatXls := GetStartUpFolder() + "\" +"data.xls"
IF FILE(cDatXls)
cDatXls:="file:///"+cDatXls
oDocument := oDesktop:loadComponentFromURL(cDatXls,"_blank", 0, {})
ELSE
oDocument := oDesktop:loadComponentFromURL("private:factory/scalc","_blank", 0, {})
ENDIF
oSchedule := oDocument:GetSheets()
oSheet := oSchedule:GetByName("Opci")
oSheet:getCellRangeByName( "E5" ):setString(ctod("01.01.2013")
oSheet:getCellRangeByName( "H5" ):setString(ctod("31.12.2013")
oSheet:getCellRangeByName( "E9" ):setValue( 5 )
oSheet:getCellRangeByName( "C17" ):setValue( 10 )
*******New sheet*****
oSheet := oSchedule:GetByName("PodData")
oSheet:getCellRangeByName( "C17" ):setValue( 10 )
endif
Return
You must have installed both applications(excel and OpenOffice.
Best Regards,
Miraš