Skip to content

Commit

Permalink
Using the specialized name in a variable and making comments clear
Browse files Browse the repository at this point in the history
- Add JSON tags for `AppProperties`, `PivotTableOption` and `PivotTableField` structure
  • Loading branch information
xuri committed Sep 17, 2022
1 parent 73cc4bd commit 3f70299
Show file tree
Hide file tree
Showing 31 changed files with 470 additions and 470 deletions.
6 changes: 3 additions & 3 deletions adjust.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ func (f *File) adjustAutoFilter(ws *xlsxWorksheet, dir adjustDirection, num, off
}

// adjustAutoFilterHelper provides a function for adjusting auto filter to
// compare and calculate cell axis by the given adjust direction, operation
// axis and offset.
// compare and calculate cell reference by the given adjust direction, operation
// reference and offset.
func (f *File) adjustAutoFilterHelper(dir adjustDirection, coordinates []int, num, offset int) []int {
if dir == rows {
if coordinates[1] >= num {
Expand Down Expand Up @@ -314,7 +314,7 @@ func (f *File) adjustMergeCells(ws *xlsxWorksheet, dir adjustDirection, num, off
}

// adjustMergeCellsHelper provides a function for adjusting merge cells to
// compare and calculate cell axis by the given pivot, operation axis and
// compare and calculate cell reference by the given pivot, operation reference and
// offset.
func (f *File) adjustMergeCellsHelper(p1, p2, num, offset int) (int, int) {
if p2 < p1 {
Expand Down
6 changes: 3 additions & 3 deletions adjust_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func TestAdjustMergeCells(t *testing.T) {
f := NewFile()
// testing adjustAutoFilter with illegal cell coordinates.
// testing adjustAutoFilter with illegal cell reference.
assert.EqualError(t, f.adjustMergeCells(&xlsxWorksheet{
MergeCells: &xlsxMergeCells{
Cells: []*xlsxMergeCell{
Expand Down Expand Up @@ -283,7 +283,7 @@ func TestAdjustAutoFilter(t *testing.T) {
Ref: "A1:A3",
},
}, rows, 1, -1))
// Test adjustAutoFilter with illegal cell coordinates.
// Test adjustAutoFilter with illegal cell reference.
assert.EqualError(t, f.adjustAutoFilter(&xlsxWorksheet{
AutoFilter: &xlsxAutoFilter{
Ref: "A:B1",
Expand Down Expand Up @@ -335,7 +335,7 @@ func TestAdjustHelper(t *testing.T) {
f.Sheet.Store("xl/worksheets/sheet2.xml", &xlsxWorksheet{
AutoFilter: &xlsxAutoFilter{Ref: "A1:B"},
})
// Test adjustHelper with illegal cell coordinates.
// Test adjustHelper with illegal cell reference.
assert.EqualError(t, f.adjustHelper("Sheet1", rows, 0, 0), newCellNameToCoordinatesError("A", newInvalidCellNameError("A")).Error())
assert.EqualError(t, f.adjustHelper("Sheet2", rows, 0, 0), newCellNameToCoordinatesError("B", newInvalidCellNameError("B")).Error())
// Test adjustHelper on not exists worksheet.
Expand Down
4 changes: 2 additions & 2 deletions calc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,7 @@ func (f *File) parseReference(ctx *calcContext, sheet, reference string) (arg fo
cr := cellRef{}
if len(tokens) == 2 { // have a worksheet name
cr.Sheet = tokens[0]
// cast to cell coordinates
// cast to cell reference
if cr.Col, cr.Row, err = CellNameToCoordinates(tokens[1]); err != nil {
// cast to column
if cr.Col, err = ColumnNameToNumber(tokens[1]); err != nil {
Expand All @@ -1428,7 +1428,7 @@ func (f *File) parseReference(ctx *calcContext, sheet, reference string) (arg fo
refs.PushBack(cr)
continue
}
// cast to cell coordinates
// cast to cell reference
if cr.Col, cr.Row, err = CellNameToCoordinates(tokens[0]); err != nil {
// cast to column
if cr.Col, err = ColumnNameToNumber(tokens[0]); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions calcchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ func (f *File) calcChainWriter() {

// deleteCalcChain provides a function to remove cell reference on the
// calculation chain.
func (f *File) deleteCalcChain(index int, axis string) {
func (f *File) deleteCalcChain(index int, cell string) {
calc := f.calcChainReader()
if calc != nil {
calc.C = xlsxCalcChainCollection(calc.C).Filter(func(c xlsxCalcChainC) bool {
return !((c.I == index && c.R == axis) || (c.I == index && axis == "") || (c.I == 0 && c.R == axis))
return !((c.I == index && c.R == cell) || (c.I == index && cell == "") || (c.I == 0 && c.R == cell))
})
}
if len(calc.C) == 0 {
Expand Down
Loading

0 comments on commit 3f70299

Please sign in to comment.