forked from p30928647/excelize
parent
f8667386dc
commit
bef49e40ee
|
@ -339,7 +339,7 @@ func TestAdjustHelper(t *testing.T) {
|
|||
assert.EqualError(t, f.adjustHelper("Sheet1", rows, 0, 0), newCellNameToCoordinatesError("A", newInvalidCellNameError("A")).Error())
|
||||
assert.EqualError(t, f.adjustHelper("Sheet2", rows, 0, 0), newCellNameToCoordinatesError("B", newInvalidCellNameError("B")).Error())
|
||||
// Test adjustHelper on not exists worksheet.
|
||||
assert.EqualError(t, f.adjustHelper("SheetN", rows, 0, 0), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.adjustHelper("SheetN", rows, 0, 0), "sheet SheetN does not exist")
|
||||
}
|
||||
|
||||
func TestAdjustCalcChain(t *testing.T) {
|
||||
|
|
|
@ -4330,7 +4330,7 @@ func TestCalcCellValue(t *testing.T) {
|
|||
// Test get calculated cell value on not exists worksheet.
|
||||
f = prepareCalcData(cellData)
|
||||
_, err = f.CalcCellValue("SheetN", "A1")
|
||||
assert.EqualError(t, err, "sheet SheetN is not exist")
|
||||
assert.EqualError(t, err, "sheet SheetN does not exist")
|
||||
// Test get calculated cell value with not support formula.
|
||||
f = prepareCalcData(cellData)
|
||||
assert.NoError(t, f.SetCellFormula("Sheet1", "A1", "=UNSUPPORT(A1)"))
|
||||
|
|
|
@ -373,7 +373,7 @@ func TestGetCellFormula(t *testing.T) {
|
|||
// Test get cell formula on not exist worksheet.
|
||||
f := NewFile()
|
||||
_, err := f.GetCellFormula("SheetN", "A1")
|
||||
assert.EqualError(t, err, "sheet SheetN is not exist")
|
||||
assert.EqualError(t, err, "sheet SheetN does not exist")
|
||||
|
||||
// Test get cell formula on no formula cell.
|
||||
assert.NoError(t, f.SetCellValue("Sheet1", "A1", true))
|
||||
|
@ -555,7 +555,7 @@ func TestGetCellRichText(t *testing.T) {
|
|||
assert.EqualError(t, err, "strconv.Atoi: parsing \"x\": invalid syntax")
|
||||
// Test set cell rich text on not exists worksheet
|
||||
_, err = f.GetCellRichText("SheetN", "A1")
|
||||
assert.EqualError(t, err, "sheet SheetN is not exist")
|
||||
assert.EqualError(t, err, "sheet SheetN does not exist")
|
||||
// Test set cell rich text with illegal cell coordinates
|
||||
_, err = f.GetCellRichText("Sheet1", "A")
|
||||
assert.EqualError(t, err, newCellNameToCoordinatesError("A", newInvalidCellNameError("A")).Error())
|
||||
|
@ -652,7 +652,7 @@ func TestSetCellRichText(t *testing.T) {
|
|||
assert.NoError(t, f.SetCellStyle("Sheet1", "A1", "A1", style))
|
||||
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestSetCellRichText.xlsx")))
|
||||
// Test set cell rich text on not exists worksheet
|
||||
assert.EqualError(t, f.SetCellRichText("SheetN", "A1", richTextRun), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.SetCellRichText("SheetN", "A1", richTextRun), "sheet SheetN does not exist")
|
||||
// Test set cell rich text with illegal cell coordinates
|
||||
assert.EqualError(t, f.SetCellRichText("Sheet1", "A", richTextRun), newCellNameToCoordinatesError("A", newInvalidCellNameError("A")).Error())
|
||||
richTextRun = []RichTextRun{{Text: strings.Repeat("s", TotalCellChars+1)}}
|
||||
|
|
|
@ -114,7 +114,7 @@ func TestAddChart(t *testing.T) {
|
|||
assert.EqualError(t, f.AddChart("Sheet1", "P1", ""), "unexpected end of JSON input")
|
||||
|
||||
// Test add chart on not exists worksheet.
|
||||
assert.EqualError(t, f.AddChart("SheetN", "P1", "{}"), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.AddChart("SheetN", "P1", "{}"), "sheet SheetN does not exist")
|
||||
|
||||
assert.NoError(t, f.AddChart("Sheet1", "P1", `{"type":"col","series":[{"name":"Sheet1!$A$30","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$30:$D$30"},{"name":"Sheet1!$A$31","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$31:$D$31"},{"name":"Sheet1!$A$32","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$32:$D$32"},{"name":"Sheet1!$A$33","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$33:$D$33"},{"name":"Sheet1!$A$34","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$34:$D$34"},{"name":"Sheet1!$A$35","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$35:$D$35"},{"name":"Sheet1!$A$36","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$36:$D$36"},{"name":"Sheet1!$A$37","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$37:$D$37"}],"format":{"x_scale":1.0,"y_scale":1.0,"x_offset":15,"y_offset":10,"print_obj":true,"lock_aspect_ratio":false,"locked":false},"legend":{"none":true,"show_legend_key":true},"title":{"name":"2D Column Chart"},"plotarea":{"show_bubble_size":true,"show_cat_name":false,"show_leader_lines":false,"show_percent":true,"show_series_name":true,"show_val":true},"show_blanks_as":"zero"}`))
|
||||
assert.NoError(t, f.AddChart("Sheet1", "X1", `{"type":"colStacked","series":[{"name":"Sheet1!$A$30","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$30:$D$30"},{"name":"Sheet1!$A$31","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$31:$D$31"},{"name":"Sheet1!$A$32","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$32:$D$32"},{"name":"Sheet1!$A$33","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$33:$D$33"},{"name":"Sheet1!$A$34","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$34:$D$34"},{"name":"Sheet1!$A$35","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$35:$D$35"},{"name":"Sheet1!$A$36","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$36:$D$36"},{"name":"Sheet1!$A$37","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$37:$D$37"}],"format":{"x_scale":1.0,"y_scale":1.0,"x_offset":15,"y_offset":10,"print_obj":true,"lock_aspect_ratio":false,"locked":false},"legend":{"position":"left","show_legend_key":false},"title":{"name":"2D Stacked Column Chart"},"plotarea":{"show_bubble_size":true,"show_cat_name":false,"show_leader_lines":false,"show_percent":true,"show_series_name":true,"show_val":true},"show_blanks_as":"zero"}`))
|
||||
|
@ -250,7 +250,7 @@ func TestDeleteChart(t *testing.T) {
|
|||
assert.NoError(t, f.DeleteChart("Sheet1", "P1"))
|
||||
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestDeleteChart.xlsx")))
|
||||
// Test delete chart on not exists worksheet.
|
||||
assert.EqualError(t, f.DeleteChart("SheetN", "A1"), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.DeleteChart("SheetN", "A1"), "sheet SheetN does not exist")
|
||||
// Test delete chart with invalid coordinates.
|
||||
assert.EqualError(t, f.DeleteChart("Sheet1", ""), newCellNameToCoordinatesError("", newInvalidCellNameError("")).Error())
|
||||
// Test delete chart on no chart worksheet.
|
||||
|
|
24
col_test.go
24
col_test.go
|
@ -94,7 +94,7 @@ func TestColsError(t *testing.T) {
|
|||
t.FailNow()
|
||||
}
|
||||
_, err = f.Cols("SheetN")
|
||||
assert.EqualError(t, err, "sheet SheetN is not exist")
|
||||
assert.EqualError(t, err, "sheet SheetN does not exist")
|
||||
assert.NoError(t, f.Close())
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ func TestGetColsError(t *testing.T) {
|
|||
t.FailNow()
|
||||
}
|
||||
_, err = f.GetCols("SheetN")
|
||||
assert.EqualError(t, err, "sheet SheetN is not exist")
|
||||
assert.EqualError(t, err, "sheet SheetN does not exist")
|
||||
assert.NoError(t, f.Close())
|
||||
|
||||
f = NewFile()
|
||||
|
@ -205,7 +205,7 @@ func TestColumnVisibility(t *testing.T) {
|
|||
|
||||
// Test get column visible on an inexistent worksheet.
|
||||
_, err = f.GetColVisible("SheetN", "F")
|
||||
assert.EqualError(t, err, "sheet SheetN is not exist")
|
||||
assert.EqualError(t, err, "sheet SheetN does not exist")
|
||||
|
||||
// Test get column visible with illegal cell coordinates.
|
||||
_, err = f.GetColVisible("Sheet1", "*")
|
||||
|
@ -215,7 +215,7 @@ func TestColumnVisibility(t *testing.T) {
|
|||
f.NewSheet("Sheet3")
|
||||
assert.NoError(t, f.SetColVisible("Sheet3", "E", false))
|
||||
assert.EqualError(t, f.SetColVisible("Sheet1", "A:-1", true), newInvalidColumnNameError("-1").Error())
|
||||
assert.EqualError(t, f.SetColVisible("SheetN", "E", false), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.SetColVisible("SheetN", "E", false), "sheet SheetN does not exist")
|
||||
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestColumnVisibility.xlsx")))
|
||||
})
|
||||
|
||||
|
@ -243,7 +243,7 @@ func TestOutlineLevel(t *testing.T) {
|
|||
|
||||
level, err = f.GetColOutlineLevel("SheetN", "A")
|
||||
assert.Equal(t, uint8(0), level)
|
||||
assert.EqualError(t, err, "sheet SheetN is not exist")
|
||||
assert.EqualError(t, err, "sheet SheetN does not exist")
|
||||
|
||||
assert.NoError(t, f.SetColWidth("Sheet2", "A", "D", 13))
|
||||
assert.EqualError(t, f.SetColWidth("Sheet2", "A", "D", MaxColumnWidth+1), ErrColumnWidth.Error())
|
||||
|
@ -253,10 +253,10 @@ func TestOutlineLevel(t *testing.T) {
|
|||
assert.EqualError(t, f.SetColOutlineLevel("Sheet1", "D", 8), ErrOutlineLevel.Error())
|
||||
assert.EqualError(t, f.SetRowOutlineLevel("Sheet1", 2, 8), ErrOutlineLevel.Error())
|
||||
// Test set row outline level on not exists worksheet.
|
||||
assert.EqualError(t, f.SetRowOutlineLevel("SheetN", 1, 4), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.SetRowOutlineLevel("SheetN", 1, 4), "sheet SheetN does not exist")
|
||||
// Test get row outline level on not exists worksheet.
|
||||
_, err = f.GetRowOutlineLevel("SheetN", 1)
|
||||
assert.EqualError(t, err, "sheet SheetN is not exist")
|
||||
assert.EqualError(t, err, "sheet SheetN does not exist")
|
||||
|
||||
// Test set and get column outline level with illegal cell coordinates.
|
||||
assert.EqualError(t, f.SetColOutlineLevel("Sheet1", "*", 1), newInvalidColumnNameError("*").Error())
|
||||
|
@ -264,7 +264,7 @@ func TestOutlineLevel(t *testing.T) {
|
|||
assert.EqualError(t, err, newInvalidColumnNameError("*").Error())
|
||||
|
||||
// Test set column outline level on not exists worksheet.
|
||||
assert.EqualError(t, f.SetColOutlineLevel("SheetN", "E", 2), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.SetColOutlineLevel("SheetN", "E", 2), "sheet SheetN does not exist")
|
||||
|
||||
assert.EqualError(t, f.SetRowOutlineLevel("Sheet1", 0, 1), newInvalidRowNumberError(0).Error())
|
||||
level, err = f.GetRowOutlineLevel("Sheet1", 2)
|
||||
|
@ -292,7 +292,7 @@ func TestSetColStyle(t *testing.T) {
|
|||
styleID, err := f.NewStyle(`{"fill":{"type":"pattern","color":["#94d3a2"],"pattern":1}}`)
|
||||
assert.NoError(t, err)
|
||||
// Test set column style on not exists worksheet.
|
||||
assert.EqualError(t, f.SetColStyle("SheetN", "E", styleID), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.SetColStyle("SheetN", "E", styleID), "sheet SheetN does not exist")
|
||||
// Test set column style with illegal cell coordinates.
|
||||
assert.EqualError(t, f.SetColStyle("Sheet1", "*", styleID), newInvalidColumnNameError("*").Error())
|
||||
assert.EqualError(t, f.SetColStyle("Sheet1", "A:*", styleID), newInvalidColumnNameError("*").Error())
|
||||
|
@ -329,11 +329,11 @@ func TestColWidth(t *testing.T) {
|
|||
assert.EqualError(t, f.SetColWidth("Sheet1", "A", "*", 1), newInvalidColumnNameError("*").Error())
|
||||
|
||||
// Test set column width on not exists worksheet.
|
||||
assert.EqualError(t, f.SetColWidth("SheetN", "B", "A", 12), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.SetColWidth("SheetN", "B", "A", 12), "sheet SheetN does not exist")
|
||||
|
||||
// Test get column width on not exists worksheet.
|
||||
_, err = f.GetColWidth("SheetN", "A")
|
||||
assert.EqualError(t, err, "sheet SheetN is not exist")
|
||||
assert.EqualError(t, err, "sheet SheetN does not exist")
|
||||
|
||||
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestColWidth.xlsx")))
|
||||
convertRowHeightToPixels(0)
|
||||
|
@ -376,7 +376,7 @@ func TestRemoveCol(t *testing.T) {
|
|||
assert.EqualError(t, f.RemoveCol("Sheet1", "*"), newInvalidColumnNameError("*").Error())
|
||||
|
||||
// Test remove column on not exists worksheet.
|
||||
assert.EqualError(t, f.RemoveCol("SheetN", "B"), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.RemoveCol("SheetN", "B"), "sheet SheetN does not exist")
|
||||
|
||||
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestRemoveCol.xlsx")))
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ func TestAddComments(t *testing.T) {
|
|||
assert.NoError(t, f.AddComment("Sheet2", "B7", `{"author":"Excelize: ","text":"This is a comment."}`))
|
||||
|
||||
// Test add comment on not exists worksheet.
|
||||
assert.EqualError(t, f.AddComment("SheetN", "B7", `{"author":"Excelize: ","text":"This is a comment."}`), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.AddComment("SheetN", "B7", `{"author":"Excelize: ","text":"This is a comment."}`), "sheet SheetN does not exist")
|
||||
// Test add comment on with illegal cell coordinates
|
||||
assert.EqualError(t, f.AddComment("Sheet1", "A", `{"author":"Excelize: ","text":"This is a comment."}`), newCellNameToCoordinatesError("A", newInvalidCellNameError("A")).Error())
|
||||
if assert.NoError(t, f.SaveAs(filepath.Join("test", "TestAddComments.xlsx"))) {
|
||||
|
@ -66,7 +66,7 @@ func TestDeleteComment(t *testing.T) {
|
|||
assert.NoError(t, f.DeleteComment("Sheet2", "C41"))
|
||||
assert.EqualValues(t, 0, len(f.GetComments()["Sheet2"]))
|
||||
// Test delete comment on not exists worksheet
|
||||
assert.EqualError(t, f.DeleteComment("SheetN", "A1"), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.DeleteComment("SheetN", "A1"), "sheet SheetN does not exist")
|
||||
// Test delete comment with worksheet part
|
||||
f.Pkg.Delete("xl/worksheets/sheet1.xml")
|
||||
assert.NoError(t, f.DeleteComment("Sheet1", "A22"))
|
||||
|
|
|
@ -90,7 +90,7 @@ func TestDataValidation(t *testing.T) {
|
|||
|
||||
// Test get data validation on no exists worksheet
|
||||
_, err = f.GetDataValidations("SheetN")
|
||||
assert.EqualError(t, err, "sheet SheetN is not exist")
|
||||
assert.EqualError(t, err, "sheet SheetN does not exist")
|
||||
|
||||
assert.NoError(t, f.SaveAs(resultFile))
|
||||
|
||||
|
@ -158,7 +158,7 @@ func TestDataValidationError(t *testing.T) {
|
|||
|
||||
// Test add data validation on no exists worksheet.
|
||||
f = NewFile()
|
||||
assert.EqualError(t, f.AddDataValidation("SheetN", nil), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.AddDataValidation("SheetN", nil), "sheet SheetN does not exist")
|
||||
}
|
||||
|
||||
func TestDeleteDataValidation(t *testing.T) {
|
||||
|
@ -201,7 +201,7 @@ func TestDeleteDataValidation(t *testing.T) {
|
|||
assert.EqualError(t, f.DeleteDataValidation("Sheet1", "A1:B2"), newCellNameToCoordinatesError("A", newInvalidCellNameError("A")).Error())
|
||||
|
||||
// Test delete data validation on no exists worksheet.
|
||||
assert.EqualError(t, f.DeleteDataValidation("SheetN", "A1:B2"), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.DeleteDataValidation("SheetN", "A1:B2"), "sheet SheetN does not exist")
|
||||
|
||||
// Test delete all data validations in the worksheet.
|
||||
assert.NoError(t, f.DeleteDataValidation("Sheet1"))
|
||||
|
|
|
@ -70,10 +70,10 @@ func newCellNameToCoordinatesError(cell string, err error) error {
|
|||
return fmt.Errorf("cannot convert cell %q to coordinates: %v", cell, err)
|
||||
}
|
||||
|
||||
// newNoExistSheetError defined the error message on receiving the not exist
|
||||
// newNoExistSheetError defined the error message on receiving the non existing
|
||||
// sheet name.
|
||||
func newNoExistSheetError(name string) error {
|
||||
return fmt.Errorf("sheet %s is not exist", name)
|
||||
return fmt.Errorf("sheet %s does not exist", name)
|
||||
}
|
||||
|
||||
// newNotWorksheetError defined the error message on receiving a sheet which
|
||||
|
|
|
@ -29,7 +29,7 @@ func TestOpenFile(t *testing.T) {
|
|||
|
||||
// Test get all the rows in a not exists worksheet.
|
||||
_, err = f.GetRows("Sheet4")
|
||||
assert.EqualError(t, err, "sheet Sheet4 is not exist")
|
||||
assert.EqualError(t, err, "sheet Sheet4 does not exist")
|
||||
// Test get all the rows in a worksheet.
|
||||
rows, err := f.GetRows("Sheet2")
|
||||
assert.NoError(t, err)
|
||||
|
@ -59,9 +59,9 @@ func TestOpenFile(t *testing.T) {
|
|||
f.NewSheet(":\\/?*[]Maximum 31 characters allowed in sheet title.")
|
||||
// Test set worksheet name with illegal name.
|
||||
f.SetSheetName("Maximum 31 characters allowed i", "[Rename]:\\/?* Maximum 31 characters allowed in sheet title.")
|
||||
assert.EqualError(t, f.SetCellInt("Sheet3", "A23", 10), "sheet Sheet3 is not exist")
|
||||
assert.EqualError(t, f.SetCellStr("Sheet3", "b230", "10"), "sheet Sheet3 is not exist")
|
||||
assert.EqualError(t, f.SetCellStr("Sheet10", "b230", "10"), "sheet Sheet10 is not exist")
|
||||
assert.EqualError(t, f.SetCellInt("Sheet3", "A23", 10), "sheet Sheet3 does not exist")
|
||||
assert.EqualError(t, f.SetCellStr("Sheet3", "b230", "10"), "sheet Sheet3 does not exist")
|
||||
assert.EqualError(t, f.SetCellStr("Sheet10", "b230", "10"), "sheet Sheet10 does not exist")
|
||||
|
||||
// Test set cell string value with illegal row number.
|
||||
assert.EqualError(t, f.SetCellStr("Sheet1", "A", "10"), newCellNameToCoordinatesError("A", newInvalidCellNameError("A")).Error())
|
||||
|
@ -122,11 +122,11 @@ func TestOpenFile(t *testing.T) {
|
|||
assert.NoError(t, f.SetCellValue("Sheet2", "F17", complex64(5+10i)))
|
||||
|
||||
// Test on not exists worksheet.
|
||||
assert.EqualError(t, f.SetCellDefault("SheetN", "A1", ""), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.SetCellFloat("SheetN", "A1", 42.65418, 2, 32), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.SetCellBool("SheetN", "A1", true), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.SetCellFormula("SheetN", "A1", ""), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.SetCellHyperLink("SheetN", "A1", "Sheet1!A40", "Location"), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.SetCellDefault("SheetN", "A1", ""), "sheet SheetN does not exist")
|
||||
assert.EqualError(t, f.SetCellFloat("SheetN", "A1", 42.65418, 2, 32), "sheet SheetN does not exist")
|
||||
assert.EqualError(t, f.SetCellBool("SheetN", "A1", true), "sheet SheetN does not exist")
|
||||
assert.EqualError(t, f.SetCellFormula("SheetN", "A1", ""), "sheet SheetN does not exist")
|
||||
assert.EqualError(t, f.SetCellHyperLink("SheetN", "A1", "Sheet1!A40", "Location"), "sheet SheetN does not exist")
|
||||
|
||||
// Test boolean write
|
||||
booltest := []struct {
|
||||
|
@ -151,7 +151,7 @@ func TestOpenFile(t *testing.T) {
|
|||
assert.NoError(t, f.SetCellValue("Sheet2", "G4", time.Now()))
|
||||
|
||||
assert.NoError(t, f.SetCellValue("Sheet2", "G4", time.Now().UTC()))
|
||||
assert.EqualError(t, f.SetCellValue("SheetN", "A1", time.Now()), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.SetCellValue("SheetN", "A1", time.Now()), "sheet SheetN does not exist")
|
||||
// 02:46:40
|
||||
assert.NoError(t, f.SetCellValue("Sheet2", "G5", time.Duration(1e13)))
|
||||
// Test completion column.
|
||||
|
@ -401,7 +401,7 @@ func TestGetCellHyperLink(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
t.Log(link, target)
|
||||
link, target, err = f.GetCellHyperLink("Sheet3", "H3")
|
||||
assert.EqualError(t, err, "sheet Sheet3 is not exist")
|
||||
assert.EqualError(t, err, "sheet Sheet3 does not exist")
|
||||
t.Log(link, target)
|
||||
assert.NoError(t, f.Close())
|
||||
|
||||
|
@ -968,7 +968,7 @@ func TestCopySheetError(t *testing.T) {
|
|||
t.FailNow()
|
||||
}
|
||||
|
||||
assert.EqualError(t, f.copySheet(-1, -2), "sheet is not exist")
|
||||
assert.EqualError(t, f.copySheet(-1, -2), "sheet does not exist")
|
||||
if !assert.EqualError(t, f.CopySheet(-1, -2), "invalid worksheet index") {
|
||||
t.FailNow()
|
||||
}
|
||||
|
@ -984,7 +984,7 @@ func TestGetSheetComments(t *testing.T) {
|
|||
func TestSetSheetVisible(t *testing.T) {
|
||||
f := NewFile()
|
||||
f.WorkBook.Sheets.Sheet[0].Name = "SheetN"
|
||||
assert.EqualError(t, f.SetSheetVisible("Sheet1", false), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.SetSheetVisible("Sheet1", false), "sheet SheetN does not exist")
|
||||
}
|
||||
|
||||
func TestGetActiveSheetIndex(t *testing.T) {
|
||||
|
@ -1002,7 +1002,7 @@ func TestRelsWriter(t *testing.T) {
|
|||
func TestGetSheetView(t *testing.T) {
|
||||
f := NewFile()
|
||||
_, err := f.getSheetView("SheetN", 0)
|
||||
assert.EqualError(t, err, "sheet SheetN is not exist")
|
||||
assert.EqualError(t, err, "sheet SheetN does not exist")
|
||||
}
|
||||
|
||||
func TestConditionalFormat(t *testing.T) {
|
||||
|
@ -1067,7 +1067,7 @@ func TestConditionalFormat(t *testing.T) {
|
|||
// Test set invalid format set in conditional format.
|
||||
assert.EqualError(t, f.SetConditionalFormat(sheet1, "L1:L10", ""), "unexpected end of JSON input")
|
||||
// Set conditional format on not exists worksheet.
|
||||
assert.EqualError(t, f.SetConditionalFormat("SheetN", "L1:L10", "[]"), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.SetConditionalFormat("SheetN", "L1:L10", "[]"), "sheet SheetN does not exist")
|
||||
|
||||
err = f.SaveAs(filepath.Join("test", "TestConditionalFormat.xlsx"))
|
||||
if !assert.NoError(t, err) {
|
||||
|
@ -1230,7 +1230,7 @@ func TestProtectSheet(t *testing.T) {
|
|||
Password: "password",
|
||||
}), ErrUnsupportedHashAlgorithm.Error())
|
||||
// Test protect not exists worksheet.
|
||||
assert.EqualError(t, f.ProtectSheet("SheetN", nil), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.ProtectSheet("SheetN", nil), "sheet SheetN does not exist")
|
||||
}
|
||||
|
||||
func TestUnprotectSheet(t *testing.T) {
|
||||
|
@ -1239,7 +1239,7 @@ func TestUnprotectSheet(t *testing.T) {
|
|||
t.FailNow()
|
||||
}
|
||||
// Test remove protection on not exists worksheet.
|
||||
assert.EqualError(t, f.UnprotectSheet("SheetN"), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.UnprotectSheet("SheetN"), "sheet SheetN does not exist")
|
||||
|
||||
assert.NoError(t, f.UnprotectSheet("Sheet1"))
|
||||
assert.EqualError(t, f.UnprotectSheet("Sheet1", "password"), ErrUnprotectSheet.Error())
|
||||
|
@ -1267,7 +1267,7 @@ func TestUnprotectSheet(t *testing.T) {
|
|||
func TestSetDefaultTimeStyle(t *testing.T) {
|
||||
f := NewFile()
|
||||
// Test set default time style on not exists worksheet.
|
||||
assert.EqualError(t, f.setDefaultTimeStyle("SheetN", "", 0), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.setDefaultTimeStyle("SheetN", "", 0), "sheet SheetN does not exist")
|
||||
|
||||
// Test set default time style on invalid cell
|
||||
assert.EqualError(t, f.setDefaultTimeStyle("Sheet1", "", 42), newCellNameToCoordinatesError("", newInvalidCellNameError("")).Error())
|
||||
|
|
|
@ -65,7 +65,7 @@ func TestMergeCell(t *testing.T) {
|
|||
assert.NoError(t, f.MergeCell("Sheet3", "N10", "O11"))
|
||||
|
||||
// Test get merged cells on not exists worksheet.
|
||||
assert.EqualError(t, f.MergeCell("SheetN", "N10", "O11"), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.MergeCell("SheetN", "N10", "O11"), "sheet SheetN does not exist")
|
||||
|
||||
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestMergeCell.xlsx")))
|
||||
assert.NoError(t, f.Close())
|
||||
|
@ -140,7 +140,7 @@ func TestGetMergeCells(t *testing.T) {
|
|||
|
||||
// Test get merged cells on not exists worksheet.
|
||||
_, err = f.GetMergeCells("SheetN")
|
||||
assert.EqualError(t, err, "sheet SheetN is not exist")
|
||||
assert.EqualError(t, err, "sheet SheetN does not exist")
|
||||
assert.NoError(t, f.Close())
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ func TestUnmergeCell(t *testing.T) {
|
|||
f = NewFile()
|
||||
assert.NoError(t, f.MergeCell("Sheet1", "A2", "B3"))
|
||||
// Test unmerged area on not exists worksheet.
|
||||
assert.EqualError(t, f.UnmergeCell("SheetN", "A1", "A1"), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.UnmergeCell("SheetN", "A1", "A1"), "sheet SheetN does not exist")
|
||||
|
||||
ws, ok := f.Sheet.Load("xl/worksheets/sheet1.xml")
|
||||
assert.True(t, ok)
|
||||
|
|
|
@ -128,7 +128,7 @@ func TestGetPicture(t *testing.T) {
|
|||
|
||||
// Try to get picture from a worksheet that doesn't contain any images.
|
||||
file, raw, err = f.GetPicture("Sheet3", "I9")
|
||||
assert.EqualError(t, err, "sheet Sheet3 is not exist")
|
||||
assert.EqualError(t, err, "sheet Sheet3 does not exist")
|
||||
assert.Empty(t, file)
|
||||
assert.Empty(t, raw)
|
||||
|
||||
|
@ -196,7 +196,7 @@ func TestAddPictureFromBytes(t *testing.T) {
|
|||
return true
|
||||
})
|
||||
assert.Equal(t, 1, imageCount, "Duplicate image should only be stored once.")
|
||||
assert.EqualError(t, f.AddPictureFromBytes("SheetN", fmt.Sprint("A", 1), "", "logo", ".png", imgFile), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.AddPictureFromBytes("SheetN", fmt.Sprint("A", 1), "", "logo", ".png", imgFile), "sheet SheetN does not exist")
|
||||
}
|
||||
|
||||
func TestDeletePicture(t *testing.T) {
|
||||
|
@ -207,7 +207,7 @@ func TestDeletePicture(t *testing.T) {
|
|||
assert.NoError(t, f.DeletePicture("Sheet1", "P1"))
|
||||
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestDeletePicture.xlsx")))
|
||||
// Test delete picture on not exists worksheet.
|
||||
assert.EqualError(t, f.DeletePicture("SheetN", "A1"), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.DeletePicture("SheetN", "A1"), "sheet SheetN does not exist")
|
||||
// Test delete picture with invalid coordinates.
|
||||
assert.EqualError(t, f.DeletePicture("Sheet1", ""), newCellNameToCoordinatesError("", newInvalidCellNameError("")).Error())
|
||||
assert.NoError(t, f.Close())
|
||||
|
@ -219,7 +219,7 @@ func TestDrawingResize(t *testing.T) {
|
|||
f := NewFile()
|
||||
// Test calculate drawing resize on not exists worksheet.
|
||||
_, _, _, _, err := f.drawingResize("SheetN", "A1", 1, 1, nil)
|
||||
assert.EqualError(t, err, "sheet SheetN is not exist")
|
||||
assert.EqualError(t, err, "sheet SheetN does not exist")
|
||||
// Test calculate drawing resize with invalid coordinates.
|
||||
_, _, _, _, err = f.drawingResize("Sheet1", "", 1, 1, nil)
|
||||
assert.EqualError(t, err, newCellNameToCoordinatesError("", newInvalidCellNameError("")).Error())
|
||||
|
|
|
@ -190,7 +190,7 @@ func (f *File) parseFormatPivotTableSet(opt *PivotTableOption) (*xlsxWorksheet,
|
|||
}
|
||||
pivotTableSheetPath, ok := f.getSheetXMLPath(pivotTableSheetName)
|
||||
if !ok {
|
||||
return dataSheet, pivotTableSheetPath, fmt.Errorf("sheet %s is not exist", pivotTableSheetName)
|
||||
return dataSheet, pivotTableSheetPath, fmt.Errorf("sheet %s does not exist", pivotTableSheetName)
|
||||
}
|
||||
return dataSheet, pivotTableSheetPath, err
|
||||
}
|
||||
|
|
|
@ -182,7 +182,7 @@ func TestAddPivotTable(t *testing.T) {
|
|||
Rows: []PivotTableField{{Data: "Month", DefaultSubtotal: true}, {Data: "Year"}},
|
||||
Columns: []PivotTableField{{Data: "Type", DefaultSubtotal: true}},
|
||||
Data: []PivotTableField{{Data: "Sales"}},
|
||||
}), "sheet SheetN is not exist")
|
||||
}), "sheet SheetN does not exist")
|
||||
// Test the pivot table range of the worksheet that is not declared
|
||||
assert.EqualError(t, f.AddPivotTable(&PivotTableOption{
|
||||
DataRange: "Sheet1!$A$1:$E$31",
|
||||
|
@ -198,7 +198,7 @@ func TestAddPivotTable(t *testing.T) {
|
|||
Rows: []PivotTableField{{Data: "Month", DefaultSubtotal: true}, {Data: "Year"}},
|
||||
Columns: []PivotTableField{{Data: "Type", DefaultSubtotal: true}},
|
||||
Data: []PivotTableField{{Data: "Sales"}},
|
||||
}), "sheet SheetN is not exist")
|
||||
}), "sheet SheetN does not exist")
|
||||
// Test not exists worksheet in data range
|
||||
assert.EqualError(t, f.AddPivotTable(&PivotTableOption{
|
||||
DataRange: "SheetN!$A$1:$E$31",
|
||||
|
@ -206,7 +206,7 @@ func TestAddPivotTable(t *testing.T) {
|
|||
Rows: []PivotTableField{{Data: "Month", DefaultSubtotal: true}, {Data: "Year"}},
|
||||
Columns: []PivotTableField{{Data: "Type", DefaultSubtotal: true}},
|
||||
Data: []PivotTableField{{Data: "Sales"}},
|
||||
}), "sheet SheetN is not exist")
|
||||
}), "sheet SheetN does not exist")
|
||||
// Test invalid row number in data range
|
||||
assert.EqualError(t, f.AddPivotTable(&PivotTableOption{
|
||||
DataRange: "Sheet1!$A$0:$E$31",
|
||||
|
@ -298,7 +298,7 @@ func TestGetPivotFieldsOrder(t *testing.T) {
|
|||
f := NewFile()
|
||||
// Test get pivot fields order with not exist worksheet
|
||||
_, err := f.getPivotFieldsOrder(&PivotTableOption{DataRange: "SheetN!$A$1:$E$31"})
|
||||
assert.EqualError(t, err, "sheet SheetN is not exist")
|
||||
assert.EqualError(t, err, "sheet SheetN does not exist")
|
||||
}
|
||||
|
||||
func TestGetPivotTableFieldName(t *testing.T) {
|
||||
|
|
4
rows.go
4
rows.go
|
@ -202,13 +202,13 @@ func appendSpace(l int, s []string) []string {
|
|||
return s
|
||||
}
|
||||
|
||||
// ErrSheetNotExist defines an error of sheet is not exist
|
||||
// ErrSheetNotExist defines an error of sheet that does not exist
|
||||
type ErrSheetNotExist struct {
|
||||
SheetName string
|
||||
}
|
||||
|
||||
func (err ErrSheetNotExist) Error() string {
|
||||
return fmt.Sprintf("sheet %s is not exist", err.SheetName)
|
||||
return fmt.Sprintf("sheet %s does not exist", err.SheetName)
|
||||
}
|
||||
|
||||
// rowXMLIterator defined runtime use field for the worksheet row SAX parser.
|
||||
|
|
20
rows_test.go
20
rows_test.go
|
@ -128,7 +128,7 @@ func TestRowsError(t *testing.T) {
|
|||
t.FailNow()
|
||||
}
|
||||
_, err = f.Rows("SheetN")
|
||||
assert.EqualError(t, err, "sheet SheetN is not exist")
|
||||
assert.EqualError(t, err, "sheet SheetN does not exist")
|
||||
assert.NoError(t, f.Close())
|
||||
}
|
||||
|
||||
|
@ -160,9 +160,9 @@ func TestRowHeight(t *testing.T) {
|
|||
assert.Equal(t, defaultRowHeight, height)
|
||||
|
||||
// Test set and get row height on not exists worksheet.
|
||||
assert.EqualError(t, f.SetRowHeight("SheetN", 1, 111.0), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.SetRowHeight("SheetN", 1, 111.0), "sheet SheetN does not exist")
|
||||
_, err = f.GetRowHeight("SheetN", 3)
|
||||
assert.EqualError(t, err, "sheet SheetN is not exist")
|
||||
assert.EqualError(t, err, "sheet SheetN does not exist")
|
||||
|
||||
// Test get row height with custom default row height.
|
||||
assert.NoError(t, f.SetSheetFormatPr(sheet1,
|
||||
|
@ -246,13 +246,13 @@ func TestRowVisibility(t *testing.T) {
|
|||
assert.Equal(t, false, visible)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualError(t, f.SetRowVisible("Sheet3", 0, true), newInvalidRowNumberError(0).Error())
|
||||
assert.EqualError(t, f.SetRowVisible("SheetN", 2, false), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.SetRowVisible("SheetN", 2, false), "sheet SheetN does not exist")
|
||||
|
||||
visible, err = f.GetRowVisible("Sheet3", 0)
|
||||
assert.Equal(t, false, visible)
|
||||
assert.EqualError(t, err, newInvalidRowNumberError(0).Error())
|
||||
_, err = f.GetRowVisible("SheetN", 1)
|
||||
assert.EqualError(t, err, "sheet SheetN is not exist")
|
||||
assert.EqualError(t, err, "sheet SheetN does not exist")
|
||||
|
||||
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestRowVisibility.xlsx")))
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ func TestRemoveRow(t *testing.T) {
|
|||
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestRemoveRow.xlsx")))
|
||||
|
||||
// Test remove row on not exist worksheet
|
||||
assert.EqualError(t, f.RemoveRow("SheetN", 1), `sheet SheetN is not exist`)
|
||||
assert.EqualError(t, f.RemoveRow("SheetN", 1), `sheet SheetN does not exist`)
|
||||
}
|
||||
|
||||
func TestInsertRow(t *testing.T) {
|
||||
|
@ -878,7 +878,7 @@ func TestDuplicateRowTo(t *testing.T) {
|
|||
})
|
||||
assert.EqualError(t, f.DuplicateRowTo(sheetName, 1, 2), newCellNameToCoordinatesError("A", newInvalidCellNameError("A")).Error())
|
||||
// Test duplicate row on not exists worksheet
|
||||
assert.EqualError(t, f.DuplicateRowTo("SheetN", 1, 2), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.DuplicateRowTo("SheetN", 1, 2), "sheet SheetN does not exist")
|
||||
}
|
||||
|
||||
func TestDuplicateMergeCells(t *testing.T) {
|
||||
|
@ -888,7 +888,7 @@ func TestDuplicateMergeCells(t *testing.T) {
|
|||
}}
|
||||
assert.EqualError(t, f.duplicateMergeCells("Sheet1", ws, 0, 0), `cannot convert cell "-" to coordinates: invalid cell name "-"`)
|
||||
ws.MergeCells.Cells[0].Ref = "A1:B1"
|
||||
assert.EqualError(t, f.duplicateMergeCells("SheetN", ws, 1, 2), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.duplicateMergeCells("SheetN", ws, 1, 2), "sheet SheetN does not exist")
|
||||
}
|
||||
|
||||
func TestGetValueFromInlineStr(t *testing.T) {
|
||||
|
@ -923,7 +923,7 @@ func TestGetValueFromNumber(t *testing.T) {
|
|||
|
||||
func TestErrSheetNotExistError(t *testing.T) {
|
||||
err := ErrSheetNotExist{SheetName: "Sheet1"}
|
||||
assert.EqualValues(t, err.Error(), "sheet Sheet1 is not exist")
|
||||
assert.EqualValues(t, err.Error(), "sheet Sheet1 does not exist")
|
||||
}
|
||||
|
||||
func TestCheckRow(t *testing.T) {
|
||||
|
@ -949,7 +949,7 @@ func TestSetRowStyle(t *testing.T) {
|
|||
assert.EqualError(t, f.SetRowStyle("Sheet1", 5, -1, style2), newInvalidRowNumberError(-1).Error())
|
||||
assert.EqualError(t, f.SetRowStyle("Sheet1", 1, TotalRows+1, style2), ErrMaxRows.Error())
|
||||
assert.EqualError(t, f.SetRowStyle("Sheet1", 1, 1, -1), newInvalidStyleID(-1).Error())
|
||||
assert.EqualError(t, f.SetRowStyle("SheetN", 1, 1, style2), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.SetRowStyle("SheetN", 1, 1, style2), "sheet SheetN does not exist")
|
||||
assert.NoError(t, f.SetRowStyle("Sheet1", 5, 1, style2))
|
||||
cellStyleID, err := f.GetCellStyle("Sheet1", "B2")
|
||||
assert.NoError(t, err)
|
||||
|
|
|
@ -36,7 +36,7 @@ func TestAddShape(t *testing.T) {
|
|||
}
|
||||
}],
|
||||
"height": 90
|
||||
}`), "sheet Sheet3 is not exist")
|
||||
}`), "sheet Sheet3 does not exist")
|
||||
assert.EqualError(t, f.AddShape("Sheet3", "H1", ""), "unexpected end of JSON input")
|
||||
assert.EqualError(t, f.AddShape("Sheet1", "A", `{
|
||||
"type": "rect",
|
||||
|
|
|
@ -102,7 +102,7 @@ func TestSetPane(t *testing.T) {
|
|||
f.NewSheet("Panes 4")
|
||||
assert.NoError(t, f.SetPanes("Panes 4", `{"freeze":true,"split":false,"x_split":0,"y_split":9,"top_left_cell":"A34","active_pane":"bottomLeft","panes":[{"sqref":"A11:XFD11","active_cell":"A11","pane":"bottomLeft"}]}`))
|
||||
assert.NoError(t, f.SetPanes("Panes 4", ""))
|
||||
assert.EqualError(t, f.SetPanes("SheetN", ""), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.SetPanes("SheetN", ""), "sheet SheetN does not exist")
|
||||
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestSetPane.xlsx")))
|
||||
// Test add pane on empty sheet views worksheet
|
||||
f = NewFile()
|
||||
|
@ -181,7 +181,7 @@ func TestSearchSheet(t *testing.T) {
|
|||
}
|
||||
// Test search in a not exists worksheet.
|
||||
_, err = f.SearchSheet("Sheet4", "")
|
||||
assert.EqualError(t, err, "sheet Sheet4 is not exist")
|
||||
assert.EqualError(t, err, "sheet Sheet4 does not exist")
|
||||
var expected []string
|
||||
// Test search a not exists value.
|
||||
result, err := f.SearchSheet("Sheet1", "X")
|
||||
|
@ -225,20 +225,20 @@ func TestSearchSheet(t *testing.T) {
|
|||
func TestSetPageLayout(t *testing.T) {
|
||||
f := NewFile()
|
||||
// Test set page layout on not exists worksheet.
|
||||
assert.EqualError(t, f.SetPageLayout("SheetN"), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.SetPageLayout("SheetN"), "sheet SheetN does not exist")
|
||||
}
|
||||
|
||||
func TestGetPageLayout(t *testing.T) {
|
||||
f := NewFile()
|
||||
// Test get page layout on not exists worksheet.
|
||||
assert.EqualError(t, f.GetPageLayout("SheetN"), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.GetPageLayout("SheetN"), "sheet SheetN does not exist")
|
||||
}
|
||||
|
||||
func TestSetHeaderFooter(t *testing.T) {
|
||||
f := NewFile()
|
||||
assert.NoError(t, f.SetCellStr("Sheet1", "A1", "Test SetHeaderFooter"))
|
||||
// Test set header and footer on not exists worksheet.
|
||||
assert.EqualError(t, f.SetHeaderFooter("SheetN", nil), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.SetHeaderFooter("SheetN", nil), "sheet SheetN does not exist")
|
||||
// Test set header and footer with illegal setting.
|
||||
assert.EqualError(t, f.SetHeaderFooter("Sheet1", &FormatHeaderFooter{
|
||||
OddHeader: strings.Repeat("c", MaxFieldLength+1),
|
||||
|
@ -301,7 +301,7 @@ func TestGroupSheets(t *testing.T) {
|
|||
for _, sheet := range sheets {
|
||||
f.NewSheet(sheet)
|
||||
}
|
||||
assert.EqualError(t, f.GroupSheets([]string{"Sheet1", "SheetN"}), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.GroupSheets([]string{"Sheet1", "SheetN"}), "sheet SheetN does not exist")
|
||||
assert.EqualError(t, f.GroupSheets([]string{"Sheet2", "Sheet3"}), "group worksheet must contain an active worksheet")
|
||||
assert.NoError(t, f.GroupSheets([]string{"Sheet1", "Sheet2"}))
|
||||
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestGroupSheets.xlsx")))
|
||||
|
@ -323,7 +323,7 @@ func TestInsertPageBreak(t *testing.T) {
|
|||
assert.NoError(t, f.InsertPageBreak("Sheet1", "C3"))
|
||||
assert.NoError(t, f.InsertPageBreak("Sheet1", "C3"))
|
||||
assert.EqualError(t, f.InsertPageBreak("Sheet1", "A"), newCellNameToCoordinatesError("A", newInvalidCellNameError("A")).Error())
|
||||
assert.EqualError(t, f.InsertPageBreak("SheetN", "C3"), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.InsertPageBreak("SheetN", "C3"), "sheet SheetN does not exist")
|
||||
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestInsertPageBreak.xlsx")))
|
||||
}
|
||||
|
||||
|
@ -349,7 +349,7 @@ func TestRemovePageBreak(t *testing.T) {
|
|||
assert.NoError(t, f.RemovePageBreak("Sheet2", "B2"))
|
||||
|
||||
assert.EqualError(t, f.RemovePageBreak("Sheet1", "A"), newCellNameToCoordinatesError("A", newInvalidCellNameError("A")).Error())
|
||||
assert.EqualError(t, f.RemovePageBreak("SheetN", "C3"), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.RemovePageBreak("SheetN", "C3"), "sheet SheetN does not exist")
|
||||
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestRemovePageBreak.xlsx")))
|
||||
}
|
||||
|
||||
|
|
|
@ -180,13 +180,13 @@ func TestSetSheetPrOptions(t *testing.T) {
|
|||
f := NewFile()
|
||||
assert.NoError(t, f.SetSheetPrOptions("Sheet1", TabColorRGB("")))
|
||||
// Test SetSheetPrOptions on not exists worksheet.
|
||||
assert.EqualError(t, f.SetSheetPrOptions("SheetN"), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.SetSheetPrOptions("SheetN"), "sheet SheetN does not exist")
|
||||
}
|
||||
|
||||
func TestGetSheetPrOptions(t *testing.T) {
|
||||
f := NewFile()
|
||||
// Test GetSheetPrOptions on not exists worksheet.
|
||||
assert.EqualError(t, f.GetSheetPrOptions("SheetN"), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.GetSheetPrOptions("SheetN"), "sheet SheetN does not exist")
|
||||
}
|
||||
|
||||
var _ = []PageMarginsOptions{
|
||||
|
@ -328,13 +328,13 @@ func TestPageMarginsOption(t *testing.T) {
|
|||
func TestSetPageMargins(t *testing.T) {
|
||||
f := NewFile()
|
||||
// Test set page margins on not exists worksheet.
|
||||
assert.EqualError(t, f.SetPageMargins("SheetN"), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.SetPageMargins("SheetN"), "sheet SheetN does not exist")
|
||||
}
|
||||
|
||||
func TestGetPageMargins(t *testing.T) {
|
||||
f := NewFile()
|
||||
// Test get page margins on not exists worksheet.
|
||||
assert.EqualError(t, f.GetPageMargins("SheetN"), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.GetPageMargins("SheetN"), "sheet SheetN does not exist")
|
||||
}
|
||||
|
||||
func ExampleFile_SetSheetFormatPr() {
|
||||
|
@ -469,7 +469,7 @@ func TestSetSheetFormatPr(t *testing.T) {
|
|||
ws.(*xlsxWorksheet).SheetFormatPr = nil
|
||||
assert.NoError(t, f.SetSheetFormatPr("Sheet1", BaseColWidth(1.0)))
|
||||
// Test set formatting properties on not exists worksheet.
|
||||
assert.EqualError(t, f.SetSheetFormatPr("SheetN"), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.SetSheetFormatPr("SheetN"), "sheet SheetN does not exist")
|
||||
}
|
||||
|
||||
func TestGetSheetFormatPr(t *testing.T) {
|
||||
|
@ -497,5 +497,5 @@ func TestGetSheetFormatPr(t *testing.T) {
|
|||
&thickBottom,
|
||||
))
|
||||
// Test get formatting properties on not exists worksheet.
|
||||
assert.EqualError(t, f.GetSheetFormatPr("SheetN"), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.GetSheetFormatPr("SheetN"), "sheet SheetN does not exist")
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ func TestAddSparkline(t *testing.T) {
|
|||
assert.EqualError(t, f.AddSparkline("SheetN", &SparklineOption{
|
||||
Location: []string{"F3"},
|
||||
Range: []string{"Sheet2!A3:E3"},
|
||||
}), "sheet SheetN is not exist")
|
||||
}), "sheet SheetN does not exist")
|
||||
|
||||
assert.EqualError(t, f.AddSparkline("Sheet1", nil), ErrParameterRequired.Error())
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ func TestNewStreamWriter(t *testing.T) {
|
|||
_, err := file.NewStreamWriter("Sheet1")
|
||||
assert.NoError(t, err)
|
||||
_, err = file.NewStreamWriter("SheetN")
|
||||
assert.EqualError(t, err, "sheet SheetN is not exist")
|
||||
assert.EqualError(t, err, "sheet SheetN does not exist")
|
||||
}
|
||||
|
||||
func TestSetRow(t *testing.T) {
|
||||
|
|
|
@ -1966,7 +1966,7 @@ var getXfIDFuncs = map[string]func(int, xlsxXf, *Style) bool{
|
|||
}
|
||||
|
||||
// getStyleID provides a function to get styleID by given style. If given
|
||||
// style is not exist, will return -1.
|
||||
// style does not exist, will return -1.
|
||||
func (f *File) getStyleID(ss *xlsxStyleSheet, style *Style) (styleID int) {
|
||||
styleID = -1
|
||||
if ss.CellXfs == nil {
|
||||
|
@ -2047,7 +2047,7 @@ func (f *File) readDefaultFont() *xlsxFont {
|
|||
}
|
||||
|
||||
// getFontID provides a function to get font ID.
|
||||
// If given font is not exist, will return -1.
|
||||
// If given font does not exist, will return -1.
|
||||
func (f *File) getFontID(styleSheet *xlsxStyleSheet, style *Style) (fontID int) {
|
||||
fontID = -1
|
||||
if styleSheet.Fonts == nil || style.Font == nil {
|
||||
|
@ -2098,7 +2098,7 @@ func (f *File) newFont(style *Style) *xlsxFont {
|
|||
}
|
||||
|
||||
// getNumFmtID provides a function to get number format code ID.
|
||||
// If given number format code is not exist, will return -1.
|
||||
// If given number format code does not exist, will return -1.
|
||||
func getNumFmtID(styleSheet *xlsxStyleSheet, style *Style) (numFmtID int) {
|
||||
numFmtID = -1
|
||||
if _, ok := builtInNumFmt[style.NumFmt]; ok {
|
||||
|
@ -2195,7 +2195,7 @@ func setCustomNumFmt(styleSheet *xlsxStyleSheet, style *Style) int {
|
|||
}
|
||||
|
||||
// getCustomNumFmtID provides a function to get custom number format code ID.
|
||||
// If given custom number format code is not exist, will return -1.
|
||||
// If given custom number format code does not exist, will return -1.
|
||||
func getCustomNumFmtID(styleSheet *xlsxStyleSheet, style *Style) (customNumFmtID int) {
|
||||
customNumFmtID = -1
|
||||
if styleSheet.NumFmts == nil {
|
||||
|
|
|
@ -199,7 +199,7 @@ func TestGetConditionalFormats(t *testing.T) {
|
|||
// Test get conditional formats on no exists worksheet
|
||||
f := NewFile()
|
||||
_, err := f.GetConditionalFormats("SheetN")
|
||||
assert.EqualError(t, err, "sheet SheetN is not exist")
|
||||
assert.EqualError(t, err, "sheet SheetN does not exist")
|
||||
}
|
||||
|
||||
func TestUnsetConditionalFormat(t *testing.T) {
|
||||
|
@ -211,7 +211,7 @@ func TestUnsetConditionalFormat(t *testing.T) {
|
|||
assert.NoError(t, f.SetConditionalFormat("Sheet1", "A1:A10", fmt.Sprintf(`[{"type":"cell","criteria":">","format":%d,"value":"6"}]`, format)))
|
||||
assert.NoError(t, f.UnsetConditionalFormat("Sheet1", "A1:A10"))
|
||||
// Test unset conditional format on not exists worksheet.
|
||||
assert.EqualError(t, f.UnsetConditionalFormat("SheetN", "A1:A10"), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.UnsetConditionalFormat("SheetN", "A1:A10"), "sheet SheetN does not exist")
|
||||
// Save spreadsheet by the given path.
|
||||
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestUnsetConditionalFormat.xlsx")))
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ func TestThemeReader(t *testing.T) {
|
|||
func TestSetCellStyle(t *testing.T) {
|
||||
f := NewFile()
|
||||
// Test set cell style on not exists worksheet.
|
||||
assert.EqualError(t, f.SetCellStyle("SheetN", "A1", "A2", 1), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.SetCellStyle("SheetN", "A1", "A2", 1), "sheet SheetN does not exist")
|
||||
}
|
||||
|
||||
func TestGetStyleID(t *testing.T) {
|
||||
|
|
|
@ -30,7 +30,7 @@ func TestAddTable(t *testing.T) {
|
|||
}
|
||||
|
||||
// Test add table in not exist worksheet.
|
||||
assert.EqualError(t, f.AddTable("SheetN", "B26", "A21", `{}`), "sheet SheetN is not exist")
|
||||
assert.EqualError(t, f.AddTable("SheetN", "B26", "A21", `{}`), "sheet SheetN does not exist")
|
||||
// Test add table with illegal formatset.
|
||||
assert.EqualError(t, f.AddTable("Sheet1", "B26", "A21", `{x}`), "invalid character 'x' looking for beginning of object key string")
|
||||
// Test add table with illegal cell coordinates.
|
||||
|
@ -111,7 +111,7 @@ func TestAutoFilterError(t *testing.T) {
|
|||
assert.EqualError(t, f.autoFilter("SheetN", "A1", 1, 1, &formatAutoFilter{
|
||||
Column: "A",
|
||||
Expression: "",
|
||||
}), "sheet SheetN is not exist")
|
||||
}), "sheet SheetN does not exist")
|
||||
assert.EqualError(t, f.autoFilter("Sheet1", "A1", 1, 1, &formatAutoFilter{
|
||||
Column: "-",
|
||||
Expression: "-",
|
||||
|
|
Loading…
Reference in New Issue