FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Excel and FiveWin
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Excel and FiveWin
Posted: Mon May 08, 2023 12:15 PM

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.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 218
Joined: Mon Feb 07, 2022 09:54 PM
Re: Excel and FiveWin
Posted: Mon May 08, 2023 02:53 PM
Hi Michel,

please, try this for example row #4:
Code (fw): Select all Collapse
   oSheet := oExcel:Get( "ActiveSheet" )

   oSheet:Rows( 4 ):Delete()
   oSheet:Rows( 4 ):Insert()
Regards,
Detlef
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Excel and FiveWin
Posted: Mon May 08, 2023 03:11 PM
See if it helps:
Code (fw): Select all Collapse
// 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
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: Excel and FiveWin - Solved
Posted: Mon May 08, 2023 03:27 PM

Thanks a lot for your help.

Problem solved.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Continue the discussion