// C:\FWH..\SAMPLES\TESTDRXL.PRG - Master Nages,
#include "FiveWin.ch"
#include "DrXlsx.ch"
#ifdef __XHARBOUR__
#xtranslate hb_DateTime( [<x,...>] ) => DateTime( <x> )
#endif
REQUEST DBFCDX
FUNCTION Main()
SET DATE FORMAT "YYYY-MM-DD"
HelloSayX()
RETURN NIL
// Mister Nages:
#ifdef __XHARBOUR__
FUNCTION HB_HEVAL(h) ; RETURN HEVAL(h)
FUNCTION HB_TTOS(t) ; RETURN TTOS(t)
FUNCTION HasTimePart( tDate )
static lBug
if lBug == nil
lBug := HB_IsDateTime( Date() )
endif
if lBug
RETURN ( tDate - Int( tDate ) ) > 0
endif
RETURN HB_IsDateTime( tDate )
#endif
FUNCTION HelloSayX()
LOCAL oXlsx := TDrXlsx():New()
LOCAL dDate := Date()
LOCAL nValue := 2023
LOCAL nValue2 := 19450815
LOCAL nUSD := 3000
IF oXlsx:CreateFile( "testsayx.xlsx" ) <> 0
?" The file is already open."
RETURN NIL
ENDIF
oXlsx:SetColumnSize( 0, 0, 20 )
@ 0, 0 SAYX "Hello World!" OF oXlsx
@ 1, 0 SAYX "CENTER Text" OF oXlsx ALIGN DRXLSX_ALIGN_CENTER
@ 2, 0 SAYX "RIGHT Text" OF oXlsx ALIGN DRXLSX_ALIGN_RIGHT
@ 3, 0 SAYX dDate OF oXlsx ALIGN DRXLSX_ALIGN_CENTER
@ 4, 0 SAYX nValue OF oXlsx PICTUREX "#,###"
@ 5, 0 SAYX nValue2 OF oXlsx PICTUREX "#,###"
@ 6, 0 SAYX nUSD OF oXlsx PICTUREX "$#,###"
oXlsx:Close()
RETURN NIL
FUNCTION Hello()
LOCAL oXlsx := TDrXlsx():New()
oXlsx:CreateFile( "test.xlsx" )
oXlsx:WriteString( 0, 0, "안녕하세요" )
oXlsx:WriteString( 1, 0, "Hello World!" )
oXlsx:Close()
RETURN NIL
FUNCTION Hello2()
LOCAL oXlsx := TDrXlsx():New()
oXlsx:CreateFile( "testlogic.xlsx" )
oXlsx:SetColumnSize( 0, 0, 12 )
oXlsx:WriteString( 0, 0, "안녕하세요" )
oXlsx:WriteString( 1, 0, "Hello World!" )
oXlsx:WriteLogical( 2, 0, .T. )
oXlsx:WriteDate( 3, 0, Date(), DRXLSX_ALIGN_CENTER, "dd-mm-yyyy" )
oXlsx:Close()
RETURN NIL
FUNCTION Hello3()
LOCAL oXlsx := TDrXlsx():New()
oXlsx:CreateFile( "align.xlsx" )
oXlsx:SetColumnSize( 0, 0, 12 )
oXlsx:WriteString( 0, 0, "안녕하세요", DRXLSX_ALIGN_CENTER )
oXlsx:WriteString( 1, 0, "Hello World!" )
oXlsx:WriteLogical( 2, 0, .T. )
oXlsx:WriteDate( 3, 0, Date(),, "dd-mm-yyyy" )
oXlsx:Close()
RETURN NIL
FUNCTION Hello4()
LOCAL oXlsx := TDrXlsx():New()
LOCAL dtTest := hb_DateTime( 2023, 8, 23, 20, 04, 30 )
oXlsx:CreateFile( "merge.xlsx" )
oXlsx:SetColumnSize( 0, 0, 30 )
oXlsx:SetColumnSize( 0, 1, 30 )
oXlsx:MergeRange( 0, 0, 0, 1, "Title", DRXLSX_ALIGN_CENTER )
oXlsx:WriteString( 1, 0, "Product 1" )
oXlsx:WriteDate( 1, 1, Date(), DRXLSX_ALIGN_CENTER, "yyyy-mm-dd" )
oXlsx:WriteString( 2, 0, "Is Stock" )
oXlsx:WriteLogical( 2, 1, .T., DRXLSX_ALIGN_CENTER )
oXlsx:WriteString( 3, 0, "Stock Price" )
oXlsx:WriteNumber( 3, 1, 9999,, "$#,##0.00" )
oXlsx:WriteString( 4, 0, "Timestamp" )
oXlsx:WriteDateTime( 4, 1, dtTest,, "yyyy-mm-dd hh:mm:dd" )
oXlsx:Close()
RETURN NIL
FUNCTION Saytest()
LOCAL oXlsx := TDrXlsx():New()
LOCAL dtTest := hb_DateTime( 2023, 8, 23, 20, 04, 30 )
oXlsx:CreateFile( "say.xlsx" )
oXlsx:SetColumnSize( 0, 0, 30 )
oXlsx:SetColumnSize( 0, 1, 30 )
oXlsx:Say( 0, 0, "Valtype" )
oXlsx:Say( 0, 1, "Value" )
oXlsx:Say( 1, 0, "Character" )
oXlsx:Say( 2, 0, "Numeric" )
oXlsx:Say( 3, 0, "Date" )
oXlsx:Say( 4, 0, "Logic" )
oXlsx:Say( 5, 0, "Datetime format" )
oXlsx:Say( 6, 0, "Datetime" )
oXlsx:Say( 1, 1, "Hello" )
oXlsx:Say( 2, 1, 1234.0000,, "#,##0.000" )
oXlsx:Say( 3, 1, Date() )
oXlsx:Say( 4, 1, .T. )
oXlsx:Say( 5, 1, dtTest,, "yyyy-mm-dd hh:mm:ss" )
oXlsx:Say( 6, 1, dtTest )
oXlsx:Close()
RETURN NIL
FUNCTION Hello5()
LOCAL oXlsx := TDrXlsx():New()
LOCAL dtTest := hb_DateTime( 2023, 8, 23, 20, 04, 30 )
LOCAL oFormat
IF oXlsx:CreateFile( "merge2.xlsx" ) <> 0
?"The file is already open."
RETURN NIL
ENDIF
/*
oFormat := TDrXlsxFormat():New( oXlsx )
oFormat:AddAlign( DRXLSX_ALIGN_CENTER )
oFormat:AddAlign( DRXLSX_ALIGN_VERTICAL_CENTER )
*/
DEFINE XLSXFORMAT oFormat OF oXlsx
ADD XLSXALIGN DRXLSX_ALIGN_CENTER TO oFormat
ADD XLSXALIGN DRXLSX_ALIGN_VERTICAL_CENTER TO oFormat
oXlsx:SetColumnSize( 0, 0, 30 )
oXlsx:SetColumnSize( 0, 1, 30 )
oXlsx:MergeRange( 0, 0, 1, 1, "Title", oFormat )
oXlsx:WriteString( 2, 0, "Product 1" )
oXlsx:WriteDate( 2, 1, Date(), DRXLSX_ALIGN_CENTER, "yyyy-mm-dd" )
oXlsx:WriteString( 3, 0, "Is Stock" )
oXlsx:WriteLogical( 3, 1, .T., DRXLSX_ALIGN_CENTER )
oXlsx:WriteString( 4, 0, "Stock Price" )
oXlsx:WriteNumber( 4, 1, 9999,, "$#,##0.00" )
oXlsx:WriteString( 5, 0, "Timestamp" )
oXlsx:WriteDateTime( 5, 1, dtTest,, "yyyy-mm-dd hh:mm:dd" )
oXlsx:WriteString( 6, 0, "Timestamp2" )
oXlsx:WriteDateTime( 6, 1, dtTest )
oXlsx:Close()
RETURN NIL
FUNCTION HelloFormula()
LOCAL oXlsx := TDrXlsx():New()
LOCAL dtTest := hb_DateTime()
LOCAL oFormat
IF oXlsx:CreateFile( "formula_format.xlsx" ) <> 0
?"The file is already open."
ENDIF
DEFINE XLSXFORMAT oFormat OF oXlsx
ADD XLSX ALIGN DRXLSX_ALIGN_CENTER TO oFormat
ADD XLSX NUMBER_FORMAT "yyyy-mm-dd hh.mm.ss.000" TO oFormat
ADD XLSX BOLD TO oFormat
ADD XLSX ITALIC TO oFormat
ADD XLSX BOTTOM STYLE DRXLSX_BORDER_DOUBLE TO oFormat
oXlsx:SetColumnSize( 0, 1, 30 )
oXlsx:WriteString( 0, 0, "Timestamp" )
oXlsx:WriteDateTime( 0, 1, dtTest )
oXlsx:WriteString( 1, 0, "Timestamp + 30" )
oXlsx:WriteFormula( 1, 1, "=B1+30", oFormat )
oXlsx:Close()
RETURN NIL
FUNCTION MakeDbf2Xls()
rddSetDefault( "DBFCDX" )
USE INVOICES NEW
Dr_Dbf2Xlsx( "invoices.xlsx", .T. )
RETURN NIL
// FIN / END