[Solved] Spaces lost when writing on FPSpreadsheet
lazarus / 49-FPSpreadsheet
----------------------------------------------------------------------
Edson · 2016-02-27 15:41
I'm using:
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i
MyWorksheet.WriteUTF8Text(row, col, ' something'); but spaces
don't appear later when opening the Excel workbook. Am I forgetting
something?
I'm using Fpspreadsheet-1.6.0.
Thanks.
----------------------------------------------------------------------
wp · 2016-02-27 16:27
I cannot confirm with fpspreadsheet trunk (v 1.7) and Excel 2007. I
think the required attribute 'xml:space="preserve"' has been there for
quite a long time. Which Excel are you using? Does LibreOfficeCalc
open the file correctly? - it should
----------------------------------------------------------------------
Edson · 2016-02-27 16:35
I'm using Office 2010.
My file i s generated using:
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i
MyWorksheet.WriteToFile(fileOutput, sfOOXML);
I don't have Libre Office. I'm going to download it
----------------------------------------------------------------------
wp · 2016-02-27 16:39
Maybe Office 2010 does things a little bit different from Office2007.
Please create a simple xlsx file using Excel2010 with a single text
cell containing a string with leading spaces. Then do the same with
fpspreadsheet. Post both files here.
----------------------------------------------------------------------
Edson · 2016-02-27 16:55
These files are supposed to have the value ' a ' in the cell A1.
The created by Lazarus, is not working.
----------------------------------------------------------------------
Edson · 2016-02-27 17:20
I see, Excel generate the code:
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i a
In the file "sharedStrings.xml", while Lazarus generate:
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i
a
----------------------------------------------------------------------
wp · 2016-02-27 17:26
Ok. I was wrong, the "xml:space" attribute was not yet used in fps1.6.
Either update to fpspreadsheet trunk, or patch your version in the
following way:
Open unit xlsxooxmlGo to line 3497 (in procedure
TsSpreadOOXMLWriter.WriteLabel) and modify the line "'' +
ResultingValue + '' + " to "'' +
ResultingValue + '' + " The entire AppendToStream call (beginning
at line 3495) should read like this
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i
AppendToStream(FSSharedStrings, '' + '' + ResultingValue + '' + '');
----------------------------------------------------------------------
Edson · 2016-02-27 18:03
That solves my problem. Thanks.