Re: Export data to OpenOffice Calc and MS Office Excel
Posted: Mon Apr 30, 2012 9:53 pm
*****************
Exclusive forum for HMG, a Free / Open Source xBase WIN32/64 Bits / GUI Development System
http://mail.hmgforum.com/
Code: Select all
LOCAL oServiceManager, oDesktop, oDoc, oSheet, oCtrl, oDispatcher
IF ( oServiceManager := win_oleCreateObject( "com.sun.star.ServiceManager" ) ) != NIL
oDesktop := oServiceManager:createInstance( "com.sun.star.frame.Desktop" )
oDispatcher = oServiceManager:createInstance ( "com.sun.star.frame.DispatchHelper" )
oDoc := oDesktop:loadComponentFromURL( "private:factory/scalc", "_blank", 0, {} )
ELSE
msginfo( "Error. OpenOffice not available.", win_oleErrorText() )
ENDIF
oCtrl := oDoc:getCurrentController()
oSheet := oDoc:getSheets:getByIndex( 0 )
oCell := oSheet:getCellByPosition( 0, 0 )
oCtrl:Select( oCell )
system.clipboard := 'Rathinagiri' + chr( 9 ) + '123'
oDispatcher:executeDispatch( oCtrl, ".uno:Paste", "", 0, { } )
return nil
Code: Select all
cRange := "A1:"+chr(asc("A")+nColumnCount) +ltrim(str(nRowCount))
oSheet:Range(cRange):Borders():LineStyle := xlContinuous
Code: Select all
oSheet:Range(oSheet:Cells(1, 1),oSheet:Cells(nRowCount, nColumnCount)):Borders():LineStyle := xlContinuous
But, If you want to use range, you need to present it as "A1:B10" for expample.rathinagiri wrote:That's why I don't ever use the cell name. Instead we can use the row id and column id.
Code: Select all
BasicBorder := TOleAuto():New("com.sun.star.table.BorderLine")
oBorder := oSheet:getCellRangeByPosition(nIndeksKolumny,0,nIndeksKolumny,nIleWierszy*(nStrona+1)):TableBorder
//BasicBorder:SetPropertyValue("Color", RGB(255,0,0))
BasicBorder:InnerLineWidth := 100
BasicBorder:OuterLineWidth := 100
BasicBorder:LineDistance := 200
oBorder:LeftLine = BasicBorder
oBorder:TopLine = BasicBorder
oBorder:RightLine = BasicBorder
oBorder:BottomLine = BasicBorder
oSheet:getCellRangeByPosition(4*i-2,0,4*i-2,nIleWierszy*(nStrona+1)):TableBorder := oBorder
Code: Select all
BasicBorder := TOleAuto():New("com.sun.star.table.BorderLine")
Code: Select all
oLineBorder := oServiceManager:Bridge_GetStruct("com.sun.star.table.BorderLine")
oLineBorder:Color := RGB(0, 0, 0)
oLineBorder:InnerLineWidth = 0
oLineBorder:OuterLineWidth = 10 // było 26
oLineBorder:LineDistance = 0 // było 24
// this border will be used for horizontal and vertical lines inside selected area
oLineBorder1 = oServiceManager:Bridge_GetStruct("com.sun.star.table.BorderLine")
//here, we can declare color of lines, remember RGB(nBlue, nGreen, nRed)
oLineBorder1:Color = RGB(0, 0, 0)
oLineBorder1:InnerLineWidth = 0
oLineBorder1:OuterLineWidth = 10
oLineBorder1:LineDistance = 0
oBorder = oServiceManager:Bridge_GetStruct("com.sun.star.table.TableBorder")
oLineBorder:OuterLineWidth = 10
oLineBorder:InnerLineWidth = 0
//oLineBorder:LineDistance = 30
//oLineBorder:Color = 0
oBorder:IsTopLineValid = 1
oBorder:IsBottomLineValid = 1
oBorder:IsLeftLineValid = 1
oBorder:IsRightLineValid = 1
oBorder:IsHorizontalLineValid = 1
oBorder:IsVerticalLineValid = 1
//Outer lines of selected area
oBorder:TopLine = oLineBorder
oBorder:BottomLine = oLineBorder
oBorder:LeftLine = oLineBorder
oBorder:RightLine = oLineBorder
//Inner lines
oBorder:HorizontalLine = oLineBorder1
oBorder:VerticalLine = oLineBorder1
Code: Select all
oSheet:getCellRangeByPosition(nStartCol, nStartRow, nEndCol, nEndRow):TableBorder := oBorder