diff --git a/cell_test.go b/cell_test.go
index 1efbc5a..60f8751 100644
--- a/cell_test.go
+++ b/cell_test.go
@@ -110,7 +110,7 @@ func ExampleFile_SetCellFloat() {
f := NewFile()
var x = 3.14159265
if err := f.SetCellFloat("Sheet1", "A1", x, 2, 64); err != nil {
- fmt.Println(err)
+ println(err.Error())
}
val, _ := f.GetCellValue("Sheet1", "A1")
fmt.Println(val)
diff --git a/excelize_test.go b/excelize_test.go
index ea82828..c7f5cad 100644
--- a/excelize_test.go
+++ b/excelize_test.go
@@ -1259,7 +1259,7 @@ func fillCells(f *File, sheet string, colCount, rowCount int) {
for row := 1; row <= rowCount; row++ {
cell, _ := CoordinatesToCellName(col, row)
if err := f.SetCellStr(sheet, cell, cell); err != nil {
- panic(err)
+ println(err.Error())
}
}
}
diff --git a/file_test.go b/file_test.go
index 97ff720..8c5050c 100644
--- a/file_test.go
+++ b/file_test.go
@@ -12,18 +12,17 @@ func BenchmarkWrite(b *testing.B) {
for col := 1; col <= 20; col++ {
val, err := CoordinatesToCellName(col, row)
if err != nil {
- panic(err)
+ b.Error(err)
}
if err := f.SetCellDefault("Sheet1", val, s); err != nil {
- panic(err)
+ b.Error(err)
}
}
}
// Save xlsx file by the given path.
err := f.SaveAs("./test.xlsx")
if err != nil {
- panic(err)
+ b.Error(err)
}
}
-
}
diff --git a/cellmerged.go b/merge.go
similarity index 100%
rename from cellmerged.go
rename to merge.go
diff --git a/cellmerged_test.go b/merge_test.go
similarity index 100%
rename from cellmerged_test.go
rename to merge_test.go
diff --git a/rows.go b/rows.go
index d24b1a6..40972ae 100644
--- a/rows.go
+++ b/rows.go
@@ -63,7 +63,6 @@ type Rows struct {
err error
curRow, totalRow, stashRow int
sheet string
- stashColumn []string
rows []xlsxRow
f *File
decoder *xml.Decoder
@@ -111,7 +110,6 @@ func (rows *Rows) Columns() ([]string, error) {
}
if row > rows.curRow {
rows.stashRow = row - 1
- rows.stashColumn = columns
return columns, err
}
}
@@ -153,12 +151,19 @@ func (err ErrSheetNotExist) Error() string {
// Rows return a rows iterator. For example:
//
// rows, err := f.Rows("Sheet1")
+// if err != nil {
+// println(err.Error())
+// return
+// }
// for rows.Next() {
// row, err := rows.Columns()
+// if err != nil {
+// println(err.Error())
+// }
// for _, colCell := range row {
-// fmt.Print(colCell, "\t")
+// print(colCell, "\t")
// }
-// fmt.Println()
+// println()
// }
//
func (f *File) Rows(sheet string) (*Rows, error) {
diff --git a/rows_test.go b/rows_test.go
index 1127bb1..9377d5e 100644
--- a/rows_test.go
+++ b/rows_test.go
@@ -143,6 +143,7 @@ func TestColumns(t *testing.T) {
rows.decoder = f.xmlNewDecoder(bytes.NewReader([]byte(`1
`)))
rows.curRow = 1
_, err = rows.Columns()
+ assert.NoError(t, err)
rows.decoder = f.xmlNewDecoder(bytes.NewReader([]byte(`1
B
`)))
rows.stashRow, rows.curRow = 0, 1
diff --git a/sheet.go b/sheet.go
index 2654b8f..19b90c6 100644
--- a/sheet.go
+++ b/sheet.go
@@ -339,12 +339,12 @@ func (f *File) GetSheetIndex(name string) int {
// GetSheetMap provides a function to get worksheet name and index map of XLSX.
// For example:
//
-// f, err := excelize.OpenFile("./Book1.xlsx")
+// f, err := excelize.OpenFile("Book1.xlsx")
// if err != nil {
// return
// }
// for index, name := range f.GetSheetMap() {
-// fmt.Println(index, name)
+// println(index, name)
// }
//
func (f *File) GetSheetMap() map[int]string {
diff --git a/sheet_test.go b/sheet_test.go
index 7a58248..a03066a 100644
--- a/sheet_test.go
+++ b/sheet_test.go
@@ -19,7 +19,7 @@ func ExampleFile_SetPageLayout() {
"Sheet1",
excelize.PageLayoutOrientation(excelize.OrientationLandscape),
); err != nil {
- panic(err)
+ println(err.Error())
}
if err := f.SetPageLayout(
"Sheet1",
@@ -27,7 +27,7 @@ func ExampleFile_SetPageLayout() {
excelize.FitToHeight(2),
excelize.FitToWidth(2),
); err != nil {
- panic(err)
+ println(err.Error())
}
// Output:
}
@@ -41,17 +41,17 @@ func ExampleFile_GetPageLayout() {
fitToWidth excelize.FitToWidth
)
if err := f.GetPageLayout("Sheet1", &orientation); err != nil {
- panic(err)
+ println(err.Error())
}
if err := f.GetPageLayout("Sheet1", &paperSize); err != nil {
- panic(err)
+ println(err.Error())
}
if err := f.GetPageLayout("Sheet1", &fitToHeight); err != nil {
- panic(err)
+ println(err.Error())
}
if err := f.GetPageLayout("Sheet1", &fitToWidth); err != nil {
- panic(err)
+ println(err.Error())
}
fmt.Println("Defaults:")
fmt.Printf("- orientation: %q\n", orientation)
diff --git a/sheetpr_test.go b/sheetpr_test.go
index d1ae2f1..6a35a6e 100644
--- a/sheetpr_test.go
+++ b/sheetpr_test.go
@@ -40,7 +40,7 @@ func ExampleFile_SetSheetPrOptions() {
excelize.AutoPageBreaks(true),
excelize.OutlineSummaryBelow(false),
); err != nil {
- panic(err)
+ println(err.Error())
}
// Output:
}
@@ -66,7 +66,7 @@ func ExampleFile_GetSheetPrOptions() {
&autoPageBreaks,
&outlineSummaryBelow,
); err != nil {
- panic(err)
+ println(err.Error())
}
fmt.Println("Defaults:")
fmt.Printf("- codeName: %q\n", codeName)
@@ -189,7 +189,7 @@ func ExampleFile_SetPageMargins() {
excelize.PageMarginRight(1.0),
excelize.PageMarginTop(1.0),
); err != nil {
- panic(err)
+ println(err.Error())
}
// Output:
}
@@ -215,7 +215,7 @@ func ExampleFile_GetPageMargins() {
&marginRight,
&marginTop,
); err != nil {
- panic(err)
+ println(err.Error())
}
fmt.Println("Defaults:")
fmt.Println("- marginBottom:", marginBottom)
diff --git a/sheetview_test.go b/sheetview_test.go
index e45b8ce..8412002 100644
--- a/sheetview_test.go
+++ b/sheetview_test.go
@@ -47,7 +47,7 @@ func ExampleFile_SetSheetViewOptions() {
excelize.ZoomScale(80),
excelize.TopLeftCell("C3"),
); err != nil {
- panic(err)
+ println(err.Error())
}
var zoomScale excelize.ZoomScale
@@ -55,22 +55,22 @@ func ExampleFile_SetSheetViewOptions() {
fmt.Println("- zoomScale: 80")
if err := f.SetSheetViewOptions(sheet, 0, excelize.ZoomScale(500)); err != nil {
- panic(err)
+ println(err.Error())
}
if err := f.GetSheetViewOptions(sheet, 0, &zoomScale); err != nil {
- panic(err)
+ println(err.Error())
}
fmt.Println("Used out of range value:")
fmt.Println("- zoomScale:", zoomScale)
if err := f.SetSheetViewOptions(sheet, 0, excelize.ZoomScale(123)); err != nil {
- panic(err)
+ println(err.Error())
}
if err := f.GetSheetViewOptions(sheet, 0, &zoomScale); err != nil {
- panic(err)
+ println(err.Error())
}
fmt.Println("Used correct value:")
@@ -111,7 +111,7 @@ func ExampleFile_GetSheetViewOptions() {
&zoomScale,
&topLeftCell,
); err != nil {
- panic(err)
+ println(err.Error())
}
fmt.Println("Default:")
@@ -125,27 +125,27 @@ func ExampleFile_GetSheetViewOptions() {
fmt.Println("- topLeftCell:", `"`+topLeftCell+`"`)
if err := f.SetSheetViewOptions(sheet, 0, excelize.TopLeftCell("B2")); err != nil {
- panic(err)
+ println(err.Error())
}
if err := f.GetSheetViewOptions(sheet, 0, &topLeftCell); err != nil {
- panic(err)
+ println(err.Error())
}
if err := f.SetSheetViewOptions(sheet, 0, excelize.ShowGridLines(false)); err != nil {
- panic(err)
+ println(err.Error())
}
if err := f.GetSheetViewOptions(sheet, 0, &showGridLines); err != nil {
- panic(err)
+ println(err.Error())
}
if err := f.SetSheetViewOptions(sheet, 0, excelize.ShowZeros(false)); err != nil {
- panic(err)
+ println(err.Error())
}
if err := f.GetSheetViewOptions(sheet, 0, &showZeros); err != nil {
- panic(err)
+ println(err.Error())
}
fmt.Println("After change:")
diff --git a/sparkline_test.go b/sparkline_test.go
index dca32e9..45bf386 100644
--- a/sparkline_test.go
+++ b/sparkline_test.go
@@ -298,12 +298,12 @@ func prepareSparklineDataset() *File {
f.NewSheet("Sheet3")
for row, data := range sheet2 {
if err := f.SetSheetRow("Sheet2", fmt.Sprintf("A%d", row+1), &data); err != nil {
- panic(err)
+ println(err.Error())
}
}
for row, data := range sheet3 {
if err := f.SetSheetRow("Sheet3", fmt.Sprintf("A%d", row+1), &data); err != nil {
- panic(err)
+ println(err.Error())
}
}
return f