We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Checkbox and chart appearance

Hi,

Can something like this be achieved in ASPOSE??

http://processtrends.com/pg_interactive_chart_checkboxes.htm

Mithun

Hi,


Please see the simple example on how to create an interactive chart by using CheckBox that is mentioned at the page: http://peltiertech.com/Excel/Charts/ChartByControl.html I have also attached the input and output files for your reference here.

Sample code:
Workbook workbook = new Workbook(“e:\test2\Template_ChartByCheckBox.xls”);

Worksheet sheet = workbook.Worksheets[0];
Aspose.Cells.Cells cells = workbook.Worksheets[0].Cells;
//Add Checkboxes
CheckBoxCollection checkboxes = sheet.CheckBoxes;
int index = checkboxes.Add(3, 1, 16, 16);
Aspose.Cells.Drawing.CheckBox checkbox = checkboxes[index];
checkbox.LinkedCell = “B3”;
checkbox.Value = true;

index = checkboxes.Add(3, 2, 16, 16);
Aspose.Cells.Drawing.CheckBox checkbox2 = checkboxes[index];
checkbox2.LinkedCell = “C3”;
checkbox2.Value = true;

index = checkboxes.Add(3, 3, 16, 16);
Aspose.Cells.Drawing.CheckBox checkbox3 = checkboxes[index];
checkbox3.LinkedCell = “D3”;
checkbox3.Value = true;

//Set formulas
Aspose.Cells.Cell cell = cells[“E5”];
cell.Formula = “=IF(B$3,B5,”")";
cells[“E6”].SetSharedFormula("=IF(B$3,B6,NA())", 4, 1);
cell = cells[“F5”];
cell.Formula = “=IF(C$3,C5,”")";
cells[“F6”].SetSharedFormula("=IF(C$3,C6,NA())", 4, 1);

cell = cells[“G5”];
cell.Formula = “=IF(D$3,D5,”")";
cells[“G6”].SetSharedFormula("=IF(D$3,D6,NA())", 4, 1);

//Calculate formulas in the sheet(s)
workbook.CalculateFormula();
int chartIndex = sheet.Charts.Add(ChartType.LineWithDataMarkers, 10, 0, 27, 9);
Chart chart = sheet.Charts[chartIndex];
//Set Chart’s MajorGridLines invisib;e
chart.CategoryAxis.MajorGridLines.IsVisible = false;
chart.PlotArea.Border.IsVisible = false;
//Set Properties of chart title
chart.Title.Text = “Chart by Checkbox”;
chart.Title.TextFont.Color = Color.Red;
chart.Title.TextFont.IsBold = true;
chart.Title.TextFont.Size = 12;

//Set properies to nseries
chart.NSeries.CategoryData = “A6:A9”;

//Set NSeries Data
chart.NSeries.Add("‘Chart By Check Box’!E6:G9", true);

//Set Nseries color varience to True
chart.NSeries.IsColorVaried = false;
chart.ShowLegend = true;


workbook.Save(“e:\test2\Output_ChartByCheckBox.xls”);


Please get reference from the above example and this you may write your own code accordingly for your desired charts.


Thanks for your understanding!