Forum Discussion
murugans1011
12 years agoRegular Contributor
HI read/write excel file can also be done with open office api in easier way lik excel.
also Tc has the builtin table type variable tat can store values lik excel see link for more info
http://support.smartbear.com/viewarticle/55435/
sample code to access open office
Sub WriteToExcel(filepath,sheetname,row,col)
Dim propertyN(0)
Set ServiceManager = CreateObject("com.sun.star.ServiceManager")
Set propertyN(0) = ServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
propertyN(0).Name = "Hidden" 'Used to work with Gui disabled
propertyN(0).Value = True
Set Desktop = ServiceManager.createInstance("com.sun.star.frame.Desktop")
Set Document =Desktop.LoadComponentFromURL("file:///"+aqString.Replace(filepath,"\","/")+"", "_blank", 0, propertyN) 'Gets filepath
Set Sheets = Document.getSheets()
Set Sheet = Sheets.getByName(sheetname)
Sheet.getCellByPosition(Col,row).String="PASS"
Set CellPass=Sheet.getCellByPosition(col,row)
CellPass.CharColor= RGB(0,0,0)
if Document.hasLocation AND Not Document.isReadOnly Then
Document.store
'Document.StoreAsUrl "file:///"+aqString.Replace(filepath,"\","/")+"",propertyN
else
Log.Error "Document not saved:Read-Only"
End if
Document.Close (True)
Desktop.terminate
End sub
also Tc has the builtin table type variable tat can store values lik excel see link for more info
http://support.smartbear.com/viewarticle/55435/
sample code to access open office
Sub WriteToExcel(filepath,sheetname,row,col)
Dim propertyN(0)
Set ServiceManager = CreateObject("com.sun.star.ServiceManager")
Set propertyN(0) = ServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
propertyN(0).Name = "Hidden" 'Used to work with Gui disabled
propertyN(0).Value = True
Set Desktop = ServiceManager.createInstance("com.sun.star.frame.Desktop")
Set Document =Desktop.LoadComponentFromURL("file:///"+aqString.Replace(filepath,"\","/")+"", "_blank", 0, propertyN) 'Gets filepath
Set Sheets = Document.getSheets()
Set Sheet = Sheets.getByName(sheetname)
Sheet.getCellByPosition(Col,row).String="PASS"
Set CellPass=Sheet.getCellByPosition(col,row)
CellPass.CharColor= RGB(0,0,0)
if Document.hasLocation AND Not Document.isReadOnly Then
Document.store
'Document.StoreAsUrl "file:///"+aqString.Replace(filepath,"\","/")+"",propertyN
else
Log.Error "Document not saved:Read-Only"
End if
Document.Close (True)
Desktop.terminate
End sub