Hello,
I'm very sorry but I might have asked this question before. Unfortunately I can't find it anymore.
But can someone tell me how to add or delete lines in an Excel worksheet?
Thank you very much in advance for any help.
oSheet := oExcel:Get( "ActiveSheet" )
oSheet:Rows( 4 ):Delete()
oSheet:Rows( 4 ):Insert()
// C:\FWH..\SAMPLES\EXCELPRV.PRG
#Include "FiveWin.ch"
FUNCTION Main()
LOCAL oPrn, oFont, nRow, nCol
USE STATES NEW SHARED
STATES->( StatesReport() )
CLOSE STATES
RETURN NIL
STATIC FUNCTION StatesReport()
LOCAL oPrn, oFont, nRow
GO TOP
PRINT oPrn PREVIEW
// AQUI LIGA O EXCEL.
oPrn:bToExcel := {|| ( Alias() )->( StatesToExcel() ) }
DEFINE FONT oFont NAME "TAHOMA" SIZE 0, - 10 OF oPrn
PAGE
nRow := 1
WHILE .NOT. Eof()
SYSREFRESH()
@ nRow, 5.0 PRINT TO oPrn TEXT FIELD->CODE SIZE 1, 0.4 CM FONT oFont
@ nRow, 6.0 PRINT TO oPrn TEXT FIELD->NAME SIZE 10, 0.4 CM FONT oFont
nRow += 0.5
SKIP
ENDDO
ENDPAGE
ENDPRINT
RELEASE FONT oFont
GO TOP
RETURN NIL
STATIC FUNCTION StatesToExcel()
LOCAL oExcel, oBook, oSheet, nRow
oExcel := ExcelObj()
oExcel:ScreenUpdating := .F.
oBook := oExcel:WorkBooks:Add()
oSheet := oExcel:ActiveSheet
GO TOP
nRow := 1
WHILE .NOT. Eof()
SYSREFRESH()
oSheet:Cells( nRow, 1 ):Value := FIELD->CODE
oSheet:Cells( nRow, 2 ):Value := FIELD->NAME
nRow++
SKIP
ENDDO
GO TOP
oSheet:Columns( 1 ):AutoFit()
oSheet:Columns( 2 ):AutoFit()
oExcel:ScreenUpdating := .T.
oExcel:Visible := .T.
RETURN NIL
// FIN / END
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot], ShumingWang and 60 guests