You've already forked lazarus-ccr
fpspreadsheet: Add writing of error-related conditional formatting conditions to xlsx writer.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7499 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -70,6 +70,21 @@ begin
|
||||
fmtIdx := wb.AddCellFormat(fmt);
|
||||
sh.WriteConditionalCellFormat(Range(0, 4, 5, 4), cfcContainsText, 'bc', fmtIdx);
|
||||
|
||||
{ ------ 5th conditional format: containsErrors -------------------------- }
|
||||
sh.WriteFormula(0, 6, '=1.0/0.0');
|
||||
sh.WriteFormula(1, 6, '=1.0/1.0');
|
||||
sh.WriteFormula(2, 6, '=1.0/2.0');
|
||||
|
||||
InitFormatRecord(fmt);
|
||||
fmt.SetBackgroundColor(scGreen);
|
||||
fmtIdx := wb.AddCellFormat(fmt);
|
||||
sh.WriteConditionalCellFormat(Range(0, 6, 5, 6), cfcNotContainsErrors, fmtIdx);
|
||||
|
||||
// Condition for ContainsErrors after NoContainsErrors to get higher priority
|
||||
fmt.SetBackgroundColor(scRed);
|
||||
fmtIdx := wb.AddCellFormat(fmt);
|
||||
sh.WriteConditionalCellFormat(Range(0, 0, 100, 100), cfcContainsErrors, fmtIdx);
|
||||
|
||||
{ ------ Save workbook to file-------------------------------------------- }
|
||||
wb.WriteToFile('test.xlsx', true);
|
||||
finally
|
||||
|
@ -3347,13 +3347,15 @@ const
|
||||
('equal', 'notEqual', 'greaterThan', 'lessThan', 'greaterThanOrEqual', 'lessThanOrEqual');
|
||||
OPERATOR_NAMES_2: array[cfcBetween..cfcNotBetween] of String =
|
||||
('between', 'notBetween');
|
||||
OPERATOR_NAMES_Text: array[cfcBeginsWith..cfcNotContainsText] of String =
|
||||
('beginsWith', 'endsWith', 'containsText', 'notContainsText');
|
||||
FORMULA: array[cfcBeginsWith..cfcNotContainsText] of String = (
|
||||
OPERATOR_NAMES_Text: array[cfcBeginsWith..cfcNotContainsErrors] of String =
|
||||
('beginsWith', 'endsWith', 'containsText', 'notContainsText', 'containsErrors', 'notContainsErrors');
|
||||
FORMULA: array[cfcBeginsWith..cfcNotContainsErrors] of String = (
|
||||
'LEFT(%0:s,LEN("%1:s"))="%1:s"', // cfcBeginsWith
|
||||
'RIGHT(%0:s,Len("%1:s"))="%1:s"', // cfcEndsWidth
|
||||
'NOT(ISERROR(SEARCH("%1:s",%0:s)))', // cfcContainsText
|
||||
'ISERROR(SEARCH("%1:s",%0:s))' // cfcNotContainsText
|
||||
'ISERROR(SEARCH("%1:s",%0:s))', // cfcNotContainsText
|
||||
'ISERROR(%0:s)', // cfcContainsErrors
|
||||
'NOT(ISERROR(%0:s))' // cfcNotContainsErrors
|
||||
);
|
||||
var
|
||||
i: Integer;
|
||||
@ -3406,7 +3408,7 @@ begin
|
||||
[dxfId, APriority, aveStr, stdDevStr, eqAveStr]));
|
||||
end;
|
||||
|
||||
cfcBeginsWith..cfcNotContainsText:
|
||||
cfcBeginsWith..cfcNotContainsErrors:
|
||||
begin
|
||||
firstCellOfRange := GetCellString(ARange.Row1, ARange.Col1);
|
||||
if ARule.Condition = cfcNotContainsText then opStr := ' operator="notContains"' else opStr := '';
|
||||
|
Reference in New Issue
Block a user