From 555e2ba9a82d6974077681c7ab34ce0fa93d351d Mon Sep 17 00:00:00 2001 From: Ri Xu Date: Tue, 27 Jun 2017 17:53:06 +0800 Subject: - Make function `TitleToNumber()` exportable, note that function `ToAlphaString()` return value calculation changes, get more info from go doc. Relate issue #63; - Readme and go doc updated --- table.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'table.go') diff --git a/table.go b/table.go index 5c8325b..1417cd9 100644 --- a/table.go +++ b/table.go @@ -47,12 +47,12 @@ func (f *File) AddTable(sheet, hcell, vcell, format string) { hcol := string(strings.Map(letterOnlyMapF, hcell)) hrow, _ := strconv.Atoi(strings.Map(intOnlyMapF, hcell)) hyAxis := hrow - 1 - hxAxis := titleToNumber(hcol) + hxAxis := TitleToNumber(hcol) vcol := string(strings.Map(letterOnlyMapF, vcell)) vrow, _ := strconv.Atoi(strings.Map(intOnlyMapF, vcell)) vyAxis := vrow - 1 - vxAxis := titleToNumber(vcol) + vxAxis := TitleToNumber(vcol) if vxAxis < hxAxis { vxAxis, hxAxis = hxAxis, vxAxis } @@ -108,12 +108,12 @@ func (f *File) addTable(sheet, tableXML string, hxAxis, hyAxis, vxAxis, vyAxis, vyAxis++ } // Correct table reference coordinate area, such correct C1:B3 to B1:C3. - ref := ToAlphaString(hxAxis+1) + strconv.Itoa(hyAxis+1) + ":" + ToAlphaString(vxAxis+1) + strconv.Itoa(vyAxis+1) + ref := ToAlphaString(hxAxis) + strconv.Itoa(hyAxis+1) + ":" + ToAlphaString(vxAxis) + strconv.Itoa(vyAxis+1) tableColumn := []*xlsxTableColumn{} idx := 0 for i := hxAxis; i <= vxAxis; i++ { idx++ - cell := ToAlphaString(i+1) + strconv.Itoa(hyAxis+1) + cell := ToAlphaString(i) + strconv.Itoa(hyAxis+1) name := f.GetCellValue(sheet, cell) if _, err := strconv.Atoi(name); err == nil { f.SetCellStr(sheet, cell, name) @@ -240,12 +240,12 @@ func (f *File) AutoFilter(sheet, hcell, vcell, format string) error { hcol := string(strings.Map(letterOnlyMapF, hcell)) hrow, _ := strconv.Atoi(strings.Map(intOnlyMapF, hcell)) hyAxis := hrow - 1 - hxAxis := titleToNumber(hcol) + hxAxis := TitleToNumber(hcol) vcol := string(strings.Map(letterOnlyMapF, vcell)) vrow, _ := strconv.Atoi(strings.Map(intOnlyMapF, vcell)) vyAxis := vrow - 1 - vxAxis := titleToNumber(vcol) + vxAxis := TitleToNumber(vcol) if vxAxis < hxAxis { vxAxis, hxAxis = hxAxis, vxAxis @@ -254,7 +254,7 @@ func (f *File) AutoFilter(sheet, hcell, vcell, format string) error { if vyAxis < hyAxis { vyAxis, hyAxis = hyAxis, vyAxis } - ref := ToAlphaString(hxAxis+1) + strconv.Itoa(hyAxis+1) + ":" + ToAlphaString(vxAxis+1) + strconv.Itoa(vyAxis+1) + ref := ToAlphaString(hxAxis) + strconv.Itoa(hyAxis+1) + ":" + ToAlphaString(vxAxis) + strconv.Itoa(vyAxis+1) refRange := vxAxis - hxAxis err := f.autoFilter(sheet, ref, refRange, hxAxis, formatSet) return err @@ -275,7 +275,7 @@ func (f *File) autoFilter(sheet, ref string, refRange, hxAxis int, formatSet *fo if formatSet.Column == "" || formatSet.Expression == "" { return nil } - col := titleToNumber(formatSet.Column) + col := TitleToNumber(formatSet.Column) offset := col - hxAxis if offset < 0 || offset > refRange { return fmt.Errorf("Incorrect index of column '%s'", formatSet.Column) -- cgit v1.2.1