use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotCache in project poi by apache.
the class TestXSSFWorkbook method testAddPivotCache.
@Test
public void testAddPivotCache() throws IOException {
XSSFWorkbook wb = new XSSFWorkbook();
try {
CTWorkbook ctWb = wb.getCTWorkbook();
CTPivotCache pivotCache = wb.addPivotCache("0");
//Ensures that pivotCaches is initiated
assertTrue(ctWb.isSetPivotCaches());
assertSame(pivotCache, ctWb.getPivotCaches().getPivotCacheArray(0));
assertEquals("0", pivotCache.getId());
} finally {
wb.close();
}
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotCache in project poi by apache.
the class XSSFWorkbook method addPivotCache.
/**
* Add pivotCache to the workbook
*/
@Beta
protected CTPivotCache addPivotCache(String rId) {
CTWorkbook ctWorkbook = getCTWorkbook();
CTPivotCaches caches;
if (ctWorkbook.isSetPivotCaches()) {
caches = ctWorkbook.getPivotCaches();
} else {
caches = ctWorkbook.addNewPivotCaches();
}
CTPivotCache cache = caches.addNewPivotCache();
int tableId = getPivotTables().size() + 1;
cache.setCacheId(tableId);
cache.setId(rId);
if (pivotCaches == null) {
pivotCaches = new ArrayList<CTPivotCache>();
}
pivotCaches.add(cache);
return cache;
}
Aggregations