Can harbour create Excel spreadsheets?

956 views
Skip to first unread message

smu johnson

unread,
Oct 17, 2011, 1:04:28 PM10/17/11
to harbou...@googlegroups.com
Hi,

My question:  is it possible to create Excel files in Harbour, by that I mean, somewhat portable ones, and not the new XML ones made by the latest version of MS Office?

I was looking into compiling the C++ xlslib and writing some .c Harbour extensions to use its C API, but perhaps I'm going down the wrong course.

contrib\hbwin\tests\testole.prg seems to hint that it might be possible already.  It looks like it uses some sort of MS API called OLE to do minor tests.  Perhaps it is possible via hbwin to build a simple spreadsheet?

Thanks in advance.

--
smu johnson <smujo...@gmail.com>

smu johnson

unread,
Oct 17, 2011, 2:33:43 PM10/17/11
to Harbour Developers
I was playing around with this test, it works great. However, it
looks as though one must have MS Excel installed on the running system
for it to work.

It might have to bust out xlslib regardless, but I was nonetheless
impressed by the testole.prg file.
> smu johnson <smujohn...@gmail.com>

Viktor Szakáts

unread,
Oct 17, 2011, 3:10:00 PM10/17/11
to harbou...@googlegroups.com
> I was playing around with this test, it works great.  However, it 
> looks as though one must have MS Excel installed on the running system 
> for it to work. 

By the nature of OLE, yes, it's non-portable, Windows-specific 
solution and always requires the apps (Excel in this case) to be 
purchased and installed. Staying with OLE, you can lighten your 
requirements by adding support for LibreOffice.

Viktor

smu johnson

unread,
Oct 17, 2011, 4:44:05 PM10/17/11
to Harbour Developers
Good to see you again! Thanks for the advice.

In case anyone else is reading this and is also curious, I've finally
gotten libxls to compile. It needed a detection for __MINGW32__ which
was added into the main project yesterday, and it doesn't seem to
compile on TDM-GCC.

I did however get it to compile from MSYS's MinGW (???) even though I
used the same gcc version: 4.5.2. Any thoughts on that?

Anyways, since I'll be using the C Harbour API to get this to work,
the author fortunately had the foresight to include a .c file as a
test example, even though the lib itself is coded in C++. I ran it
and it seems to work thus far.

For more info, see these files after it compiled:

xlslib\targets\test\mainC.c
xlslib\targets\test\testC.exe

hua

unread,
Oct 17, 2011, 10:09:44 PM10/17/11
to Harbour Developers
On Oct 18, 4:44 am, smu johnson <smujohn...@gmail.com> wrote:
> In case anyone else is reading this and is also curious, I've finally
> gotten libxls to compile.  It needed a detection for __MINGW32__ which
> was added into the main project yesterday, and it doesn't seem to
> compile on TDM-GCC.
<snip>

Keep posting, I'm interested :) Have been looking on how to create
Excel file without having to have MS Office installed

TIA
--
hua

Simon

unread,
Oct 26, 2011, 8:41:42 PM10/26/11
to Harbour Developers
Hi

Have you thought of using this method?

http://www.foxpert.com/docs/excel.en.htm

Simon

Julius Bartal

unread,
Oct 27, 2011, 5:20:35 AM10/27/11
to harbou...@googlegroups.com

Hi 

for example without OLE : 

MiniGui 
TsBrowse
METHOD Excel2( cFile, lActivate, hProgress, cTitle, lSave ) CLASS TSBrowse
Function BiffRec( nOpCode, uData, nRow, nCol, lBorder, nAlign, nPic, nFont )

Gyula

F.C.Trautwein

unread,
Oct 27, 2011, 7:30:13 AM10/27/11
to harbou...@googlegroups.com
Hi

I've been using this:

www.adlerinformatica.com.br/download/xhb/excelwriterxml.zip

It was converted from Robert F Greer, PHP original version
http://sourceforge.net/projects/excelwriterxml/

Fausto

Gmail

unread,
Oct 27, 2011, 8:42:47 AM10/27/11
to harbou...@googlegroups.com
Hello Fausto,

Did you try it with Harbour 3.0 (or newer)?
I am trying it but it gives me errors.
I tried: hbmk2 teste ExcelWriterXML ExcelWriterXML_Sheet
ExcelWriterXML_Style -lxhb
Any hint, please?

Qatan

F.C.Trautwein

unread,
Oct 27, 2011, 9:49:07 AM10/27/11
to harbou...@googlegroups.com
Hello,

Sorry, it was used only with xharbour, but I changed a little.

Please download again from:

www.adlerinformatica.com.br/download/xhb/excelwriterxml.zip

I tried this new version with harbour and it looks ok.

Fausto

Gmail

unread,
Oct 27, 2011, 10:18:53 AM10/27/11
to harbou...@googlegroups.com
Hello Fausto,

Now it works OK.
Seems very good. Maybe the developers could add it to Contrib (or
Examples) if they belive it is a good idea.
Thank you!

Qatan

----- Original Message -----
From: "F.C.Trautwein" <ftw...@yahoo.com.br>
To: <harbou...@googlegroups.com>
Sent: Thursday, October 27, 2011 11:49
Subject: Re: [harbour] Re: Can harbour create Excel spreadsheets?

Viktor Szakáts

unread,
Oct 27, 2011, 2:26:18 PM10/27/11
to harbou...@googlegroups.com
Even to include in examples it must be cleaned and formatted, 
plus std make files created, unnecessary files deleted, 8.3 filenames 
added, lots of cycles. For contrib it's even more work. I hope someone 
will do it, but won't be crossing my fingers.

To spread the load better, maybe it's just simply enough if someone 
is hosting this file on an existing website.

Viktor

Angel Pais

unread,
Oct 27, 2011, 3:20:47 PM10/27/11
to harbou...@googlegroups.com
is there a doc about that ?

Regards
Angel

Viktor Szakáts

unread,
Oct 27, 2011, 3:48:05 PM10/27/11
to harbou...@googlegroups.com
About what to do with raw code to include in SVN?

There are tons of examples which I think is the best 
for giving direction.

There are _some_ docs, but nobody reads them, and 
they are hugely time-consuming to create them, so 
they are not maintained or extended. I don't really believe 
in putting every detail in writing would help, but rather in 
showing the example. If someone is really interested, the 
best read is this list for longer period of time, commit logs 
which include diffs, past changes, or simply to inspect 
how a contrib looks like.

I hope that was question anyway :)

Viktor

Pritpal Bedi

unread,
Oct 27, 2011, 4:35:33 PM10/27/11
to Harbour Developers
Viktor


> I hope that was question anyway :)

Harbour standard port of this code will be ready
in a day. Let me know where to commit.

DISCLAIMER: I did not test this code. My
offering only assumes that this will be useful for
many in many respects.

Pritpal Bedi

Viktor Szakáts

unread,
Oct 27, 2011, 4:53:55 PM10/27/11
to harbou...@googlegroups.com
Hi Pritpal,

Please put it to examples at first, to have a clearer 
picture and allow more testing on it.

F.e.:
   /examples/hbxlswrt/

Viktor

Gmail

unread,
Oct 27, 2011, 8:27:42 PM10/27/11
to harbou...@googlegroups.com
Hello Viktor,
 
    I can at least make it available to download until the main job is done: http://www.dbtron.com/harbour/excelwriterxml/excelwriterxml.zip
   
Qatan
----- Original Message -----
Sent: Thursday, October 27, 2011 16:26
Subject: Re: [harbour] Re: Can harbour create Excel spreadsheets?

Angel Pais

unread,
Oct 28, 2011, 12:38:42 PM10/28/11
to harbou...@googlegroups.com

So, how can you enforce a non-written law ?
I see a big paradox in there.
To answer this question has vital importance to the continuity of this
project.
How can it go form a one-man-ruled open source project to a community
based one ?
How can we attract the next generation of contributors ?
Xbase languaje contributors are needed once the c level layer is completed.
Ussualy they are far less disciplinated than c ones, and they may come
from very different backgrounds.
There is a need to establish a well defined check list for new
contributions.
In fact we need 2 lists: one for .c files and another for .prg files.
We also need to establish Who and When promotes a contribution from
examples to contrib or if they are simply documentary ones.

Regards
Angel

Viktor Szakáts

unread,
Oct 28, 2011, 1:57:20 PM10/28/11
to harbou...@googlegroups.com
> So, how can you enforce a non-written law ?
> I see a big paradox in there.

You can try creating a doc which describes the practical 
rules we follow. For me it's too much work and I don't 
believe we would be an inch closer to any solution. I've 
also yet to see a project which has hefty rulebooks.

What I did in the past (and to this day if I happen to 
contribute), is to convey a strictly consistent way of 
doing things, so interested people can easily follow it. 
That's why I used to waste so much time on consistent 
formatting for example, and that's why I give details on 
my own modifications of submitted patches, and that's 
why I describe everything in ChangeLog precisely.

It worked for a few contributors who gave their attention 
and dedication and I'm very happy to see it when it happens.

> To answer this question has vital importance to the continuity of this 
> project.

I'm not sure.

> How can it go form a one-man-ruled open source project to a community 
> based one ?

One-man-ruled?

I think the classic way of open-source communities 
is to watch existing contributors, react to feedback, try 
to follow the flow as much as possible. Follow common-sense, 
add your time and attention, also to details.

> How can we attract the next generation of contributors ?

Since giving up quality goals and letting crap flow in 
doesn't seem an option to me personally, I don't know.

Maybe to let development flourish outside Harbour SVN?

Nobody is forced to follow any rules around here and can 
do everything on their own. Granted, quality won't be 
necessarily that much strict or verified and peer-reviewed, 
but that's part of the business.

> Xbase languaje contributors are needed once the c level layer is completed.
> Ussualy they are far less disciplinated than c ones, and they may come 
> from very different backgrounds.

True.

> There is a need to establish a well defined check list for new 
> contributions.
> In fact we need 2 lists: one for .c files and another for .prg files.

I disagree for several reasons. What about making a 3rd list 
for make-related files then? :) Even the devel vs users list 
confuses a great deal of people. Or how about submitting 
a patch which has both .c and .prg? (just to give two obvious 
reasons)

> We also need to establish Who and When promotes a contribution from 
> examples to contrib or if they are simply documentary ones.

Good luck describing such conditions precise enough 
and practical enough at the same time.

IMO this is impossible and will always need human 
judgment and decision of someone who has enough 
knowledge, experience and holds the trust of the community.

Viktor

Gmail

unread,
Oct 28, 2011, 3:01:20 PM10/28/11
to harbou...@googlegroups.com
Fausto,

Thanks for sharing that nice collection of code with us.

Qatan

----- Original Message -----
From: "F.C.Trautwein" <ftw...@yahoo.com.br>
To: <harbou...@googlegroups.com>
Sent: Thursday, October 27, 2011 11:49
Subject: Re: [harbour] Re: Can harbour create Excel spreadsheets?

F.C.Trautwein

unread,
Oct 28, 2011, 3:51:24 PM10/28/11
to harbou...@googlegroups.com
Qatan,

My pleasure.

Fausto

Pritpal Bedi

unread,
Oct 28, 2011, 7:12:31 PM10/28/11
to Harbour Developers

> www.adlerinformatica.com.br/download/xhb/excelwriterxml.zip

Thanks Fausto for this tool.

The logical next question:
Do you have anything which reads such generated
.xml and could change field values and could
write it back ?

Goal is to have developer(application)-end user(client)
interaction feasible. Can be a source of a rich document
generator which is defined by the end-user and filled-up
by the application.

Pritpal Bedi

F.C.Trautwein

unread,
Oct 28, 2011, 10:26:08 PM10/28/11
to harbou...@googlegroups.com
Pritpal,

Unfortunately I don't have anything that reads the .xml.

I use excelwriterxml in a linux application, it generates reports in xml
and users open them with excel, just this.

Good: You don't need excel to create the files. Faster than OLE. Free.
Simple.

Bad: Bigger than xls. Openoffice (Libreoffice) doesn't open the xml
sometimes (big ones).

Fausto

Message has been deleted

fprijatelj

unread,
Oct 29, 2011, 3:20:47 AM10/29/11
to Harbour Developers
Hi

Just rename file (or create it with .xls extension).
Than any modern spreadsheet program (LibreOffice, OpenOffice, Excell)
opens it.

Regards
Franček

Viktor Szakáts

unread,
Oct 29, 2011, 5:00:55 AM10/29/11
to harbou...@googlegroups.com
> Than any modern spreadsheet program (LibreOffice, OpenOffice, Excell) 

Unfortunately this is not true. I never got f.e. LibreOffice/OpenOffice 
to open these files in the last few years, not even small ones. Well, 
that's not true, it opens them as HTML documents.

Viktor

Massimo Belgrano

unread,
Oct 29, 2011, 5:01:20 AM10/29/11
to harbou...@googlegroups.com
+1

2011/10/28 Angel Pais <amig...@adinet.com.uy>


So, how can you enforce a non-written law ?
I see a big paradox in there.
To answer this question has vital importance to the continuity of this project.
How can it go form a one-man-ruled open source project to a community based one ?
How can we attract the next generation of contributors ?
Xbase languaje contributors are needed once the c level layer is completed.
Ussualy they are far less disciplinated than c ones, and they may come from very different backgrounds.
There is a need to establish a well defined check list for new contributions.
In fact we need 2 lists: one for .c files and another for .prg files.
We also need to establish Who and When promotes a contribution from examples to contrib or if they are simply documentary ones.

Regards
Angel



--

fprijatelj

unread,
Oct 29, 2011, 5:43:26 AM10/29/11
to Harbour Developers
Hi

Maybe I wasn't clear enough ;)

Rename file !!!!
Change .xml extension to .xls , and then open file with LibreOffice.
Or just create file with .xls extension.
I tested it and IT WORKS

Franček
Message has been deleted

Bacco

unread,
Oct 29, 2011, 5:55:44 AM10/29/11
to harbou...@googlegroups.com
This is wrong.

I also can rename any .bmp to .jpg and it stills open in my graphic
editor, but it doesn't make it a JPEG file, just an bmp with wrong
extension. You can't expect people will choose the same tools as you,
neither guess why it's not opening in the tools of their choice.


Regards,
Bacco

On Sat, Oct 29, 2011 at 07:48, fprijatelj <francek....@siol.net> wrote:
> Hi
>
> Wasn't I clear enough ?
>
> Change .XML extension to .XLS !!!!
> Then open it with LibreOffice.
> It works (I tested it many times).
> Beter solution is to generate file with .XLS extension.


>
> Franček
>
>
> On Oct 29, 11:00 am, Viktor Szakáts <harbour...@syenar.hu> wrote:

Bacco

unread,
Oct 29, 2011, 5:58:50 AM10/29/11
to harbou...@googlegroups.com
PS: Those who want to use xml in excel files should learn the XLSX
file structure, that is based on xml.

fprijatelj

unread,
Oct 29, 2011, 8:38:04 AM10/29/11
to Harbour Developers
Hi

That's not the same.
Renaming .bmp to .jpg would be stupid.

But in this article :

( http://en.wikipedia.org/wiki/Microsoft_Excel#File_formats)

The XML Spreadsheet format introduced in Excel 2002[52] is a simple,
XML based format missing some more advanced features like storage of
VBA macros. Though the intended file extension for this format
is .xml, the program also correctly handles XML files with .xls
extension. !!!

Excel 2002 format (XMLSS) is different from newer Office Open XML
(OOXML) format with .xlsx extension.

Franček

Bacco

unread,
Oct 29, 2011, 8:44:59 AM10/29/11
to harbou...@googlegroups.com
Quoted from your link, ** emphasis added.

"The XML Spreadsheet format introduced in Excel 2002[52] is a simple,
XML based format missing some more advanced features like storage of

VBA macros. ** Though the intended file extension for this format is


.xml, the program also correctly handles XML files with .xls extension

**"

Intended extension -> XML
The program (excel itself) also handles xls extension.

Similarly, my graphic editor handles correctly a .bmp renamed to .jpg,
About your comment about renaming, I think you somewhat got the same
I'm thinking about this whole thing.


Regards,
Bacco

ToninhoFWi

unread,
Oct 29, 2011, 11:47:52 AM10/29/11
to harbou...@googlegroups.com
Hi.

Well, in my windows 7 this type of xml files open in excel 2010 without
problem. But I can't open it in Sony Tablet S with android 3.2, same
renaming xml to xls file, but native xls file open in 'Documents To Go"...

Regards,

Toninho.

Reply all
Reply to author
Forward
0 new messages