ScriptForge (SF_Calc) formatting methods

So far only the SetCellStyle() method
provided means to modify cell formats.

The actual patch introduces next methods
to apply simple and common formats. For
other options use the XCellRange
UNO interface.

- calc.AlignRange(targetrange,alignment,...)
- calc.BorderRange(targetrange,borders,...)
- calc.ColorizeRange(targetrange,foreground,background,...)
- calc.DecorateFont(targetrange,fontname,fontsize,
         decoration,...)
- calc.FormatRange(targetrange,numberformat,locale,...)

Extra arguments ("...") are:
  FilterFormula: a Calc formula to select cells
  FilterScope; CELL, ROW or COLUMN
to allow a kind of static conditional formats.

All methods are applicable to Basic and Python
user scripts.

This change will require an update of the
user documentation.

Change-Id: Ic824aebd763f2b55364c2c0bea17430f32512742
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181854
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
This commit is contained in:
Jean-Pierre Ledure
2025-02-19 10:59:24 +01:00
parent 09721edb1c
commit ec71ff69fe
3 changed files with 773 additions and 7 deletions
@@ -2518,6 +2518,12 @@ class SFDocuments:
def Activate(self, sheetname = ''):
return self.ExecMethod(self.vbMethod, 'Activate', sheetname)
def AlignRange(self, targetrange, alignment, filterformula = '', filterscope = ''):
return self.ExecMethod(self.vbMethod, 'AlignRange', targetrange, alignment, filterformula, filterscope)
def BorderRange(self, targetrange, borders, filterformula = '', filterscope = ''):
return self.ExecMethod(self.vbMethod, 'BorderRange', targetrange, borders, filterformula, filterscope)
def Charts(self, sheetname, chartname = ''):
return self.ExecMethod(self.vbMethod + self.flgArrayRet, 'Charts', sheetname, chartname)
@@ -2530,6 +2536,10 @@ class SFDocuments:
def ClearValues(self, range, filterformula = '', filterscope = ''):
return self.ExecMethod(self.vbMethod, 'ClearValues', range, filterformula, filterscope)
def ColorizeRange(self, targetrange, foreground = -1, background = -1, filterformula = '', filterscope = ''):
return self.ExecMethod(self.vbMethod, 'ColorizeRange', targetrange, foreground, background,
filterformula, filterscope)
def CompactLeft(self, range, wholecolumn = False, filterformula = ''):
return self.ExecMethod(self.vbMethod, 'CompactLeft', range, wholecolumn, filterformula)
@@ -2579,9 +2589,18 @@ class SFDocuments:
def DSum(self, range):
return self.ExecMethod(self.vbMethod, 'DSum', range)
def DecorateFont(self, targetrange, fontname = '', fontsize = 0, decoration = '',
filterformula = '', filterscope = ''):
return self.ExecMethod(self.vbMethod, 'DecorateFont', targetrange, fontname, fontsize, decoration,
filterformula, filterscope)
def ExportRangeToFile(self, range, filename, imagetype = 'pdf', overwrite = False):
return self.ExecMethod(self.vbMethod, 'ExportRangeToFile', range, filename, imagetype, overwrite)
def FormatRange(self, targetrange, numberformat, locale = '', filterformula = '', filterscope = ''):
return self.ExecMethod(self.vbMethod, 'FormatRange', targetrange, numberformat, locale,
filterformula, filterscope)
def Forms(self, sheetname, form = ''):
return self.ExecMethod(self.vbMethod + self.flgArrayRet, 'Forms', sheetname, form)