diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml
index 13913aa..320e3da 100644
--- a/.github/workflows/go.yml
+++ b/.github/workflows/go.yml
@@ -5,7 +5,7 @@ jobs:
test:
strategy:
matrix:
- go-version: [1.15.x, 1.16.x]
+ go-version: [1.15.x, 1.16.x, 1.17.x]
os: [ubuntu-latest, macos-latest, windows-latest]
targetplatform: [x86, x64]
diff --git a/cell_test.go b/cell_test.go
index 0af0097..91dc4fd 100644
--- a/cell_test.go
+++ b/cell_test.go
@@ -181,6 +181,7 @@ func TestGetCellValue(t *testing.T) {
// Test get cell value without r attribute of the row.
f := NewFile()
sheetData := `%s`
+
f.Sheet.Delete("xl/worksheets/sheet1.xml")
f.Pkg.Store("xl/worksheets/sheet1.xml", []byte(fmt.Sprintf(sheetData, `A3
A4B4
A7B7
A8B8
`)))
f.checked = nil
@@ -196,24 +197,34 @@ func TestGetCellValue(t *testing.T) {
cols, err := f.GetCols("Sheet1")
assert.Equal(t, [][]string{{"", "", "A3", "A4", "", "", "A7", "A8"}, {"", "", "", "B4", "", "", "B7", "B8"}}, cols)
assert.NoError(t, err)
+
f.Sheet.Delete("xl/worksheets/sheet1.xml")
f.Pkg.Store("xl/worksheets/sheet1.xml", []byte(fmt.Sprintf(sheetData, `A2
B2
`)))
f.checked = nil
cell, err := f.GetCellValue("Sheet1", "A2")
assert.Equal(t, "A2", cell)
assert.NoError(t, err)
+
f.Sheet.Delete("xl/worksheets/sheet1.xml")
f.Pkg.Store("xl/worksheets/sheet1.xml", []byte(fmt.Sprintf(sheetData, `A2
B2
`)))
f.checked = nil
rows, err = f.GetRows("Sheet1")
assert.Equal(t, [][]string{nil, {"A2", "B2"}}, rows)
assert.NoError(t, err)
+
f.Sheet.Delete("xl/worksheets/sheet1.xml")
f.Pkg.Store("xl/worksheets/sheet1.xml", []byte(fmt.Sprintf(sheetData, `A1
B1
`)))
f.checked = nil
rows, err = f.GetRows("Sheet1")
assert.Equal(t, [][]string{{"A1", "B1"}}, rows)
assert.NoError(t, err)
+
+ f.Sheet.Delete("xl/worksheets/sheet1.xml")
+ f.Pkg.Store("xl/worksheets/sheet1.xml", []byte(fmt.Sprintf(sheetData, `A3
A4B4
A7B7
A8B8
`)))
+ f.checked = nil
+ rows, err = f.GetRows("Sheet1")
+ assert.Equal(t, [][]string{{"A3"}, {"A4", "B4"}, nil, nil, nil, nil, {"A7", "B7"}, {"A8", "B8"}}, rows)
+ assert.NoError(t, err)
}
func TestGetCellFormula(t *testing.T) {
diff --git a/col.go b/col.go
index d2eba8b..1e0c333 100644
--- a/col.go
+++ b/col.go
@@ -399,8 +399,8 @@ func (f *File) SetColOutlineLevel(sheet, col string, level uint8) error {
// SetColStyle provides a function to set style of columns by given worksheet
// name, columns range and style ID. Note that this will overwrite the
-// existing styles for the cell, it won't append or merge style with existing
-// styles.
+// existing styles for the columns, it won't append or merge style with
+// existing styles.
//
// For example set style of column H on Sheet1:
//
diff --git a/excelize.go b/excelize.go
index fafa57f..6e4e4d9 100644
--- a/excelize.go
+++ b/excelize.go
@@ -238,7 +238,7 @@ func checkSheet(ws *xlsxWorksheet) {
sheetData := xlsxSheetData{Row: make([]xlsxRow, row)}
row = 0
for _, r := range ws.SheetData.Row {
- if r.R == row {
+ if r.R == row && row > 0 {
sheetData.Row[r.R-1].C = append(sheetData.Row[r.R-1].C, r.C...)
continue
}
diff --git a/rows.go b/rows.go
index fb03bba..bfd7d13 100644
--- a/rows.go
+++ b/rows.go
@@ -24,8 +24,12 @@ import (
)
// GetRows return all the rows in a sheet by given worksheet name
-// (case sensitive). GetRows fetched the rows with value or formula cells,
-// the tail continuously empty cell will be skipped. For example:
+// (case sensitive), returned as a two-dimensional array, where the value of
+// the cell is converted to the string type. If the cell format can be
+// applied to the value of the cell, the applied value will be used,
+// otherwise the original value will be used. GetRows fetched the rows with
+// value or formula cells, the tail continuously empty cell will be skipped.
+// For example:
//
// rows, err := f.GetRows("Sheet1")
// if err != nil {
@@ -111,7 +115,7 @@ func (rows *Rows) Columns() ([]string, error) {
}
case xml.EndElement:
rowIterator.inElement = xmlElement.Name.Local
- if rowIterator.row == 0 {
+ if rowIterator.row == 0 && rowIterator.rows.curRow > 1 {
rowIterator.row = rowIterator.rows.curRow
}
if rowIterator.inElement == "row" && rowIterator.row+1 < rowIterator.rows.curRow {
@@ -720,9 +724,9 @@ func checkRow(ws *xlsxWorksheet) error {
return nil
}
-// SetRowStyle provides a function to set style of rows by given worksheet
-// name, row range and style ID. Note that this will overwrite the existing
-// styles for the cell, it won't append or merge style with existing styles.
+// SetRowStyle provides a function to set the style of rows by given worksheet
+// name, row range, and style ID. Note that this will overwrite the existing
+// styles for the rows, it won't append or merge style with existing styles.
//
// For example set style of row 1 on Sheet1:
//
diff --git a/styles.go b/styles.go
index d925ea9..31fa7fb 100644
--- a/styles.go
+++ b/styles.go
@@ -2603,8 +2603,8 @@ func (f *File) GetCellStyle(sheet, axis string) (int, error) {
// SetCellStyle provides a function to add style attribute for cells by given
// worksheet name, coordinate area and style ID. Note that diagonalDown and
// diagonalUp type border should be use same color in the same coordinate
-// area, this will overwrite the existing styles for the cell, it won't
-// append or merge style with existing styles.
+// area. SetCellStyle will overwrite the existing styles for the cell, it
+// won't append or merge style with existing styles.
//
// For example create a borders of cell H9 on Sheet1:
//