FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Xlsxlibhb_ver2
Posts: 37
Joined: Fri Jan 02, 2009 03:12 PM
Xlsxlibhb_ver2
Posted: Tue Oct 03, 2023 08:01 PM
Dear All,

Here I leave the sources of our contribution for harbor and xharbour of the complete functions of John McNamara for the libxlsxwriter,

enjoy it

To download the complete library from https://www.mediafire.com/file/8bn1bbcxz022z6g/Xlsxlibhb_ver2.zip/file

Greetings
Arturo Tamayo Daza
Posts: 866
Joined: Tue Oct 16, 2007 08:57 AM
Re: Xlsxlibhb_ver2
Posted: Wed Oct 04, 2023 03:22 AM
arturo tamayo wrote:Dear All,

Here I leave the sources of our contribution for harbor and xharbour of the complete functions of John McNamara for the libxlsxwriter,

enjoy it

To download the complete library from https://www.mediafire.com/file/8bn1bbcxz022z6g/Xlsxlibhb_ver2.zip/file

Greetings
Arturo Tamayo Daza
Thank you so much.
Best Regards,



Richard



Harbour 3.2.0dev (r2503251254) => Borland C++ v7.7 32bit

MySQL v8.0

Harbour 3.2.0dev (r2503251254) => Borland C++ v7.7 64bit
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Xlsxlibhb_ver2
Posted: Wed Oct 04, 2023 04:07 AM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Xlsxlibhb_ver2
Posted: Thu Oct 05, 2023 12:01 AM

Many thanks to the authors for making this Great Library available to our Harbour community.

Thank you Mr. John McNamara and Mr. Arturo Tamayo Daza

Regards



G. N. Rao.

Hyderabad, India
Posts: 654
Joined: Fri Oct 21, 2005 05:54 AM
Re: Xlsxlibhb_ver2
Posted: Thu Oct 05, 2023 01:11 AM
Hi,

When I am trying to use the XlsxlibHb with xHarbour,
I am getting the following error.

ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
³ FiveWin for xHarbour 21.04 - Apr. 2021 Harbour development power ³Ü
³ (c) FiveTech 1993-2021 for Microsoft Windows 9X/NT/200X/ME/XP/Vista/7/8/10 ³Û
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙÛ
ÿ ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
Compiling...
xHarbour 1.2.3 Intl. (SimpLex) (Build 20201212)
Copyright 1999-2020, http://www.xharbour.org http://www.harbour-project.org/
Compiling 'chart_data_table.prg' and generating preprocessed output to 'chart_data_table.ppo'...

Lines 120, Functions/Procedures 2, pCodes 335
Embarcadero C++ 7.00 for Win32 Copyright (c) 1993-2015 Embarcadero Technologies, Inc.
chart_data_table.c:
Turbo Incremental Link 6.70 Copyright (c) 1997-2014 Embarcadero Technologies, Inc.
Error: Unresolved external '_hb_parvptr' referenced from C:\FWH\LIB\XLSXLIBHB.LIB|XlxsFunc
Error: Unable to perform link
* Linking errors *

Will this library work with only Harbour or xHarbour too ?

-Ramesh Babu
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Xlsxlibhb_ver2
Posted: Thu Oct 05, 2023 10:07 AM
While working with this library I am learning a lot while enjoying it.
Till now I have used only a very few features of the library and there is a lot more to explore.

Exporting CUSTOMER.DBF to CUSTOMER.XLSX


Exporting WWONDERS.DBF to WWONDERS.XLSX with IMAGES in the Memo Fields:
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Xlsxlibhb_ver2
Posted: Thu Oct 05, 2023 10:12 AM
Main program:
Code (fw): Select all Collapse
#include "fivewin.ch"

REQUEST DBFCDX

function wwonders()

   local cXlsx

   USE C:\FWH\SAMPLES\WWONDERS VIA "DBFCDX"
   cXlsx    := DBF2XLSX()
   ShellExecute( 0, "Open", cXlsx )

return nil
Exporting to xlsx is easy using this new function:
Code (fw): Select all Collapse
function DBF2XLSX( cFileXlsx )

   local oBook, oSheet
   local aStruct, bRow, nRow

   if Empty( Alias() )
      return nil
   endif

   DEFAULT cFileXlsx := cFileSetExt( DbInfo( DBI_FULLPATH ), "xlsx" )

   oBook    := TWorkBook():New( cFileXlsx )
   if oBook == nil
      ? "Can not create " + cFileXlsx
      return nil
   endif

   GO TOP
   aStruct  := DBSTRUCT()
   AEval( aStruct, { |a,i| If( a[ 2 ] == "M" .and. IsBinaryData( FieldGet( i ) ), a[ 2 ] := "m", nil ) } )
   bRow     := "{||{" + FW_ArrayAsList( ArrTranspose( aStruct )[ 1 ] ) + "}}"
   bRow     := &( bRow )

   oSheet   := oBook:AddSheet()
   nRow  := oSheet:SetStruct( aStruct )
   DBEVAL( { || nRow := oSheet:SayRow( nRow, Eval( bRow ) ) } )

   oBook:Close()

   ? "Exported to " + cFileXlsx

return cFileXlsx
In turn this function uses a small class I started making now. Right now, this class uses minimal features of this library
Regards



G. N. Rao.

Hyderabad, India
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Xlsxlibhb_ver2
Posted: Thu Oct 05, 2023 10:24 AM
Dear Ramesh,

Please add this code to the bottom of your main PRG and please let me know if it solves that unresolved external for you using xHarbour

many thanks for your feedback
Code (fw): Select all Collapse
#pragma BEGINDUMP

#include <hbapi.h>

#ifdef __XHARBOUR__

#include <stdarg.h>

void * hb_parvptr( int iParam, ... )
{
    void * result;
    va_list args;
    va_start( args, iParam );
    result = hb_parptr( iParam, args );
    va_end( args );

    return result;
}

#endif

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 654
Joined: Fri Oct 21, 2005 05:54 AM
Re: Xlsxlibhb_ver2
Posted: Fri Oct 06, 2023 01:36 AM
Dear Antonio,

Wonderful. It worked !!.

That is Antonio and THE MASTER.

As told by Mr.Nageswara Rao
While working with this library I am learning a lot while enjoying it.
Till now I have used only a very few features of the library and there is a lot more to explore.
There is a lot to learn from this Library.

-Ramesh Babu P
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Xlsxlibhb_ver2
Posted: Sun Oct 15, 2023 03:11 PM
FWH will include an interface class to this library
If this library is downloaded and linked with FWH we can use the class to use the lib with much ease.

Fonts and Images


Code (fw): Select all Collapse
#include "fivewin.ch"

REQUEST FWXLSXLIB

function Main()

   local cFile, oXlsx, oFormat

   cFile    := "testfont.xlsx"
   oXlsx    := XlsxLibObj( cFile )

   WITH OBJECT oXlsx

      WITH OBJECT( oFormat := :Format() )
         :SetFont( "IMPACT", 50, NARGB(0,CLR_HRED), "BOLD" )
         :SetColor( nil, NARGB( CLR_YELLOW ) )
         :FontRotate( 90 )
         :SetAlign( 2, 10 )
      END

      :MergeRange( 0,0,15,0, "MERGED", oFormat )
      :SetColumnSize( 1, 1, 40 )

      WITH OBJECT( oFormat := :Format() )
         :SetFont( "Times New Roman", 20, 0, "BOLD" )
      END

      :Say( "B1", "Times New Roman", oFormat )
      :Say( 1, 1, "äöüÄÖÜ",  :Format():SetFont( "tahoma", 16, 0xff0000 ) )
      :B3    := "THIRD ROW"
      WITH OBJECT ( oFormat := :Format() )
         :NumFormat( 4 )
         :SetFont( "Lucida Console", 14, 0x0000ff, "bold" )
      END
      :Say( 4, 1, 3456789.2, oFormat )

      // Image
      :aImageSize( 1000, 700 )
      :B17 := MEMOREAD( "\fwh\bitmaps\sea.bmp" )

      :Close()

   END

   ShellExecute( 0, "Open", cFile )

return nil
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Xlsxlibhb_ver2
Posted: Thu Oct 19, 2023 04:04 AM
This example demonstrates:

1. Image Brush
2. Sheet name customized
3. Group Headers
4. Freeze Header Rows
5. Hide Zero values
6. Footer row with aggregage formulae



Exporting tables is very simple
Code (fw): Select all Collapse
#include "fivewin.ch"

function Main()

   local oXlsx, aStruct, aGroup, aFooter, bRow, nRow

   // Prepare DBF
   USE CUSTOMER
   aStruct  := DbStruct()
   aGroup   := { { 2, 3, "NAME" }, { 4,7,"ADDRESS" }, { 9, 10, "PERSONAL" } }
   aFooter  := { ,"TOTALS",,,,,,,,"=AVERAGE(range)","=SUM(range)", }
   bRow     := "{||{" + FW_ArrayAsList( ArrTranspose( aStruct )[ 1 ] ) + "}}"
   bRow     := &( bRow )

   // Write to xlsx
   if ( oXlsx := XlsxLibObj( "customer.xlsx", "customer" ) ) != nil
      WITH OBJECT oXlsx
         nRow  := :SetStruct( aStruct,,aGroup )
         DBEVAL( { || nRow := :SayRow( nRow, Eval( bRow ) ) } )
         :SetFooter( aFooter )
         :SetBackGround( "\fwh\bitmaps\backgrnd\paper2.bmp" )
         :HideZero()
         //
         :Close()
         ? "Created customer.xlsx"
         ShellExecute( 0, "Open", "customer.xlsx" )
      END
   else
      ? "Can not create xlsx"
   endif

return nil
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Xlsxlibhb_ver2
Posted: Thu Oct 19, 2023 05:43 AM
One line code for no frills export of DBF or other tables
Code (fw): Select all Collapse
oXlsx:CreateFrom() // uses current alias
for other tables:
Code (fw): Select all Collapse
oXlsx:CreateFrom( oRs )
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Xlsxlibhb_ver2
Posted: Thu Oct 19, 2023 06:00 AM
Exporting multiple tables to different Sheets/Tabs of one single ExcelBook:
Code (fw): Select all Collapse
#include "fivewin.ch"

REQUEST DBFCDX

function Main()

   local oXlsx

   USE STATES SHARED NEW
   USE WWONDERS SHARED NEW VIA "DBFCDX"
   USE CUSTOMER SHARED NEW

   if ( oXlsx := XlsxLibObj( "mydbfs.xlsx", Alias() ) ) != nil
      WITH OBJECT oXlsx
         CUSTOMER->( :CreateFrom() )
         STATES->(   :AddSheet( Alias() ):CreateFrom() )
         WWONDERS->( :AddSheet( Alias() ):CreateFrom() )
         :Close()
      END
      ? "Created mydbfs.xlsx"
      ShellExecute( 0, "Open", "mydbfs.xlsx" )
   else
      ? "can not create xlsx"
   endif

   CLOSE DATA

return nil
Regards



G. N. Rao.

Hyderabad, India
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Xlsxlibhb_ver2
Posted: Sat Nov 04, 2023 12:00 PM
Hi Mr. Rao,

To use this library in fwh 23.10.

I have add this line to my main application.
Code (fw): Select all Collapse
REQUEST XLXLIB
I have add my this line to my makefile.
Code (fw): Select all Collapse
  echo $(FWDIR)\lib\xlsxlibhbmsvc.lib >> msvc.tmp
I have compiled my application. There is an error like this.
Code (fw): Select all Collapse
Master.obj : error LNK2001: unresolved external symbol _HB_FUN_XLXLIB
What else do I need to do?
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Xlsxlibhb_ver2
Posted: Sat Nov 04, 2023 12:58 PM
Please use

REQUEST XLSXLIB

Sorry for the spelling mistake in the whatsnew.txt
Regards



G. N. Rao.

Hyderabad, India