Recent

Author Topic: Problems with fpSpreadsheet in a console app...  (Read 10420 times)

idealis

  • New Member
  • *
  • Posts: 34
Problems with fpSpreadsheet in a console app...
« on: October 20, 2010, 02:41:48 am »
Hi, I am trying to write a small console app that reads from an Excel spreadsheet and saves something to a DBF file. The file opening sequence looks like this:

Code: [Select]
WriteLn('STEP 1');
  nWorkBook := TsWorkbook.Create;
  WriteLn('STEP 2');
  nWorkBook.ReadFromFile(MyXLS,sfExcel8);
  WriteLn('STEP 3');
  nWorkSheet := nWorkBook.GetFirstWorksheet;
  ...

It would work normally in a standard app; however the output for this console app goes like

Code: [Select]
STEP 1
STEP 2
exception at 00435934:
Expected CONTINUE not found.

I couldn't find any info on this exception (and the program won't allow me to simply insert a 'CONTINUE;' into the code). Any clues?

Thanks in advance :)

- idealis

ivan17

  • Full Member
  • ***
  • Posts: 173
Re: Problems with fpSpreadsheet in a console app...
« Reply #1 on: October 20, 2010, 11:32:57 am »
binary excel files are composed of records. when one item is larger then 8224 bytes, it will be cut and continued in one or more CONTINUE records following the record in question.

in plain words - messed up file or wrong format.  add exception handling.

José Mejuto

  • Full Member
  • ***
  • Posts: 136
Re: Problems with fpSpreadsheet in a console app...
« Reply #2 on: October 21, 2010, 03:41:14 pm »
Hi, I am trying to write a small console app that reads from an Excel spreadsheet and
[...]
It would work normally in a standard app; however the output for this console app goes like
Code: [Select]
[...]
Expected CONTINUE not found.
I couldn't find any info on this exception (and the program won't allow me to simply insert a 'CONTINUE;' into the code). Any clues?
[...]

Hello,

Can you post a bug report in http://bugs.freepascal.org/ with the affected XLS file. Is not easy to find excel files with the continue TAG (which is a horrendous technique from my point of view) so this TAG has not been tested very well.

ivan17

  • Full Member
  • ***
  • Posts: 173
Re: Problems with fpSpreadsheet in a console app...
« Reply #3 on: October 21, 2010, 09:43:57 pm »
Can you post a bug report in http://bugs.freepascal.org/ with the affected XLS file. Is not easy to find excel files with the continue TAG (which is a horrendous technique from my point of view) so this TAG has not been tested very well.

not easy to find?  well this will shock you: make a new workbook, insert a 50kb bitmap, save.

that being said, idealis, i too would like to take a peek inside the file; can you upload it somewhere or attach to this thread (compressed and possibly split into 128k pieces)?

José Mejuto

  • Full Member
  • ***
  • Posts: 136
Re: Problems with fpSpreadsheet in a console app...
« Reply #4 on: October 22, 2010, 06:38:59 pm »
not easy to find?  well this will shock you: make a new workbook, insert a 50kb bitmap, save.
that being said, idealis, i too would like to take a peek inside the file; can you upload it somewhere or attach to this thread (compressed and possibly split into 128k pieces)?

Hello,

My bad! :) Just thinking in a spreadsheet as a "raw" spreadsheet with a lot of numbers :) In fact I do not have any file in my test case with graphics! I must check it. Thank you.

idealis

  • New Member
  • *
  • Posts: 34
Re: Problems with fpSpreadsheet in a console app...
« Reply #5 on: October 29, 2010, 12:13:20 pm »
Sorry for the late reply, I had a bunch of important stuff to do, heh.

As for the spreadsheet, I would like to send it to you, but sadly it contains "confidential" information, so I don't think it would be right to do so. I've experimented a bit with it, however, changing the information to generic data and the program worked fine! As I'm writing this I'm getting the idea that this all could be caused by an excessive record length (I didn't quite get what ivan17 said about the 8224 bytes limit, but probably he was talking about this).

As soon as I run some more tests I will tell you. :)

- idealis

José Mejuto

  • Full Member
  • ***
  • Posts: 136
Re: Problems with fpSpreadsheet in a console app...
« Reply #6 on: October 29, 2010, 03:17:47 pm »
[...]
fine! As I'm writing this I'm getting the idea that this all could be caused by an excessive record length (I didn't quite get what ivan17 said about the 8224 bytes limit, but probably he was talking about this).
As soon as I run some more tests I will tell you. :)
- idealis

Hello,

Yes it is, all information is stored in records with a maximun length of 8224 bytes, so if a cell carries some information that exceed this size is must be splitted across different records using a CONTINUE signal. This continue has been implemented more or less fine for text records, but maybe for unknown records (graphics in example are unknown to fpspreadsheet) it is not implemented in any way.

ivan17

  • Full Member
  • ***
  • Posts: 173
Re: Problems with fpSpreadsheet in a console app...
« Reply #7 on: October 29, 2010, 08:56:53 pm »
As for the spreadsheet, I would like to send it to you, but sadly it contains "confidential" information, so I don't think it would be right to do so.

being a really nice guy, you decided to remove the sensitive information, however...

I've experimented a bit with it, however, changing the information to generic data and the program worked fine!

that's because you opened the document in excel or calc, changed something and saved - the program then saved the new workbook correctly. the resulting file is completely worthless. oh well...

 

TinyPortal © 2005-2018