From 821632cf89422b9955160a3af7f28f05a12f70f8 Mon Sep 17 00:00:00 2001 From: xuri Date: Wed, 12 Jun 2019 08:10:33 +0800 Subject: Fix #424, refactor merged cells adjuster --- table.go | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'table.go') diff --git a/table.go b/table.go index f3819d3..3d8d402 100644 --- a/table.go +++ b/table.go @@ -115,29 +115,24 @@ func (f *File) addSheetTable(sheet string, rID int) { // addTable provides a function to add table by given worksheet name, // coordinate area and format set. -func (f *File) addTable(sheet, tableXML string, hcol, hrow, vcol, vrow, i int, formatSet *formatTable) error { +func (f *File) addTable(sheet, tableXML string, x1, y1, x2, y2, i int, formatSet *formatTable) error { // Correct the minimum number of rows, the table at least two lines. - if hrow == vrow { - vrow++ + if y1 == y2 { + y2++ } // Correct table reference coordinate area, such correct C1:B3 to B1:C3. - hcell, err := CoordinatesToCellName(hcol, hrow) + ref, err := f.coordinatesToAreaRef([]int{x1, y1, x2, y2}) if err != nil { return err } - vcell, err := CoordinatesToCellName(vcol, vrow) - if err != nil { - return err - } - ref := hcell + ":" + vcell var tableColumn []*xlsxTableColumn idx := 0 - for i := hcol; i <= vcol; i++ { + for i := x1; i <= x2; i++ { idx++ - cell, err := CoordinatesToCellName(i, hrow) + cell, err := CoordinatesToCellName(i, y1) if err != nil { return err } -- cgit v1.2.1