Permalink
Browse files

Merge pull request #334 from albenik/duplicate_row

Resolve #333 New feature: File.DuplicateRowTo() duplicate row to a specified row position
  • Loading branch information...
xuri committed Jan 11, 2019
2 parents b0ed4c1 + 725c1a0 commit 7f1323f7ac7037670848fb8ab103ace59748c28e
Showing with 434 additions and 173 deletions.
  1. +3 −2 datavalidation_test.go
  2. +5 −7 excelize.go
  3. +384 −140 excelize_test.go
  4. +1 −2 go.mod
  5. +4 −2 go.sum
  6. +37 −20 rows.go
@@ -10,13 +10,14 @@
package excelize

import (
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
)

func TestDataValidation(t *testing.T) {
const resultFile = "./test/TestDataValidation.xlsx"
resultFile := filepath.Join("test", "TestDataValidation.xlsx")

xlsx := NewFile()

@@ -50,7 +51,7 @@ func TestDataValidation(t *testing.T) {
}

func TestDataValidationError(t *testing.T) {
const resultFile = "./test/TestDataValidationError.xlsx"
resultFile := filepath.Join("test", "TestDataValidationError.xlsx")

xlsx := NewFile()
xlsx.SetCellStr("Sheet1", "E1", "E1")
@@ -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)
}
}

Oops, something went wrong.

0 comments on commit 7f1323f

Please sign in to comment.