浏览代码

Fix checkRow() out of range

Ri Xu 9 年之前
父节点
当前提交
7bd8d9ee5b
共有 2 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      excelize.go
  2. 二进制
      test/Workbook1.xlsx

+ 3 - 1
excelize.go

@@ -42,7 +42,6 @@ func SetCellInt(file []FileList, sheet string, axis string, value int) []FileLis
 	cell := yAxis + 1
 
 	xlsx = checkRow(xlsx)
-
 	xlsx = completeRow(xlsx, rows, cell)
 	xlsx = completeCol(xlsx, rows, cell)
 
@@ -173,6 +172,9 @@ func replaceWorkSheetsRelationshipsNameSpace(workbookMarshal string) string {
 func checkRow(xlsx xlsxWorksheet) xlsxWorksheet {
 	for k, v := range xlsx.SheetData.Row {
 		lenCol := len(v.C)
+		if lenCol < 1 {
+			continue
+		}
 		endR := getColIndex(v.C[lenCol-1].R)
 		endRow := getRowIndex(v.C[lenCol-1].R)
 		endCol := titleToNumber(endR)

二进制
test/Workbook1.xlsx