File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -218,6 +218,24 @@ func TestSlicer(t *testing.T) {
218218 }), "XML syntax error on line 1: invalid UTF-8" )
219219 assert .NoError (t , f .Close ())
220220
221+ // Test add a pivot table slicer with invalid pivot cache XML content to trigger buildSlicerItems error
222+ f , err = OpenFile (workbookPath )
223+ assert .NoError (t , err )
224+ pivotTables , err := f .GetPivotTables ("Sheet2" )
225+ assert .NoError (t , err )
226+ assert .NotEmpty (t , pivotTables )
227+ f .Pkg .Store (pivotTables [0 ].pivotCacheXML , []byte ("<!DOCTYPE html><html><body>Not actually XML</body></html>" ))
228+ err = f .AddSlicer ("Sheet2" , & SlicerOptions {
229+ Name : "Month" ,
230+ Cell : "S42" ,
231+ TableSheet : "Sheet2" ,
232+ TableName : "PivotTable1" ,
233+ Caption : "Test Invalid XML" ,
234+ })
235+ assert .Error (t , err )
236+ assert .Contains (t , err .Error (), "pivotCacheDefinition" )
237+ assert .NoError (t , f .Close ())
238+
221239 // Test open a workbook and get already exist slicers
222240 f , err = OpenFile (workbookPath )
223241 assert .NoError (t , err )
You can’t perform that action at this time.
0 commit comments