Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-09

read cells contents from .xls file

12 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

John Lee

File produced by excel 2003. Can anyone tell me the basic ideas, formats, pitfalls - I'd just like to write a short routine & don't want to fight with the complexities of the lazarus based stuff. Prepared to experiment...

TIA John

Felipe Monteiro de Carvalho
to John Lee

You mean like this library does? http://wiki.freepascal.org/FPSpreadsheet

Felipe Monteiro de Carvalho

John Lee wrote 11 lines
File produced by excel 2003. Can anyone tell me the basic ideas, formats, pitfalls - I'd just like to write a short routine & don't want to fight with the complexities of the lazarus based stuff. Prepared to experiment... TIA John _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Felipe Monteiro de Carvalho
John Lee
to Felipe Monteiro de Carvalho

Thanks - that looks excellent, but the 'uses' list for this, for non lazarus users, has, I guess, lots of things in it.

The problem is also that I'm trying to implement this hack in an old version of pascal, v2.2.2 for which I only have the compiler & basic rtl stuff - that's why I'd just like some info for a quick hack eg some bullets or some idea what I need to do eg to read the no or string in eg cell x23 of sheet jim in fred.xls.

John

On 30 September 2013 16:38, Felipe Monteiro de Carvalho <

Show quoted text 28 lines
wrote: You mean like this library does? http://wiki.freepascal.org/FPSpreadsheet Felipe Monteiro de Carvalho On Mon, Sep 30, 2013 at 5:33 PM, John Lee wrote: > File produced by excel 2003. Can anyone tell me the basic ideas, formats, > pitfalls - I'd just like to write a short routine & don't want to fight with > the complexities of the lazarus based stuff. Prepared to experiment... > > TIA John > > > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- Felipe Monteiro de Carvalho _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Felipe Monteiro de Carvalho
to John Lee

The source code of fpspreadsheet is open ... just copy/paste/modifiy it for your needs:

https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/components/fpspreadsheet/xlsbiff8.pas#l50

But BIFF8 is not a simple format, there is no simple answer to your question. It is encapsulated in a OLE Document storage system to start with, which is something pretty complex.

BIFF2 till BIFF5 (Excel 5.0) were simple formats, but that's not the format you are looking for from your question.

Felipe

John Lee wrote 51 lines
Thanks - that looks excellent, but the 'uses' list for this, for non lazarus users, has, I guess, lots of things in it. The problem is also that I'm trying to implement this hack in an old version of pascal, v2.2.2 for which I only have the compiler & basic rtl stuff - that's why I'd just like some info for a quick hack eg some bullets or some idea what I need to do eg to read the no or string in eg cell x23 of sheet jim in fred.xls. John On 30 September 2013 16:38, Felipe Monteiro de Carvalho wrote: > > You mean like this library does? http://wiki.freepascal.org/FPSpreadsheet > > Felipe Monteiro de Carvalho > > On Mon, Sep 30, 2013 at 5:33 PM, John Lee wrote: > > File produced by excel 2003. Can anyone tell me the basic ideas, > > formats, > > pitfalls - I'd just like to write a short routine & don't want to fight > > with > > the complexities of the lazarus based stuff. Prepared to experiment... > > > > TIA John > > > > > > > > _______________________________________________ > > fpc-pascal maillist - > > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > > -- > Felipe Monteiro de Carvalho > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Felipe Monteiro de Carvalho
John Lee
to Felipe Monteiro de Carvalho

Thanks - as you say (with nice irony) it isn't a simple format, and I don't pretend to understand it, indeed it is 'doing my head in' - but I don't want to write .xls or do charts etc, just read some cells (only in in excel 2003, seems to be v11 according to help) - maybe my hope of a few lines, with one or two units 'used', isn't possible but there seem to be millions of lines here. Is there an example of reading cells from named spread that you could point to?

John

On 1 October 2013 08:44, Felipe Monteiro de Carvalho <

Show quoted text 84 lines
wrote: The source code of fpspreadsheet is open ... just copy/paste/modifiy it for your needs: https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/components/fpspreadsheet/xlsbiff8.pas#l50 But BIFF8 is not a simple format, there is no simple answer to your question. It is encapsulated in a OLE Document storage system to start with, which is something pretty complex. BIFF2 till BIFF5 (Excel 5.0) were simple formats, but that's not the format you are looking for from your question. Felipe On Mon, Sep 30, 2013 at 9:45 PM, John Lee wrote: > Thanks - that looks excellent, but the 'uses' list for this, for non lazarus > users, has, I guess, lots of things in it. > > The problem is also that I'm trying to implement this hack in an old version > of pascal, v2.2.2 for which I only have the compiler & basic rtl stuff - > that's why I'd just like some info for a quick hack eg some bullets or some > idea what I need to do eg to read the no or string in eg cell x23 of sheet > jim in fred.xls. > > John > > > > > > > On 30 September 2013 16:38, Felipe Monteiro de Carvalho > wrote: >> >> You mean like this library does? http://wiki.freepascal.org/FPSpreadsheet >> >> Felipe Monteiro de Carvalho >> >> On Mon, Sep 30, 2013 at 5:33 PM, John Lee wrote: >> > File produced by excel 2003. Can anyone tell me the basic ideas, >> > formats, >> > pitfalls - I'd just like to write a short routine & don't want to fight >> > with >> > the complexities of the lazarus based stuff. Prepared to experiment... >> > >> > TIA John >> > >> > >> > >> > _______________________________________________ >> > fpc-pascal maillist - >> > http://lists.freepascal.org/mailman/listinfo/fpc-pascal >> >> >> >> -- >> Felipe Monteiro de Carvalho >> _______________________________________________ >> fpc-pascal maillist - >> http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal -- Felipe Monteiro de Carvalho _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reinier Olislagers
to John Lee
John Lee wrote 7 lines
Thanks - as you say (with nice irony) it isn't a simple format, and I don't pretend to understand it, indeed it is 'doing my head in' - but I don't want to write .xls or do charts etc, just read some cells (only in in excel 2003, seems to be v11 according to help) - maybe my hope of a few lines, with one or two units 'used', isn't possible but there seem to be millions of lines here. Is there an example of reading cells from named spread that you could point to?

In case you hadn't found it: examples here
http://wiki.lazarus.freepascal.org/FPSpreadsheet

Excel 2003 .xls format is AFAIU BIFF8 as well.

John Lee
to John Lee: Thanks - as you say (with nice irony) it isn't a simple format, and I don't pretend to…

Thanks for all suggestions. IMO fpspread...pas is too complex for & I'd need to hack thro' thousands of lines - maybe a simple program to read xls into csv, as in b) below could be added?.

Here, fyi, In looking around I came up with these 2 :

a) googled 'read xls'

http://exceldatareader.codeplex.com/

Unfortunately I don't use c# but the mechanisms for reading spread look simple in the referenced page ie 1 line!

Guess one could try to use the excel.dll in te reference in fpc & then access it from fpc

b) using a <10 line vbs program referenced here to create a csv file then getting the data from that

http://stackoverflow.com/questions/1858195/convert-xls-to-csv-on-command-line

This is the way I'm doing it, running the vbs file from cmd using exec etc, simple if crude!.

john

John Lee wrote 99 lines
Thanks - as you say (with nice irony) it isn't a simple format, and I don't pretend to understand it, indeed it is 'doing my head in' - but I don't want to write .xls or do charts etc, just read some cells (only in in excel 2003, seems to be v11 according to help) - maybe my hope of a few lines, with one or two units 'used', isn't possible but there seem to be millions of lines here. Is there an example of reading cells from named spread that you could point to? John On 1 October 2013 08:44, Felipe Monteiro de Carvalho < > wrote: > The source code of fpspreadsheet is open ... just copy/paste/modifiy > it for your needs: > > > https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/components/fpspreadsheet/xlsbiff8.pas#l50 > > But BIFF8 is not a simple format, there is no simple answer to your > question. It is encapsulated in a OLE Document storage system to start > with, which is something pretty complex. > > BIFF2 till BIFF5 (Excel 5.0) were simple formats, but that's not the > format you are looking for from your question. > > Felipe > > On Mon, Sep 30, 2013 at 9:45 PM, John Lee wrote: > > Thanks - that looks excellent, but the 'uses' list for this, for non > lazarus > > users, has, I guess, lots of things in it. > > > > The problem is also that I'm trying to implement this hack in an old > version > > of pascal, v2.2.2 for which I only have the compiler & basic rtl stuff - > > that's why I'd just like some info for a quick hack eg some bullets or > some > > idea what I need to do eg to read the no or string in eg cell x23 of > sheet > > jim in fred.xls. > > > > John > > > > > > > > > > > > > > On 30 September 2013 16:38, Felipe Monteiro de Carvalho > > wrote: > >> > >> You mean like this library does? > http://wiki.freepascal.org/FPSpreadsheet > >> > >> Felipe Monteiro de Carvalho > >> > >> On Mon, Sep 30, 2013 at 5:33 PM, John Lee wrote: > >> > File produced by excel 2003. Can anyone tell me the basic ideas, > >> > formats, > >> > pitfalls - I'd just like to write a short routine & don't want to > fight > >> > with > >> > the complexities of the lazarus based stuff. Prepared to > experiment... > >> > > >> > TIA John > >> > > >> > > >> > > >> > _______________________________________________ > >> > fpc-pascal maillist - > >> > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > >> > >> > >> > >> -- > >> Felipe Monteiro de Carvalho > >> _______________________________________________ > >> fpc-pascal maillist - > >> http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > > > > > > _______________________________________________ > > fpc-pascal maillist - > > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > > -- > Felipe Monteiro de Carvalho > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal >
Reinier Olislagers
to John Lee
John Lee wrote
Thanks for all suggestions. IMO fpspread...pas is too complex for & I'd need to hack thro' thousands of lines - maybe a simple program to read xls into csv, as in b) below could be added?.

<snip totally irrelevant reference to other programming language>

Guess one could try to use the excel.dll in te reference in fpc & then access it from fpc

Good luck with that. I strongly doubt that dll is procedural, so you'd have to implement support for C++/.Net (whichever it is) object oriented DLL calling conventions/object support.

Show quoted text 7 lines
b) using a <10 line vbs program referenced here to create a csv file then getting the data from that http://stackoverflow.com/questions/1858195/convert-xls-to-csv-on-command-line This is the way I'm doing it, running the vbs file from cmd using exec etc, simple if crude!.

As already indicated multiple times: fpspreadsheet is about the simplest code required to read BIFF8 xls files. Of course it can be stripped down further from a general purpose library to something that just suits your needs.

You now have indicated multiple times you are not interested in doing that. Unfortunately for you, I don't think anybody else is, either.

You indicated you wanted to use an outdated FPC compiler to do things and did not tell you are wililng to use 3rd party tools. Now it turns out you do use 3rd party tools.

As you indicate: why not simply compile an xls=>csv (or whatever) converter using a recent FPC+Lazarus+fpspreadsheet and use that, then? You *don't* need to hack through 1000s of lines of code for that. The examples on the wiki page indicated already show you the code. Seems you want others to do all the work for you...

Alternatively, you could use Lazarus opendocument to let Excel open an .xls file with a VBA macro that converts the data to whatever format you want, etc.

Good luck.

John Lee
to Reinier Olislagers

I didn't _want_ to use 3rd part products - I didn't really have any choice if I wanted to get something working in a finite time, given the 1000s of lines of code to try to hack, then test when I don't really understand them & the fact that there isn't any easy fpc solution.

Thanks all for you help.
John

Reinier Olislagers wrote 49 lines
On 01/10/2013 21:44, John Lee wrote: > Thanks for all suggestions. IMO fpspread...pas is too complex for & I'd > need to hack thro' thousands of lines - maybe a simple program to read > xls into csv, as in b) below could be added?. <snip totally irrelevant reference to other programming language> > Guess one could try to use the excel.dll in te reference in fpc & then > access it from fpc Good luck with that. I strongly doubt that dll is procedural, so you'd have to implement support for C++/.Net (whichever it is) object oriented DLL calling conventions/object support. > b) using a <10 line vbs program referenced here to create a csv file > then getting the data from that > > http://stackoverflow.com/questions/1858195/convert-xls-to-csv-on-command-line > > This is the way I'm doing it, running the vbs file from cmd using exec > etc, simple if crude!. As already indicated multiple times: fpspreadsheet is about the simplest code required to read BIFF8 xls files. Of course it can be stripped down further from a general purpose library to something that just suits your needs. You now have indicated multiple times you are not interested in doing that. Unfortunately for you, I don't think anybody else is, either. You indicated you wanted to use an outdated FPC compiler to do things and did not tell you are wililng to use 3rd party tools. Now it turns out you do use 3rd party tools. As you indicate: why not simply compile an xls=>csv (or whatever) converter using a recent FPC+Lazarus+fpspreadsheet and use that, then? You *don't* need to hack through 1000s of lines of code for that. The examples on the wiki page indicated already show you the code. Seems you want others to do all the work for you... Alternatively, you could use Lazarus opendocument to let Excel open an .xls file with a VBA macro that converts the data to whatever format you want, etc. Good luck. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
John Lee
to Felipe Monteiro de Carvalho

I have it and use it - but not lazarus. But using some legacy 2.2.2 libraries w/o source & want it to work there. Even with latest fpc it didn't seem very easy to get sheet data into csv, I couldn't follow the examples in fpspread..., seemed to need lots of lazarus stuff n units that I didn't understand, just to do something simple, as in my original email. J

On 2 October 2013 11:20, Felipe Monteiro de Carvalho <

Show quoted text 10 lines
wrote: Why cant you download the latest FPC? -- Felipe Monteiro de Carvalho _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Felipe Monteiro de Carvalho
to John Lee

It's really very simple. fpspreadsheet requires lazutils, which comes inside the source code from Lazarus and lazutils does not require anything out of FPC.

So if you don't want to use Lazarus, which would automatically solve the problem, then just pass 2 unit search paths to FPC when compiling your project which uses fpspreadsheet:

1> Path to fpspreadsheet
2> Path to lazutils (located in the folder lazarus/components/lazutils)

You need to download Lazarus to have lazutils, but you don't have to use it as an IDE.

Felipe Monteiro de Carvalho

John Lee wrote 24 lines
I have it and use it - but not lazarus. But using some legacy 2.2.2 libraries w/o source & want it to work there. Even with latest fpc it didn't seem very easy to get sheet data into csv, I couldn't follow the examples in fpspread..., seemed to need lots of lazarus stuff n units that I didn't understand, just to do something simple, as in my original email. J On 2 October 2013 11:20, Felipe Monteiro de Carvalho wrote: > > Why cant you download the latest FPC? > > -- > Felipe Monteiro de Carvalho > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Felipe Monteiro de Carvalho