Alaska Software Inc. - Generate Excel (XLSX) and Word (DOCX)
Username: Password:
AuthorTopic: Generate Excel (XLSX) and Word (DOCX)
Salvatore Megna Generate Excel (XLSX) and Word (DOCX)
on Thu, 13 Feb 2020 11:18:21 +0100
Hi,
what do you use for generate files xlsx or docx? Some third part library?

thanks boys
Jonathan LeemingRe: Generate Excel (XLSX) and Word (DOCX)
on Thu, 13 Feb 2020 08:49:55 -0700
On 2/13/2020 3:18 AM, Salvatore Megna wrote:
> Hi,
> what do you use for generate files xlsx or docx? Some third part library?
> 
> thanks boys
Hi,

I use Xbase++ with ActiveX connecting to Excel or Word.  As long as 
Excel / Word are installed on the workstation you can use this method.

The create an Excel file the basic steps are...

oXls := CreateObject("Excel.Application")   Open Excel
oBook  := oXls:workbooks:Add()              Open new blank Workbook
oSheet := oBook:ActiveSheet                 Select Sheet1

oSheet:Cells(1,3):Value := "Some Value"     Write "Some Value" to C3

nRow := 5
nCol := 2

* The following would set B5 to 12
oSheet:Cells((nRow),(nCol)):Value := 12

aData := {{0,1,1},;
           {2,5,8},;
           {13,21,34}}

*The following would set the 9 cells to the values in aData
oRange := oSheet:Range("A8","C10")
oRange:Value := aData

*or if you don't need the same range for anything else...

oSheet:Range("A8","C10"):Value := aData

*To Save the spreadsheet file

oBook:SaveAs("C:\SomePath\SomeFile.xlsx")

oBook := oSheet := NIL

oXls:quit()        Quit & Exit from Excel

oXls:destroy()    destroy excel object


Using the ActiveX you can do most anything that you can manually from 
within Excel.  If I'm stuck on how to do something programmatically I 
usually open excel and record a macro to do what I need and then inspect 
the VB code and convert it to Xbase++.  Not that when updating a 
spreadsheet the fewer AxtiveX call you make the faster it runs so rather 
than updating individual cells update ranges of cells from an array of 
values.  (the aData example above)

There is an ActiveX section within this newsgroup.

Alaska has some samples too...

Documents\Xbase++\source\samples\activex\msexcel

This link helps me with working with the Excel object...

https://docs.microsoft.com/en-us/office/vba/api/overview/Excel/object-model

Excel has many constants and using the Xbase++ tool these can be put 
into a header file...

Tlb2Ch.exe "Excel.Application" > excel.ch

Using the oWord := CreateObject("Word.Application") you could similarly 
work with Word documents.

There are 3rd party libraries that can create Excel spreadsheets without 
having to have Excel installed but I have yet had a need to use them.

Hope this helps... Jonathan


jonathan.leeming@familycentre.org
Edmonton, Alberta, Canada
Jim LeeRe: Generate Excel (XLSX) and Word (DOCX)
on Fri, 14 Feb 2020 07:29:45 +0100
hi

you can try hbxlsxwriter
https://github.com/riztan/hbxlsxwriter

it is for harbour and i have not test it yet with Xbase++

---

there is a old Solution from Phil Ide to use HTML which Excel will open.
have to search for it
Jorge L. BorlandoRe: Generate Excel (XLSX) and Word (DOCX)
on Tue, 25 Feb 2020 12:38:00 -0300
hello I have made a library that generates excel xml files and if necessary 
you can generate an xlsx output but you need to have excel installed,
each cell supports almost all the formats allowed in excel, if you are 
interested we see it privately jlborlando@gmail.com

regards

"Salvatore Megna"  escribió en el mensaje de 
noticias:38a21ae7$3f3dfa10$12b120@news.alaska-software.com...

Hi,
what do you use for generate files xlsx or docx? Some third part library?

thanks boys