From 3ee3c38f9c63de3782fad21aae9c05ee0530fc32 Mon Sep 17 00:00:00 2001 From: xuri Date: Sun, 23 Jan 2022 00:32:34 +0800 Subject: Fix file corrupted in some cases, check file extension and format code Fix file corrupted when save as in XLAM / XLSM / XLTM / XLTX extension in some case New exported error ErrWorkbookExt has been added, and check file extension on save the workbook Format source code with `gofumpt` --- cell_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'cell_test.go') diff --git a/cell_test.go b/cell_test.go index 8d00e2d..f6f1098 100644 --- a/cell_test.go +++ b/cell_test.go @@ -30,11 +30,13 @@ func TestConcurrency(t *testing.T) { _, err := f.GetCellValue("Sheet1", fmt.Sprintf("A%d", val)) assert.NoError(t, err) // Concurrency set rows - assert.NoError(t, f.SetSheetRow("Sheet1", "B6", &[]interface{}{" Hello", + assert.NoError(t, f.SetSheetRow("Sheet1", "B6", &[]interface{}{ + " Hello", []byte("World"), 42, int8(1<<8/2 - 1), int16(1<<16/2 - 1), int32(1<<32/2 - 1), int64(1<<32/2 - 1), float32(42.65418), float64(-42.65418), float32(42), float64(42), uint(1<<32 - 1), uint8(1<<8 - 1), uint16(1<<16 - 1), uint32(1<<32 - 1), - uint64(1<<32 - 1), true, complex64(5 + 10i)})) + uint64(1<<32 - 1), true, complex64(5 + 10i), + })) // Concurrency create style style, err := f.NewStyle(`{"font":{"color":"#1265BE","underline":"single"}}`) assert.NoError(t, err) @@ -384,7 +386,7 @@ func TestGetCellFormula(t *testing.T) { func ExampleFile_SetCellFloat() { f := NewFile() - var x = 3.14159265 + x := 3.14159265 if err := f.SetCellFloat("Sheet1", "A1", x, 2, 64); err != nil { fmt.Println(err) } @@ -534,6 +536,7 @@ func TestGetCellRichText(t *testing.T) { _, err = f.GetCellRichText("Sheet1", "A") assert.EqualError(t, err, newCellNameToCoordinatesError("A", newInvalidCellNameError("A")).Error()) } + func TestSetCellRichText(t *testing.T) { f := NewFile() assert.NoError(t, f.SetRowHeight("Sheet1", 1, 35)) -- cgit v1.2.1