You've already forked lazarus-ccr
fpspreadsheet: Fix xlsx and ods writers using local format settings for writing floats in conditional formats.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8039 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -454,13 +454,22 @@ const
|
|||||||
'5Rating', '5Quarters', '5Boxes' // is5Rating, is5Quarters, is5Boxes
|
'5Rating', '5Quarters', '5Boxes' // is5Rating, is5Quarters, is5Boxes
|
||||||
);
|
);
|
||||||
|
|
||||||
function CFOperandToStr(v: variant; AWorksheet: TsWorksheet): String;
|
function CFOperandToStr(v: variant; AWorksheet: TsWorksheet;
|
||||||
|
const AFormatSettings: TFormatSettings): String;
|
||||||
var
|
var
|
||||||
r,c: Cardinal;
|
r,c: Cardinal;
|
||||||
|
f: Double;
|
||||||
begin
|
begin
|
||||||
Result := VarToStr(v);
|
if VarIsFloat(v) then
|
||||||
if Result = '' then
|
begin
|
||||||
exit;
|
f := v;
|
||||||
|
Result := Format('%g', [f], AFormatSettings);
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
Result := VarToStr(v);
|
||||||
|
if Result = '' then
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
if VarIsStr(v) then begin
|
if VarIsStr(v) then begin
|
||||||
// Special case: v is a formula, i.e. begins with '='
|
// Special case: v is a formula, i.e. begins with '='
|
||||||
@@ -6592,8 +6601,8 @@ begin
|
|||||||
begin
|
begin
|
||||||
cf_cellRule := TsCFCellRule(cf.Rules[j]);
|
cf_cellRule := TsCFCellRule(cf.Rules[j]);
|
||||||
cf_styleName := Format('conditional_%d', [cf_CellRule.FormatIndex]);
|
cf_styleName := Format('conditional_%d', [cf_CellRule.FormatIndex]);
|
||||||
value1Str := CFOperandToStr(cf_cellRule.Operand1, sheet);
|
value1Str := CFOperandToStr(cf_cellRule.Operand1, sheet, FPointSeparatorSettings);
|
||||||
value2Str := CFOperandToStr(cf_cellRule.Operand2, sheet);
|
value2Str := CFOperandToStr(cf_cellRule.Operand2, sheet, FPointSeparatorSettings);
|
||||||
opStr := Format(CF_CALCEXT_OP[cf_cellRule.Condition], [value1Str, value2str]);
|
opStr := Format(CF_CALCEXT_OP[cf_cellRule.Condition], [value1Str, value2str]);
|
||||||
isDateFmt := cf_cellRule.Condition in [cfcYesterday..cfcNextYear];
|
isDateFmt := cf_cellRule.Condition in [cfcYesterday..cfcNextYear];
|
||||||
if opStr <> '' then
|
if opStr <> '' then
|
||||||
@@ -8123,12 +8132,12 @@ begin
|
|||||||
operand1Str := VarToStr(cf_cellRule.Operand1);
|
operand1Str := VarToStr(cf_cellRule.Operand1);
|
||||||
if (operand1Str <> '') and (operand1Str[1] <> '=') then
|
if (operand1Str <> '') and (operand1Str[1] <> '=') then
|
||||||
operand1Str := '=' + operand1Str;
|
operand1Str := '=' + operand1Str;
|
||||||
operand1Str := CFOperandToStr(operand1Str, cf_sheet);
|
operand1Str := CFOperandToStr(operand1Str, cf_sheet, FPointSeparatorSettings);
|
||||||
operand2Str := '';
|
operand2Str := '';
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
operand1Str := CFOperandToStr(cf_cellrule.Operand1, cf_sheet);
|
operand1Str := CFOperandToStr(cf_cellrule.Operand1, cf_sheet, FPointSeparatorSettings);
|
||||||
operand2Str := CFOperandToStr(cf_cellrule.Operand2, cf_sheet);
|
operand2Str := CFOperandToStr(cf_cellrule.Operand2, cf_sheet, FPointSeparatorSettings);
|
||||||
end;
|
end;
|
||||||
cf_condition := Format(CF_STYLE_OP[cf_cellRule.Condition], [operand1Str, operand2Str]);
|
cf_condition := Format(CF_STYLE_OP[cf_cellRule.Condition], [operand1Str, operand2Str]);
|
||||||
|
|
||||||
|
@@ -548,15 +548,23 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CFOperandToStr(v: Variant): String;
|
function CFOperandToStr(v: Variant; const AFormatSettings: TFormatSettings): String;
|
||||||
const
|
const
|
||||||
ERR = cardinal(-1);
|
ERR = cardinal(-1);
|
||||||
var
|
var
|
||||||
r, c: Cardinal;
|
r, c: Cardinal;
|
||||||
|
f: Double;
|
||||||
begin
|
begin
|
||||||
Result := VarToStr(v);
|
if VarIsFloat(v) then
|
||||||
if Result = '' then
|
begin
|
||||||
exit;
|
f := v;
|
||||||
|
Result := Format('%g', [f], AFormatSettings);
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
Result := VarToStr(v);
|
||||||
|
if Result = '' then
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
if Result[1] = '=' then
|
if Result[1] = '=' then
|
||||||
Delete(Result, 1, 1)
|
Delete(Result, 1, 1)
|
||||||
@@ -4219,11 +4227,11 @@ begin
|
|||||||
case ARule.Condition of
|
case ARule.Condition of
|
||||||
cfcEqual..cfcNotBetween:
|
cfcEqual..cfcNotBetween:
|
||||||
begin
|
begin
|
||||||
s := CFOperandToStr(ARule.Operand1);
|
s := CFOperandToStr(ARule.Operand1, FPointSeparatorSettings);
|
||||||
formula1Str := Format('<formula>%s</formula>', [s]);
|
formula1Str := Format('<formula>%s</formula>', [s]);
|
||||||
if (ARule.Condition in [cfcBetween, cfcNotBetween]) then
|
if (ARule.Condition in [cfcBetween, cfcNotBetween]) then
|
||||||
begin
|
begin
|
||||||
s := CFOperandToStr(ARule.Operand2);
|
s := CFOperandToStr(ARule.Operand2, FPointSeparatorSettings);
|
||||||
formula2Str := Format('<formula>%s</formula>', [s]);
|
formula2Str := Format('<formula>%s</formula>', [s]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@@ -4234,7 +4242,7 @@ begin
|
|||||||
if (ARule.Condition in [cfcAboveEqualAverage, cfcBelowEqualAverage]) then
|
if (ARule.Condition in [cfcAboveEqualAverage, cfcBelowEqualAverage]) then
|
||||||
param2Str := ' equalAverage="1"';
|
param2Str := ' equalAverage="1"';
|
||||||
if VarIsNumeric(ARule.Operand1) or (ARule.Operand1 = 0) then
|
if VarIsNumeric(ARule.Operand1) or (ARule.Operand1 = 0) then
|
||||||
param3Str := Format(' stdDev="%g"', [double(ARule.Operand1)]);
|
param3Str := Format(' stdDev="%g"', [double(ARule.Operand1)], FPointSeparatorSettings);
|
||||||
end;
|
end;
|
||||||
cfcTop, cfcBottom, cfcTopPercent, cfcBottomPercent:
|
cfcTop, cfcBottom, cfcTopPercent, cfcBottomPercent:
|
||||||
begin
|
begin
|
||||||
|
Reference in New Issue
Block a user