From 0072bb731043f89ce978778b9d7fdc6160e29de0 Mon Sep 17 00:00:00 2001 From: xuri Date: Fri, 22 Feb 2019 22:17:38 +0800 Subject: resolve the issue corrupted xlsx after deleting formula of cell, reference #346 --- excelize_test.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'excelize_test.go') diff --git a/excelize_test.go b/excelize_test.go index ebbfcf7..d621b87 100644 --- a/excelize_test.go +++ b/excelize_test.go @@ -342,8 +342,18 @@ func TestSetCellFormula(t *testing.T) { xlsx.SetCellFormula("Sheet1", "C19", "SUM(Sheet2!D2,Sheet2!D9)") // Test set cell formula with illegal rows number. xlsx.SetCellFormula("Sheet1", "C", "SUM(Sheet2!D2,Sheet2!D9)") + assert.NoError(t, xlsx.SaveAs(filepath.Join("test", "TestSetCellFormula1.xlsx"))) - assert.NoError(t, xlsx.SaveAs(filepath.Join("test", "TestSetCellFormula.xlsx"))) + xlsx, err = OpenFile(filepath.Join("test", "CalcChain.xlsx")) + if !assert.NoError(t, err) { + t.FailNow() + } + // Test remove cell formula. + xlsx.SetCellFormula("Sheet1", "A1", "") + assert.NoError(t, xlsx.SaveAs(filepath.Join("test", "TestSetCellFormula2.xlsx"))) + // Test remove all cell formula. + xlsx.SetCellFormula("Sheet1", "B1", "") + assert.NoError(t, xlsx.SaveAs(filepath.Join("test", "TestSetCellFormula3.xlsx"))) } func TestSetSheetBackground(t *testing.T) { -- cgit v1.2.1