summaryrefslogtreecommitdiff
path: root/excelize.go
diff options
context:
space:
mode:
authorRi Xu <xuri.me@gmail.com>2017-05-24 14:17:35 +0800
committerRi Xu <xuri.me@gmail.com>2017-05-24 14:17:35 +0800
commitdea57dd0aeb5507dc4f58de48b261d4013364232 (patch)
treeb6c8b73affc39acb5a4305eac86cd48792446b44 /excelize.go
parent70f6328150aa954cd9721e90883f001ea005c1ee (diff)
Code optimize.
Diffstat (limited to 'excelize.go')
-rw-r--r--excelize.go26
1 files changed, 4 insertions, 22 deletions
diff --git a/excelize.go b/excelize.go
index 18d08e2..8061884 100644
--- a/excelize.go
+++ b/excelize.go
@@ -123,13 +123,7 @@ func (f *File) workSheetReader(sheet string) *xlsxWorksheet {
func (f *File) SetCellInt(sheet, axis string, value int) {
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
@@ -150,13 +144,7 @@ func (f *File) SetCellInt(sheet, axis string, value int) {
func (f *File) SetCellStr(sheet, axis, value 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)
if len(value) > 32767 {
value = value[0:32767]
}
@@ -189,13 +177,7 @@ func (f *File) SetCellStr(sheet, axis, value string) {
func (f *File) SetCellDefault(sheet, axis, value 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
@@ -272,7 +254,7 @@ func completeRow(xlsx *xlsxWorksheet, row, cell int) {
// continuous in a worksheet of XML.
func checkSheet(xlsx *xlsxWorksheet) {
row := len(xlsx.SheetData.Row)
- if row > 1 {
+ if row >= 1 {
lastRow := xlsx.SheetData.Row[row-1].R
if lastRow >= row {
row = lastRow