Recent

Author Topic: Text truncated over 255 chars [SOLVED]  (Read 5031 times)

totya

  • Hero Member
  • *****
  • Posts: 720
Text truncated over 255 chars [SOLVED]
« on: October 30, 2017, 08:50:01 pm »
Hi!

Thanks for this great component, but I found a problem.

Simple open/save or CopyCell (in worksheet or between worksheets) result truncated text over 255 chars.

See attached sample.

Thanks!
« Last Edit: November 03, 2017, 07:57:25 pm by totya »

wp

  • Hero Member
  • *****
  • Posts: 11854
Re: Text truncated over 255 chars
« Reply #1 on: October 31, 2017, 09:11:11 am »
The copied cell is written to the file in full length. Open the saved file in LibreOffice calc or Spready to verify (you'll have to increase the row height to see everything). So, the problem is that the text is truncated when the file is read by Excel!

The text in cell (0, 0) is in a "LabelSST" record, this means that the text is stored in the SST ("shared strings table") and the cell contains only the index of the text within the SST. These records were introduced with the BIFF8 format.

fpspreadsheet, on the other hand, writes text in the old "Label" records used in the previous versions. The old versions had reserved 1 byte for the string length; therefore, Excel 5 and earlier must truncate at 255 characters. I did not expect that BIFF8 does the same because Microsoft has extended the length information to two bytes.

I'll try to introduce a Shared-String-Table in the implementation of BIFF8 for fpspreadsheet. Let's see what happens.

totya

  • Hero Member
  • *****
  • Posts: 720
Re: Text truncated over 255 chars
« Reply #2 on: October 31, 2017, 04:14:44 pm »
Hi master!

Thanks for the answer! I worked my real job file, and I see, some long texts are truncated, so I think this is important problem. In my job we uses Office XP version (BIFF8).

If I open sample_out.xls from Office 2007, the text truncated already. If I open it from Spready it seems to me it is okay.

Thank you! ...and I hope the new version will arrive soon... :)
« Last Edit: November 01, 2017, 11:38:44 am by totya »

wp

  • Hero Member
  • *****
  • Posts: 11854
Re: Text truncated over 255 chars
« Reply #3 on: November 03, 2017, 02:48:08 pm »
Done finally... The Excel8 writer of fpspreadsheet r6054 now writes strings to a shared-string-table (SST) and this overcomes the 255-character-limit. It was quite mind-twisting to get this working along with rich-text formatting runs because a BIFF record is limited to 8224 bytes; therefore CONTINUE records had to be added if this is not enough, which is very likely in case of the SST which collects all strings of the worksheet; and correspondingly, strings and formatting runs have to be split correctly at the cross-over.

Please test carefully. I think that the most critical border cases are covered by the tests included with fpspreadsheet, but you never can tell...

totya

  • Hero Member
  • *****
  • Posts: 720
Re: Text truncated over 255 chars
« Reply #4 on: November 03, 2017, 07:57:15 pm »
Thanks master, thank you for your job, it seems to me it's working!


derles

  • New Member
  • *
  • Posts: 35
Re: Text truncated over 255 chars [SOLVED, but not for me ]
« Reply #5 on: September 05, 2018, 10:29:07 pm »
Hi.
I have the same problem: exporting to Excel, text over 255 char length are truncated to 255.
I don't get the explained solution.

Anyone can help me ?
Tksss

Daniel

wp

  • Hero Member
  • *****
  • Posts: 11854
Re: Text truncated over 255 chars [SOLVED]
« Reply #6 on: September 05, 2018, 11:16:35 pm »
Are you using a fpspreadsheet v1.8.x? You should update to 10.1 (https://sourceforge.net/projects/lazarus-ccr/files/FPSpreadsheet/fpspreadsheet-1.10.1.zip/download).

 

TinyPortal © 2005-2018