@Test
public void testRemoveSheet() throws Exception{
File file = new File(ResourceUtilities.getAbsolutePath(TEST_FILE));
SpreadsheetDocument spDocument = SpreadsheetDocument.loadDocument(file);
//index <0 , Not expected
Table table = spDocument.insertSheet(-1);
Assert.assertNull(table);
//index >= sheet count
Table tableb = spDocument.insertSheet(11);
Assert.assertNull(tableb);
//index is within the law
Table tab = spDocument.getSheetByName("tabellDemo2");
if(tab != null){
for(int i=0;i<spDocument.getSheetCount();i++){
if(tab.equals(spDocument.getSheetByIndex(i)))
spDocument.removeSheet(i);
}
}
Table tablea = spDocument.insertSheet(0);
Column col = tablea.appendColumn();
col.setWidth(12.99);
Column col2 = tablea.appendColumn();
col.setWidth(12.);
tablea.setTableName("tabellDemo2");
Assert.assertEquals("tabellDemo2", tablea.getTableName());
spDocument.removeSheet(0);
Table tablem = spDocument.getSheetByIndex(0);
Assert.assertNotSame(tablea, tablem);
//spDocument.save(ResourceUtilities.getAbsolutePath(TEST_FILE));
}