spire.xls 11.10.5已发布。本次更新主要新增了一些实用图表,比如瀑布图、排列图和直方图等等。详情请阅读以下内容。
新功能:
- 支持瀑布图、排列图、直方图、箱型图、树状图、旭日图以及漏斗图
workbook workbook = new workbook();
workbook.loadfromfile("waterfall_sample.xlsx");
var sheet = workbook.worksheets[0];
var officechart = sheet.charts.add();
//set chart type as waterfall
officechart.charttype = excelcharttype.waterfall;
//set data range to the chart from the worksheet
officechart.datarange = sheet["a2:b8"];
//data point settings as total in chart
officechart.series[0].datapoints[3].setastotal = true;
officechart.series[0].datapoints[6].setastotal = true;
//showing the connector lines between data points
officechart.series[0].format.showconnectorlines = true;
//set the chart title
officechart.charttitle = "company profit (in usd)";
//formatting data label and legend option
officechart.series[0].datapoints.defaultdatapoint.datalabels.hasvalue = true;
officechart.series[0].datapoints.defaultdatapoint.datalabels.size = 8;
officechart.legend.position = legendpositiontype.right;
workbook.savetofile("waterfall_chart.xlsx");
workbook workbook = new workbook();
workbook.loadfromfile("pareto_sample.xlsx");
var sheet = workbook.worksheets[0];
var officechart = sheet.charts.add();
//set chart type as pareto
officechart.charttype = excelcharttype.pareto;
//set data range in the worksheet
officechart.datarange = sheet["a2:b8"];
//set category values as bin values
officechart.primarycategoryaxis.isbinningbycategory = true;
officechart.primarycategoryaxis.overflowbinvalue = 5;
officechart.primarycategoryaxis.underflowbinvalue = 1;
//formatting pareto line
officechart.series[0].paretolineformat.lineproperties.color = system.drawing.color.blue;
//gap width settings
officechart.series[0].dataformat.options.gapwidth = 6;
//set the chart title
officechart.charttitle = "expenses";
//hiding the legend
officechart.haslegend = false;
workbook.savetofile("pareto_chart.xlsx");
workbook workbook = new workbook();
workbook.loadfromfile("histogram_sample.xlsx");
var sheet = workbook.worksheets[0];
var officechart = sheet.charts.add();
//set chart type as histogram
officechart.charttype = excelcharttype.histogram;
//set data range in the worksheet
officechart.datarange = sheet["a1:a15"];
//category axis bin settings
officechart.primarycategoryaxis.binwidth = 8;
//gap width settings
officechart.series[0].dataformat.options.gapwidth = 6;
//set the chart title and axis title
officechart.charttitle = "height data";
officechart.primaryvalueaxis.title = "number of students";
officechart.primarycategoryaxis.title = "height";
//hiding the legend
officechart.haslegend = false;
workbook.savetofile("histogram_chart.xlsx");
workbook workbook = new workbook();
workbook.loadfromfile("boxandwhisker_sample.xlsx");
var sheet = workbook.worksheets[0];
var officechart = sheet.charts.add();
//set the chart title
officechart.charttitle = "yearly vehicle sales";
//set chart type as box and whisker
officechart.charttype = excelcharttype.boxandwhisker;
//set data range in the worksheet
officechart.datarange = sheet["a1:e17"];
//box and whisker settings on first series
var seriesa = officechart.series[0];
seriesa.dataformat.showinnerpoints = false;
seriesa.dataformat.showoutlierpoints = true;
seriesa.dataformat.showmeanmarkers = true;
seriesa.dataformat.showmeanline = false;
seriesa.dataformat.quartilecalculationtype = excelquartilecalculation.exclusivemedian;
//box and whisker settings on second series
var seriesb = officechart.series[1];
seriesb.dataformat.showinnerpoints = false;
seriesb.dataformat.showoutlierpoints = true;
seriesb.dataformat.showmeanmarkers = true;
seriesb.dataformat.showmeanline = false;
seriesb.dataformat.quartilecalculationtype = excelquartilecalculation.inclusivemedian;
//box and whisker settings on third series
var seriesc = officechart.series[2];
seriesc.dataformat.showinnerpoints = false;
seriesc.dataformat.showoutlierpoints = true;
seriesc.dataformat.showmeanmarkers = true;
seriesc.dataformat.showmeanline = false;
seriesc.dataformat.quartilecalculationtype = excelquartilecalculation.exclusivemedian;
workbook.savetofile("boxandwhisker_chart.xlsx");
workbook workbook = new workbook();
workbook.loadfromfile("treemap_sample.xlsx");
var sheet = workbook.worksheets[0];
var officechart = sheet.charts.add();
//set chart type as treemap
officechart.charttype = excelcharttype.treemap;
//set data range in the worksheet
officechart.datarange = sheet["a2:c11"];
//set the chart title
officechart.charttitle = "area by countries";
//set the treemap label option
officechart.series[0].dataformat.treemaplabeloption = exceltreemaplabeloption.banner;
//formatting data labels
officechart.series[0].datapoints.defaultdatapoint.datalabels.size = 8;
workbook.savetofile("treemap_chart.xlsx");
workbook workbook = new workbook();
workbook.loadfromfile("sunburst_sample.xlsx");
var sheet = workbook.worksheets[0];
var officechart = sheet.charts.add();
//set chart type as sunburst
officechart.charttype = excelcharttype.sunburst;
//set data range in the worksheet
officechart.datarange = sheet["a1:d16"];
//set the chart title
officechart.charttitle = "sales by annual";
//formatting data labels
officechart.series[0].datapoints.defaultdatapoint.datalabels.size = 8;
//hiding the legend
officechart.haslegend = false;
workbook.savetofile("sunburst_chart.xlsx");
workbook workbook = new workbook();
workbook.loadfromfile("funnel_sample.xlsx");
var sheet = workbook.worksheets[0];
var officechart = sheet.charts.add();
//set chart type as funnel
officechart.charttype = excelcharttype.funnel;
//set data range in the worksheet
officechart.datarange = sheet.range["a1:b6"];
//set the chart title
officechart.charttitle = "funnel";
//formatting the legend and data label option
officechart.haslegend = false;
officechart.series[0].datapoints.defaultdatapoint.datalabels.hasvalue = true;
officechart.series[0].datapoints.defaultdatapoint.datalabels.size = 8;
workbook.savetofile("funnel_chart.xlsx");
下载spire.xls 11.10.5请点击: