NPOI.XSSF.UserModel.XSSFWorkbook.AddPivotCache C# (CSharp) Метод

AddPivotCache() защищенный Метод

protected AddPivotCache ( String rId ) : NPOI.OpenXmlFormats.Spreadsheet.CT_PivotCache
rId String
Результат NPOI.OpenXmlFormats.Spreadsheet.CT_PivotCache
        protected internal CT_PivotCache AddPivotCache(String rId)
        {
            CT_Workbook ctWorkbook = GetCTWorkbook();
            CT_PivotCaches caches;
            if (ctWorkbook.IsSetPivotCaches())
            {
                caches = ctWorkbook.pivotCaches;
            }
            else
            {
                caches = ctWorkbook.AddNewPivotCaches();
            }
            CT_PivotCache cache = caches.AddNewPivotCache();

            int tableId = PivotTables.Count + 1;
            cache.cacheId = (uint)tableId;
            cache.id = (/*setter*/rId);
            if (pivotCaches == null)
            {
                pivotCaches = new List<CT_PivotCache>();
            }
            pivotCaches.Add(cache);
            return cache;
        }

Usage Example

Пример #1
0
        public void AddPivotCache()
        {
            XSSFWorkbook wb = new XSSFWorkbook();

            try
            {
                CT_Workbook   ctWb       = wb.GetCTWorkbook();
                CT_PivotCache pivotCache = wb.AddPivotCache("0");
                //Ensures that pivotCaches is Initiated
                Assert.IsTrue(ctWb.IsSetPivotCaches());
                Assert.AreSame(pivotCache, ctWb.pivotCaches.GetPivotCacheArray(0));
                Assert.AreEqual("0", pivotCache.id);
            }
            finally
            {
                wb.Close();
            }
        }
All Usage Examples Of NPOI.XSSF.UserModel.XSSFWorkbook::AddPivotCache