summaryrefslogtreecommitdiff
path: root/cell.go
diff options
context:
space:
mode:
Diffstat (limited to 'cell.go')
-rw-r--r--cell.go44
1 files changed, 16 insertions, 28 deletions
diff --git a/cell.go b/cell.go
index a452215..86c3567 100644
--- a/cell.go
+++ b/cell.go
@@ -6,13 +6,9 @@ import (
"strings"
)
-// GetCellValue provides function to get formatted value from cell by given
-// sheet index and axis in XLSX file. If it is possible to apply a format to the
-// cell value, it will do so, if not then an error will be returned, along with
-// the raw value of the cell.
-func (f *File) GetCellValue(sheet, axis string) string {
- xlsx := f.workSheetReader(sheet)
- axis = strings.ToUpper(axis)
+// mergeCellsParser provides function to check merged cells in worksheet by
+// given axis.
+func (f *File) mergeCellsParser(xlsx *xlsxWorksheet, axis string) {
if xlsx.MergeCells != nil {
for i := 0; i < len(xlsx.MergeCells.Cells); i++ {
if checkCellInArea(axis, xlsx.MergeCells.Cells[i].Ref) {
@@ -20,6 +16,16 @@ func (f *File) GetCellValue(sheet, axis string) string {
}
}
}
+}
+
+// GetCellValue provides function to get formatted value from cell by given
+// sheet index and axis in XLSX file. If it is possible to apply a format to the
+// cell value, it will do so, if not then an error will be returned, along with
+// the raw value of the cell.
+func (f *File) GetCellValue(sheet, axis string) string {
+ xlsx := f.workSheetReader(sheet)
+ axis = strings.ToUpper(axis)
+ f.mergeCellsParser(xlsx, axis)
row, _ := strconv.Atoi(strings.Map(intOnlyMapF, axis))
xAxis := row - 1
rows := len(xlsx.SheetData.Row)
@@ -78,13 +84,7 @@ func (f *File) formattedValue(s int, v string) string {
func (f *File) GetCellFormula(sheet, axis string) string {
xlsx := f.workSheetReader(sheet)
axis = strings.ToUpper(axis)
- if xlsx.MergeCells != nil {
- for i := 0; i < len(xlsx.MergeCells.Cells); i++ {
- if checkCellInArea(axis, xlsx.MergeCells.Cells[i].Ref) {
- axis = strings.Split(xlsx.MergeCells.Cells[i].Ref, ":")[0]
- }
- }
- }
+ f.mergeCellsParser(xlsx, axis)
row, _ := strconv.Atoi(strings.Map(intOnlyMapF, axis))
xAxis := row - 1
rows := len(xlsx.SheetData.Row)
@@ -118,13 +118,7 @@ func (f *File) GetCellFormula(sheet, axis string) string {
func (f *File) SetCellFormula(sheet, axis, formula string) {
xlsx := f.workSheetReader(sheet)
axis = strings.ToUpper(axis)
- if xlsx.MergeCells != nil {
- for i := 0; i < len(xlsx.MergeCells.Cells); i++ {
- if checkCellInArea(axis, xlsx.MergeCells.Cells[i].Ref) {
- axis = strings.Split(xlsx.MergeCells.Cells[i].Ref, ":")[0]
- }
- }
- }
+ f.mergeCellsParser(xlsx, axis)
col := string(strings.Map(letterOnlyMapF, axis))
row, _ := strconv.Atoi(strings.Map(intOnlyMapF, axis))
xAxis := row - 1
@@ -151,13 +145,7 @@ func (f *File) SetCellFormula(sheet, axis, formula string) {
func (f *File) SetCellHyperLink(sheet, axis, link string) {
xlsx := f.workSheetReader(sheet)
axis = strings.ToUpper(axis)
- if xlsx.MergeCells != nil {
- for i := 0; i < len(xlsx.MergeCells.Cells); i++ {
- if checkCellInArea(axis, xlsx.MergeCells.Cells[i].Ref) {
- axis = strings.Split(xlsx.MergeCells.Cells[i].Ref, ":")[0]
- }
- }
- }
+ f.mergeCellsParser(xlsx, axis)
rID := f.addSheetRelationships(sheet, SourceRelationshipHyperLink, link, "External")
hyperlink := xlsxHyperlink{
Ref: axis,