[]
        
(Showing Draft Content)

피벗 뷰 매니저

피벗 뷰 매니저(Pivot View Manager)를 사용하면 피벗 테이블의 뷰를 관리할 수 있습니다. 이 기능을 통해 특정 시점에 저장된 피벗 테이블의 뷰에 빠르게 접근할 수 있습니다. PivotTableViewManager 클래스를 사용하여 뷰를 추가하고 삭제하며 수정할 수 있습니다.

addsave 메서드를 사용하면 뷰를 추가하고 저장할 수 있습니다. 피벗 테이블에 새 뷰를 추가할 때는 고유한 이름이 필요합니다.

아래 GIF는 피벗 뷰 관리자에 여러 뷰가 저장된 예시를 보여줍니다.




다음 코드 샘플은 피벗 뷰 관리자에 여러 뷰를 저장하는 방법을 보여줍니다.

function initPivotTable(sheet) {
    // pivottable 추가
    myPivotTable = sheet.pivotTables.add("myPivotTable", "tableSales", 1, 1, GC.Spread.Pivot.PivotTableLayoutType.tabular, GC.Spread.Pivot.PivotTableThemes.dark3);
    myPivotTable.suspendLayout();
    var emptyPT = "Empty Pivot Table";
    //1) 빈 리포트 뷰
    myPivotTable.views.save(emptyPT);
    // 2) 제품 총계 리포트 뷰
    // 피벗테이블 열헤더 행헤더 표시
    myPivotTable.options.showRowHeader = true;
    myPivotTable.options.showColumnHeader = true;
    // 열 필드 추가
    myPivotTable.add("Category", "Category", GC.Spread.Pivot.PivotTableFieldType.columnField);
    myPivotTable.add("Product", "Product", GC.Spread.Pivot.PivotTableFieldType.columnField);
    // 행 필드 추가
    myPivotTable.add("Region", "Region", GC.Spread.Pivot.PivotTableFieldType.rowField);
    myPivotTable.add("City", "City", GC.Spread.Pivot.PivotTableFieldType.rowField);
    // SubtotalType이 Sum인 값 필드 추가
    myPivotTable.add("Quantity", "Sum of quantity", GC.Spread.Pivot.PivotTableFieldType.valueField, GC.Pivot.SubtotalType.sum);
    // 필터 필드 추가
    myPivotTable.add("OrderDate", "OrderDate", GC.Spread.Pivot.PivotTableFieldType.filterField);
    myPivotTable.autoFitColumn();
    myPivotTable.views.save("Products Total Report View");
    myPivotTable.views.apply(emptyPT);
    // 3) 분기 리포트 뷰
    // 열헤더/행헤더 표시 
    myPivotTable.options.showRowHeader = true;
    myPivotTable.options.showColumnHeader = true;
    // 행 필드 추가
    myPivotTable.add("Region", "Region", GC.Spread.Pivot.PivotTableFieldType.rowField);
    myPivotTable.add("City", "City", GC.Spread.Pivot.PivotTableFieldType.rowField);
    // 열 필드 추가
    let groupInfo = { originFieldName: "OrderDate", dateGroups: [{ by: GC.Pivot.DateGroupType.quarters }, { by: GC.Pivot.DateGroupType.years }] };
    myPivotTable.group(groupInfo);
    myPivotTable.add("OrderDate", "Qtr", GC.Spread.Pivot.PivotTableFieldType.columnField);
    myPivotTable.add("Years", "Years", GC.Spread.Pivot.PivotTableFieldType.columnField);
    // SubtotalType이 Sum인 값 필드 추가
    myPivotTable.add("Quantity", "Sum of quantity", GC.Spread.Pivot.PivotTableFieldType.valueField, GC.Pivot.SubtotalType.sum);
    myPivotTable.autoFitColumn();
    myPivotTable.views.save("Quarterly Report View");
    var panel = new GC.Spread.Pivot.PivotPanel("myPivotPanel", myPivotTable, document.getElementById("panel"));
    myPivotTable.resumeLayout();
    return myPivotTable;
}