summaryrefslogtreecommitdiff
path: root/cell.go
diff options
context:
space:
mode:
Diffstat (limited to 'cell.go')
-rw-r--r--cell.go25
1 files changed, 7 insertions, 18 deletions
diff --git a/cell.go b/cell.go
index 5d26338..bb363aa 100644
--- a/cell.go
+++ b/cell.go
@@ -455,27 +455,16 @@ func (f *File) SetCellDefault(sheet, axis, value string) {
// checkCellInArea provides function to determine if a given coordinate is
// within an area.
func checkCellInArea(cell, area string) bool {
- result := false
cell = strings.ToUpper(cell)
- col := string(strings.Map(letterOnlyMapF, cell))
- row, _ := strconv.Atoi(strings.Map(intOnlyMapF, cell))
- xAxis := row - 1
- yAxis := TitleToNumber(col)
+ area = strings.ToUpper(area)
ref := strings.Split(area, ":")
- hCol := string(strings.Map(letterOnlyMapF, ref[0]))
- hRow, _ := strconv.Atoi(strings.Map(intOnlyMapF, ref[0]))
- hyAxis := hRow - 1
- hxAxis := TitleToNumber(hCol)
+ from := ref[0]
+ to := ref[1]
- vCol := string(strings.Map(letterOnlyMapF, ref[1]))
- vRow, _ := strconv.Atoi(strings.Map(intOnlyMapF, ref[1]))
- vyAxis := vRow - 1
- vxAxis := TitleToNumber(vCol)
-
- if hxAxis <= yAxis && yAxis <= vxAxis && hyAxis <= xAxis && xAxis <= vyAxis {
- result = true
- }
+ col, row := getCellColRow(cell)
+ fromCol, fromRow := getCellColRow(from)
+ toCol, toRow := getCellColRow(to)
- return result
+ return axisLowerOrEqualThan(fromCol, col) && axisLowerOrEqualThan(col, toCol) && axisLowerOrEqualThan(fromRow, row) && axisLowerOrEqualThan(row, toRow)
}