Syncfusion.XlsIO.Base
Example 


Syncfusion.XlsIO Namespace > IChart Interface : ShowValueFieldButtons Property

ShowValueFieldButtons Property

Gets or sets a boolean value indicating whether to show value field buttons on a pivot chart.
Syntax
'Declaration
 
Property ShowValueFieldButtons As Boolean
'Usage
 
Dim instance As IChart
Dim value As Boolean
 
instance.ShowValueFieldButtons = value
 
value = instance.ShowValueFieldButtons
bool ShowValueFieldButtons {get; set;}

Property Value

true to show value field buttons; false otherwise.
Example
The following code illustrates how to set the visibility of value field buttons in pivot chart.
using Syncfusion.XlsIO;
using System.Data;
            
class Program
{
    static void Main(string[] args)
    {
        using (ExcelEngine excelEngine = new ExcelEngine())
        {
            //Create worksheet
            IApplication application = excelEngine.Excel;
            application.DefaultVersion = ExcelVersion.Excel2013;
            IWorkbook workbook = application.Workbooks.Create(1);
            IWorksheet sheet = workbook.Worksheets[0];
            
            //Add data
            sheet.ImportDataTable(getData(), true, 1, 1);
            
            //Create pivot table
            IPivotCache cache = workbook.PivotCaches.Add(sheet["A1:D21"]);
            IPivotTable pivotTable = sheet.PivotTables.Add("PivotTable", sheet["F1"], cache);
            pivotTable.Fields[0].Axis = PivotAxisTypes.Row;
            pivotTable.Fields[1].Axis = PivotAxisTypes.Column;
            pivotTable.Fields[2].Axis = PivotAxisTypes.Row;
            IPivotField field = pivotTable.Fields[3];
            pivotTable.DataFields.Add(field, "Sum", PivotSubtotalTypes.Sum);
            
            //Create chart
            IChart chart = sheet.Charts.Add();
            
            //Set pivot source
            chart.PivotSource = pivotTable;
            
            //Set button visibility
            chart.ShowValueFieldButtons = false;
            
            //Save and Dispose
            workbook.SaveAs("Chart.xlsx");
            workbook.Close();
        }
    }
    static DataTable getData()
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("Region");
        dt.Columns.Add("Employee");
        dt.Columns.Add("Item");
        dt.Columns.Add("Units");
        dt.Rows.Add("Central", "Jones", "Pen Set", 700);
        dt.Rows.Add("West", "Kivell", "Binder", 85);
        dt.Rows.Add("East", "Gill", "Pen", 58);
        dt.Rows.Add("Central", "Jones", "Pen Set", 46);
        dt.Rows.Add("West", "Kivell", "Binder", 61);
        dt.Rows.Add("Central", "Jones", "Pen", 90);
        dt.Rows.Add("West", "Kivell", "Pen Set", 32);
        dt.Rows.Add("East", "Gill", "Binder", 79);
        dt.Rows.Add("Central", "Jones", "Pen Set", 27);
        dt.Rows.Add("Central", "Jones", "Binder", 5);
        dt.Rows.Add("East", "Gill", "Pen Set", 41);
        dt.Rows.Add("East", "Gill", "Pen Set", 61);
        dt.Rows.Add("East", "Gill", "Binder", 9);
        dt.Rows.Add("Central", "Jones", "Pen Set", 75);
        dt.Rows.Add("West", "Kivell", "Pen Set", 97);
        dt.Rows.Add("West", "Kivell", "Pen Set", 86);
        dt.Rows.Add("East", "Gill", "Pen Set", 90);
        dt.Rows.Add("East", "Gill", "Pen Set", 25);
        dt.Rows.Add("East", "Gill", "Binder", 68);
        dt.Rows.Add("East", "Gill", "Binder", 19);
        return dt;
    }
}
AssemblyVersion

Syncfusion.XlsIO.Base: 17.1460.0.32

See Also