fpspreadsheet: Fix writing of RichText in Excel2003/XML format.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7034 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2019-07-14 20:37:29 +00:00
parent 73f87c6979
commit 5aff5d6d37
4 changed files with 33 additions and 13 deletions

View File

@ -23,8 +23,7 @@ var
begin begin
// Open the input file // Open the input file
dir := ExtractFilePath(ParamStr(0)); dir := ExtractFilePath(ParamStr(0));
// inputFileName := dir + 'test.xml'; inputFileName := dir + 'test.xml';
inputFileName := dir + 'datatypes.xml';
if not FileExists(inputFileName) then begin if not FileExists(inputFileName) then begin
WriteLn('Input file ', inputFileName, ' does not exist. Please run excelxmlwrite first.'); WriteLn('Input file ', inputFileName, ' does not exist. Please run excelxmlwrite first.');

View File

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<CONFIG> <CONFIG>
<ProjectOptions> <ProjectOptions>
<Version Value="11"/> <Version Value="12"/>
<PathDelim Value="\"/> <PathDelim Value="\"/>
<General> <General>
<Flags> <Flags>
<LRSInOutputDirectory Value="False"/> <LRSInOutputDirectory Value="False"/>
<CompatibilityMode Value="True"/>
</Flags> </Flags>
<SessionStorage Value="InProjectDir"/> <SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="excelxmlwrite"/> <Title Value="excelxmlwrite"/>
<UseAppBundle Value="False"/> <UseAppBundle Value="False"/>
</General> </General>
@ -17,19 +17,16 @@
</BuildModes> </BuildModes>
<PublishOptions> <PublishOptions>
<Version Value="2"/> <Version Value="2"/>
<IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions> </PublishOptions>
<RunParams> <RunParams>
<local> <local>
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/> <LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T &apos;Lazarus Run Output&apos; -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local> </local>
<FormatVersion Value="2"/> <FormatVersion Value="2"/>
<Modes Count="1"> <Modes Count="1">
<Mode0 Name="default"> <Mode0 Name="default">
<local> <local>
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/> <LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T &apos;Lazarus Run Output&apos; -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local> </local>
</Mode0> </Mode0>
</Modes> </Modes>

View File

@ -126,7 +126,6 @@ begin
MyWorksheet.WriteBorderLineStyle(5, 13, cbSouth, lsDotted); MyWorksheet.WriteBorderLineStyle(5, 13, cbSouth, lsDotted);
// N6 empty cell, left border: double // N6 empty cell, left border: double
// MyWorksheet.WriteBlank(5, 14);
MyWorksheet.WriteBorders(5, 14, [cbWest]); MyWorksheet.WriteBorders(5, 14, [cbWest]);
MyWorksheet.WriteBorderLineStyle(5, 14, cbWest, lsDouble); MyWorksheet.WriteBorderLineStyle(5, 14, cbWest, lsDouble);
@ -142,6 +141,8 @@ begin
MyWorksheet.WriteText(8, 3, 'Colors...'); MyWorksheet.WriteText(8, 3, 'Colors...');
MyWorksheet.WriteFont(8, 3, 'Courier New', 12, [fssUnderline], scBlue); MyWorksheet.WriteFont(8, 3, 'Courier New', 12, [fssUnderline], scBlue);
MyWorksheet.WriteBackgroundColor(8, 3, scYellow); MyWorksheet.WriteBackgroundColor(8, 3, scYellow);
(********************* to do...
MyWorksheet.WriteComment(8, 3, 'This is font "Courier New", Size 12.'); MyWorksheet.WriteComment(8, 3, 'This is font "Courier New", Size 12.');
// Write the string formula E1 = A1 + B1 ... // Write the string formula E1 = A1 + B1 ...
@ -169,7 +170,7 @@ begin
RPNSTring('B', RPNSTring('B',
RPNFunc(fekConcat, RPNFunc(fekConcat,
nil))))); nil)))));
*)
r := 10; r := 10;
MyWorksheet.WriteText(r, 0, 'Writing current date/time:'); MyWorksheet.WriteText(r, 0, 'Writing current date/time:');
inc(r, 2); inc(r, 2);
@ -377,6 +378,8 @@ begin
// Set height of rows 0 // Set height of rows 0
MyWorksheet.WriteRowHeight(0, 5, suLines); // 5 lines MyWorksheet.WriteRowHeight(0, 5, suLines); // 5 lines
//----------------------------------------------------------------------------
// Creates a new worksheet // Creates a new worksheet
MyWorksheet := MyWorkbook.AddWorksheet(Str_Worksheet2); MyWorksheet := MyWorkbook.AddWorksheet(Str_Worksheet2);

View File

@ -1174,6 +1174,9 @@ var
cctStr: String; cctStr: String;
xmlnsStr: String; xmlnsStr: String;
dataTagStr: String; dataTagStr: String;
p: Integer;
tmp: String;
ch:char;
begin begin
if Length(ACell^.RichTextParams) > 0 then if Length(ACell^.RichTextParams) > 0 then
begin begin
@ -1187,6 +1190,24 @@ begin
); );
xmlnsStr := ' xmlns="http://www.w3.org/TR/REC-html40"'; xmlnsStr := ' xmlns="http://www.w3.org/TR/REC-html40"';
dataTagStr := 'ss:'; dataTagStr := 'ss:';
// Excel does not like units in font size specification...
tmp := valueStr;
p := pos('<Font html:Size="', valueStr);
if p > 0 then begin
valueStr := '';
while p > 0 do begin
inc(p, Length('<Font html:Size="'));
valueStr := valueStr + copy(tmp, 1, p-1);
while (tmp[p] <> '"') do begin
if (tmp[p] in ['0'..'9', '.']) then valueStr := valueStr + tmp[p];
inc(p);
end;
tmp := copy(tmp, p, MaxInt);
p := pos('<Font html:Size="', tmp);
end;
valueStr := valuestr + tmp;
end;
end else end else
begin begin
valueStr := AValue; valueStr := AValue;
@ -1597,8 +1618,8 @@ begin
// Protection // Protection
protectStr := Format(INDENT3 + '<ProtectObjects>%s</ProtectObjects>' + LF + protectStr := Format(INDENT3 + '<ProtectObjects>%s</ProtectObjects>' + LF +
INDENT3 + '<ProtectScenarios>%s</ProtectScenarios>' + LF, [ INDENT3 + '<ProtectScenarios>%s</ProtectScenarios>' + LF, [
StrUtils.IfThen(AWorksheet.IsProtected and (spObjects in AWorksheet.Protection), '1', '0'), StrUtils.IfThen(AWorksheet.IsProtected and (spObjects in AWorksheet.Protection), 'True', 'False'),
StrUtils.IfThen(AWorksheet.IsProtected {and [spScenarios in AWorksheet.Protection])}, '1', '0') StrUtils.IfThen(AWorksheet.IsProtected {and [spScenarios in AWorksheet.Protection])}, 'True', 'False')
]); ]);
// Put it all together... // Put it all together...