summaryrefslogtreecommitdiff
path: root/excelize.go
diff options
context:
space:
mode:
authorVeniamin Albaev <albenik@gmail.com>2018-12-26 08:33:40 +0300
committerxuri <xuri.me@gmail.com>2018-12-26 13:33:40 +0800
commit7b7ca99f5d570c30f7eee92c38c5e632b7815239 (patch)
tree280ea5f79cc5875232044c81dd57bc3f344f3de1 /excelize.go
parent9b8baf75ad7613dba24635b4c66791e404c6b7d5 (diff)
Duplicate row (#317)
* go mod tidy applied * File.DuplicateRow() method added
Diffstat (limited to 'excelize.go')
-rw-r--r--excelize.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/excelize.go b/excelize.go
index 4b4aa32..b162b79 100644
--- a/excelize.go
+++ b/excelize.go
@@ -238,18 +238,19 @@ func (f *File) adjustRowDimensions(xlsx *xlsxWorksheet, rowIndex, offset int) {
}
for i, r := range xlsx.SheetData.Row {
if r.R >= rowIndex {
- xlsx.SheetData.Row[i].R += offset
- for k, v := range xlsx.SheetData.Row[i].C {
- axis := v.R
- col := string(strings.Map(letterOnlyMapF, axis))
- row, _ := strconv.Atoi(strings.Map(intOnlyMapF, axis))
- xAxis := row + offset
- xlsx.SheetData.Row[i].C[k].R = col + strconv.Itoa(xAxis)
- }
+ f.ajustSingleRowDimensions(&xlsx.SheetData.Row[i], offset)
}
}
}
+func (f *File) ajustSingleRowDimensions(r *xlsxRow, offset int) {
+ r.R += offset
+ 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)
+ }
+}
+
// adjustHyperlinks provides a function to update hyperlinks when inserting or
// deleting rows or columns.
func (f *File) adjustHyperlinks(sheet string, column, rowIndex, offset int) {