exceljs / exceljs

Excel Workbook Manager
MIT License
13.75k stars 1.75k forks source link

Conditional Formatting Example priority key missing #2760

Open dennisdotg opened 5 months ago

dennisdotg commented 5 months ago

Hi guys!

I noticed that under the Conditional Formatting section, the example does not contain the priority key which is mandatory

// add a checkerboard pattern to A1:E7 based on row + col being even or odd
worksheet.addConditionalFormatting({
  ref: 'A1:E7',
  rules: [
    {
      type: 'expression',
      formulae: ['MOD(ROW()+COLUMN(),2)=0'],
      style: {fill: {type: 'pattern', pattern: 'solid', bgColor: {argb: 'FF00FF00'}}},
    }
  ]
})
export interface ConditionalFormattingBaseRule {
    priority: number;
    style?: Partial<Style>;
}
Type '{ type: "expression"; formulae: string[]; style: { fill: { type: "pattern"; pattern: "solid"; bgColor: { argb: string; }; }; }; }' is not assignable to type 'ConditionalFormattingRule'.
  Property 'priority' is missing in type '{ type: "expression"; formulae: string[]; style: { fill: { type: "pattern"; pattern: "solid"; bgColor: { argb: string; }; }; }; }' but required in type 'ExpressionRuleType'.ts(2322)
index.d.ts(1017, 2): 'priority' is declared here
Blackhol3 commented 5 months ago

The error is in the type declaration, not in the example; priority is indeed optional and will be automatically assigned in ascending order if missing, as explained in the documentation. The issue is resolved with #2736.