diff options
author | Kostya Privezentsev <privezentsev@gmail.com> | 2022-08-30 19:02:48 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-31 00:02:48 +0800 |
commit | 18cd63a548afa1abcddc86a998fdefa3b4cc60c1 (patch) | |
tree | 20abe577307ce6d072900f0b98fee57e06133eea /rows.go | |
parent | bef49e40eec508a6413e80ee5df7df52f7827424 (diff) |
This is a breaking change closes #1332 (#1333)
This use `InsertRows` instead of `InsertRow`, and using `InsertCols` instead of `InsertCol`
Diffstat (limited to 'rows.go')
-rw-r--r-- | rows.go | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -622,21 +622,27 @@ func (f *File) RemoveRow(sheet string, row int) error { return f.adjustHelper(sheet, rows, row, -1) } -// InsertRow provides a function to insert a new row after given Excel row -// number starting from 1. For example, create a new row before row 3 in -// Sheet1: +// InsertRows provides a function to insert new rows after the given Excel row +// number starting from 1 and number of rows. For example, create two rows +// before row 3 in Sheet1: // -// err := f.InsertRow("Sheet1", 3) +// err := f.InsertRows("Sheet1", 3, 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) InsertRow(sheet string, row int) error { +func (f *File) InsertRows(sheet string, row, n int) error { if row < 1 { return newInvalidRowNumberError(row) } - return f.adjustHelper(sheet, rows, row, 1) + if row >= TotalRows || n >= TotalRows { + return ErrMaxRows + } + if n < 1 { + return ErrParameterInvalid + } + return f.adjustHelper(sheet, rows, row, n) } // DuplicateRow inserts a copy of specified row (by its Excel row number) below |