core api - Excel Worksheet to be updated after the pivot - Stack Overflow

Using Syncfusion.XlsIO excel engine in the below code after updated the pivot table the worksheet still

Using Syncfusion.XlsIO excel engine in the below code after updated the pivot table the worksheet still has the old data, usedRange.LastRow has 25 rows where as my original excel has 100 rows after pivot update

IApplication application = excelEngine.Excel;
 FileStream fileStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite);
 IWorkbook xlworkbook = application.Workbooks.Open(fileStream);

 IWorksheet oreportSheet = xlworkbook.Worksheets["Report"];
 if (pivotTables.Count > 0)
 {

     IPivotTable pivotTable = oreportSheet.PivotTables[0];
     PivotTableImpl pivotTableImpl = pivotTable as PivotTableImpl;
    
     //Refreshing pivot cache to update the pivot table
     pivotTableImpl.Cache.IsRefreshOnLoad = true;
}
IRange usedRange = oreportSheet.UsedRange;
for (int row = 1; row <= usedRange.LastRow; row++)
{
    for (int column = 1; column <= usedRange.LastColumn; column++)
    {
        try
        {
            IRange cell = oreportSheet[row, column];
            string sValue = cell.Value;
            // Do something with the cell value
            if (!String.IsNullOrEmpty(sValue))
            {
                if (sValue.Equals("(blank) Sum") || sValue.Equals("(blank) Count") || sValue.Equals("(blank) Average") || sValue.Equals("(blank)"))
                {
                    // oreportSheet.SetRowHeight(row, 0);// oreportSheet.ShowRow(row, false);
                    oreportSheet.HideRow(row);
                    break;
                }
            }
        }
        catch (System.Exception ex)
        {
            // Handle the exception
        }

    }
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744409620a4572808.html

相关推荐

  • core api - Excel Worksheet to be updated after the pivot - Stack Overflow

    Using Syncfusion.XlsIO excel engine in the below code after updated the pivot table the worksheet still

    7天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信