summaryrefslogtreecommitdiff
path: root/col.go
diff options
context:
space:
mode:
authorKostya Privezentsev <privezentsev@gmail.com>2022-08-30 19:02:48 +0300
committerGitHub <noreply@github.com>2022-08-31 00:02:48 +0800
commit18cd63a548afa1abcddc86a998fdefa3b4cc60c1 (patch)
tree20abe577307ce6d072900f0b98fee57e06133eea /col.go
parentbef49e40eec508a6413e80ee5df7df52f7827424 (diff)
This is a breaking change closes #1332 (#1333)
This use `InsertRows` instead of `InsertRow`, and using `InsertCols` instead of `InsertCol`
Diffstat (limited to 'col.go')
-rw-r--r--col.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/col.go b/col.go
index 248e22c..f51336d 100644
--- a/col.go
+++ b/col.go
@@ -657,16 +657,25 @@ func (f *File) GetColWidth(sheet, col string) (float64, error) {
return defaultColWidth, err
}
-// InsertCol provides a function to insert a new column before given column
-// index. For example, create a new column before column C in Sheet1:
+// InsertCols provides a function to insert new columns before the given column
+// name and number of columns. For example, create two columns before column
+// C in Sheet1:
//
-// err := f.InsertCol("Sheet1", "C")
-func (f *File) InsertCol(sheet, col string) error {
+// err := f.InsertCols("Sheet1", "C", 2)
+//
+// Use this method with caution, which will affect changes in references such
+// as formulas, charts, and so on. If there is any referenced value of the
+// worksheet, it will cause a file error when you open it. The excelize only
+// partially updates these references currently.
+func (f *File) InsertCols(sheet, col string, n int) error {
num, err := ColumnNameToNumber(col)
if err != nil {
return err
}
- return f.adjustHelper(sheet, columns, num, 1)
+ if n < 1 || n > MaxColumns {
+ return ErrColumnNumber
+ }
+ return f.adjustHelper(sheet, columns, num, n)
}
// RemoveCol provides a function to remove single column by given worksheet