diff options
author | Veniamin Albaev <albenik@gmail.com> | 2018-12-27 17:28:28 +0300 |
---|---|---|
committer | Veniamin Albaev <albenik@gmail.com> | 2019-01-10 14:29:19 +0300 |
commit | 725c1a0c40971282ff924f4802a57e4c17431691 (patch) | |
tree | a2ca4ea8afe8f48ddb11ad3dc7744b59a497ddc0 /excelize.go | |
parent | b0ed4c12d2cced29d82e8a4af47f7b42f555ca8c (diff) |
New feature: File.DuplicateRowTo() duplicate row to specified row position.
DuplicateRowTo() is similar to DuplicateRow() but copies specified row not just after specified source row
but to any other specified position below or above source row.
Also I made minor modifications of tests: using filepath.Join() instead of direct unix-way paths strings
to avoid possible tests fails on other OS.
Diffstat (limited to 'excelize.go')
-rw-r--r-- | excelize.go | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/excelize.go b/excelize.go index 61f6dd6..32f0451 100644 --- a/excelize.go +++ b/excelize.go @@ -238,18 +238,16 @@ func (f *File) adjustRowDimensions(xlsx *xlsxWorksheet, rowIndex, offset int) { } for i, r := range xlsx.SheetData.Row { if r.R >= rowIndex { - f.ajustSingleRowDimensions(&xlsx.SheetData.Row[i], offset) + f.ajustSingleRowDimensions(&xlsx.SheetData.Row[i], r.R+offset) } } } -// ajustSingleRowDimensions provides a function to ajust single row -// dimensions. -func (f *File) ajustSingleRowDimensions(r *xlsxRow, offset int) { - r.R += offset +// ajustSingleRowDimensions provides a function to ajust single row dimensions. +func (f *File) ajustSingleRowDimensions(r *xlsxRow, row int) { + r.R = row for i, col := range r.C { - row, _ := strconv.Atoi(strings.Map(intOnlyMapF, col.R)) - r.C[i].R = string(strings.Map(letterOnlyMapF, col.R)) + strconv.Itoa(row+offset) + r.C[i].R = string(strings.Map(letterOnlyMapF, col.R)) + strconv.Itoa(r.R) } } |