summaryrefslogtreecommitdiff
path: root/cell.go
diff options
context:
space:
mode:
Diffstat (limited to 'cell.go')
-rw-r--r--cell.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/cell.go b/cell.go
index 1da46aa..f9868de 100644
--- a/cell.go
+++ b/cell.go
@@ -273,9 +273,15 @@ func (f *File) GetCellFormula(sheet, axis string) (string, error) {
})
}
+// FormulaOpts can be passed to SetCellFormula to use other formula types.
+type FormulaOpts struct {
+ Type *string // Formula type
+ Ref *string // Shared formula ref
+}
+
// SetCellFormula provides a function to set cell formula by given string and
// worksheet name.
-func (f *File) SetCellFormula(sheet, axis, formula string) error {
+func (f *File) SetCellFormula(sheet, axis, formula string, opts ...FormulaOpts) error {
xlsx, err := f.workSheetReader(sheet)
if err != nil {
return err
@@ -295,6 +301,17 @@ func (f *File) SetCellFormula(sheet, axis, formula string) error {
} else {
cellData.F = &xlsxF{Content: formula}
}
+
+ for _, o := range opts {
+ if o.Type != nil {
+ cellData.F.T = *o.Type
+ }
+
+ if o.Ref != nil {
+ cellData.F.Ref = *o.Ref
+ }
+ }
+
return err
}