이 pivottable.ManualUpdate이 [= 설정] 진정한
이 오히려
거짓 상쾌한보다, 피벗 테이블에서 데이터를 삭제하는 RefreshTable 원인 RefreshTable가 정상적으로 작동 할 수 있습니다 : 여기
내 코드입니다 .
기본값은 False입니다.
이 속성은 자동으로이 속성은
다음은 몇 가지 코드 (예 : 피벗 항목 Visible 속성을 변경)를 업데이트를하기 직전에 true로 설정해야
호출 프로 시저 종료 (중요한) 후 False로 재설정 예를 들어 C#으로 작성된 : 그 이유는 그래서, 결론, ManualUpdate 속성 변경, 내 테스트에서 (오래 유지하지 않는 나는 그것을 가능한 빨리 false로 다시 설정됩니다 것을 볼 수 있었다으로
private void FilterByPivotItems(PivotField pf, List<string> pivotItemNames)
{
PivotItems pis = pf.ChildItems;
if (pf.Orientation != 0)
{
int oldAutoSortOrder = 0;
if (pf.AutoSortOrder != (int)Constants.xlManual)
{
oldAutoSortOrder = pf.AutoSortOrder;
pf.AutoSort((int)Constants.xlManual, pf.Name);
}
int pivotItemsCount = pf.PivotItems().Count;
for (int i = 1; i <= pivotItemsCount; i++)
{
PivotItem pi = pf.PivotItems(i);
// check if current pivot item needs to be hidden (if it exists in pivotItemNames)
var match = pivotItemNames.FirstOrDefault(stringToCheck => stringToCheck.Equals(pi.Value));
if (match == null)
{
TryFilterPivotItems(pi, false, true);
}
else
{
TryFilterPivotItems(pi, true, true);
}
}
if (oldAutoSortOrder != 0)
{
pf.AutoSort(oldAutoSortOrder, pf.Name);
}
PivotTable pt = pf.Parent as PivotTable;
if (pt != null)
{
// changing a pivot item triggers pivot table update
// so a refresh should be avoided cause it takes a lot and is unnecessary in this case
pt.Update();
}
}
}
private void TryFilterPivotItems(PivotItem currentPI, bool filterValue, bool deferLayoutUpdate = false)
{
try
{
PivotField pf = currentPI.Parent;
PivotTable pt = pf.Parent as PivotTable;
if (currentPI.Visible != filterValue)
{
if (deferLayoutUpdate == true && pt != null)
{
// just keep these three lines stick together, no if, no nothing (otherwise ManualUpdate will reset back to false)
pt.ManualUpdate = true;
currentPI.Visible = filterValue;
// this may be redundant since setting Visible property of pivot item, resets ManualUpdate to false
pt.ManualUpdate = false;
}
else
{
currentPI.Visible = filterValue;
}
}
}
catch (Exception ex)
{
}
}
private void TryFilterPivotItems(PivotField pf, string itemValue, bool filterValue, bool deferLayoutUpdate = false)
{
try
{
PivotItem currentPI = pf.PivotItems(itemValue);
TryFilterPivotItems(currentPI, filterValue, deferLayoutUpdate);
}
catch (Exception ex)
{
}
}
I 변경을 원할 때마다 true로 설정하도록 권장했습니다.
Pivot Refresh vs. Update – is there a real difference?
참고 :
제목 : 프로그래밍 VBA와 Excel 및 .NET
으로 Excel에서 업데이 트를 무엇을 의미하는지에 대한 추가 정보를 원하시면 라 피벗 항목)
, 다음을 확인하실 수 있습니다 : 제프 웹, 스티브 손더스
인쇄 ISBN : 978-0-596-00766-9 | ISBN 10 : 0-596-00766-3
전자 책 ISBN : 978-0-596-15951-1 | ISBN 10 : 0-596-15951-X