tab 1
此演示向您展示如何在 powerpoint 文档中创建图表。
data
e-iceblue
option
e-iceblue
downloads
如果这不是您想要的 demo,您可以通过填写表格获取免费定制 demo。
如您有与我们产品相关的其他技术问题,请联系 该email地址已收到反垃圾邮件插件保护。要显示它您需要在浏览器中启用javascript。;销售相关的问题,请联系 该email地址已收到反垃圾邮件插件保护。要显示它您需要在浏览器中启用javascript。。
tab 2
package ppt;
import com.spire.data.table.datacolumn;
import com.spire.data.table.datarow;
import com.spire.data.table.datatable;
import com.spire.pdf.tables.table.datatypes;
import com.spire.presentation.fileformat;
import com.spire.presentation.presentation;
import com.spire.presentation.charts.charttype;
import com.spire.presentation.charts.ichart;
import java.awt.geom.rectangle2d;
public class chartdemo {
public void chartdemoppt(string resultfilepath, charttype charttype) throws exception {
presentation presentation = new presentation();
rectangle2d rect1 = new rectangle2d.double(90, 100, 550, 320);
ichart chart = presentation.getslides().get(0).getshapes().appendchart(charttype, rect1, false);
//chart title
chart.getcharttitle().gettextproperties().settext("chart");
chart.getcharttitle().gettextproperties().iscentered(true);
chart.getcharttitle().setheight(30);
chart.hastitle( true);
datatable datatable = getdatatable();
insertdatatabletochart(chart,datatable);
//set series label
chart.getseries().setserieslabel(chart.getchartdata().get("b1", "d1"));
system.out.println(chart.getseries().size());
if (charttype.getname().contains("scatter") || charttype.getname().contains("bubble")){
chart.getseries().get(0).setxvalues(chart.getchartdata().get("a2", "a7"));
chart.getseries().get(0).setyvalues(chart.getchartdata().get("b2", "b7"));
chart.getseries().get(1).setyvalues(chart.getchartdata().get("c2", "c7"));
chart.getseries().get(2).setyvalues(chart.getchartdata().get("d2", "d7"));
if (charttype.getname().contains("bubble")){
for (int i = 0; i < chart.getseries().size();i ){
chart.getseries().get(i).getbubbles().add(1);
chart.getseries().get(i).getbubbles().add(4);
chart.getseries().get(i).getbubbles().add(3);
chart.getseries().get(i).getbubbles().add(4);
chart.getseries().get(i).getbubbles().add(2);
chart.getseries().get(i).getbubbles().add(9);
}
}
}else {
//set category label
chart.getcategories().setcategorylabels(chart.getchartdata().get("a2", "a7"));
//set values for series
chart.getseries().get(0).setvalues(chart.getchartdata().get("b2", "b7"));
chart.getseries().get(1).setvalues(chart.getchartdata().get("c2", "c7"));
chart.getseries().get(2).setvalues(chart.getchartdata().get("d2", "d7"));
if (charttype.getname().contains("3d")){
chart.getrotationthreed().setxdegree(10);
chart.getrotationthreed().setydegree(10);
}
}
presentation.savetofile(resultfilepath, fileformat.pptx_2013);
}
private datatable getdatatable() throws exception {
datatable datatable = new datatable();
datatable.getcolumns().add(new datacolumn("salespers", datatypes.datatable_string));
datatable.getcolumns().add(new datacolumn("saleamt", datatypes.datatable_int));
datatable.getcolumns().add(new datacolumn("compct", datatypes.datatable_int));
datatable.getcolumns().add(new datacolumn("comamt", datatypes.datatable_int));
datarow row1 = datatable.newrow();
row1.setstring("salespers", "joe");
row1.setint("saleamt", 250);
row1.setint("compct", 150);
row1.setint("comamt", 99);
datarow row2 = datatable.newrow();
row2.setstring("salespers", "robert");
row2.setint("saleamt", 270);
row2.setint("compct", 150);
row2.setint("comamt", 99);
datarow row3 = datatable.newrow();
row3.setstring("salespers", "michelle");
row3.setint("saleamt", 310);
row3.setint("compct", 120);
row3.setint("comamt", 49);
datarow row4 = datatable.newrow();
row4.setstring("salespers", "erich");
row4.setint("saleamt", 330);
row4.setint("compct", 120);
row4.setint("comamt", 49);
datarow row5 = datatable.newrow();
row5.setstring("salespers", "dafna");
row5.setint("saleamt", 360);
row5.setint("compct", 150);
row5.setint("comamt", 141);
datarow row6 = datatable.newrow();
row6.setstring("salespers", "rob");
row6.setint("saleamt", 380);
row6.setint("compct", 150);
row6.setint("comamt", 135);
datatable.getrows().add(row1);
datatable.getrows().add(row2);
datatable.getrows().add(row3);
datatable.getrows().add(row4);
datatable.getrows().add(row5);
datatable.getrows().add(row6);
return datatable;
}
private void insertdatatabletochart(ichart chart, datatable datatable) throws exception {
for (int c = 0; c < datatable.getcolumns().size(); c ) {
chart.getchartdata().get(0, c).settext(datatable.getcolumns().get(c).getcolumnname());
}
for (int r = 0; r < datatable.getrows().size(); r ) {
object[] datas = datatable.getrows().get(r).getarraylist();
for (int c = 0; c < datas.length; c ) {
chart.getchartdata().get(r 1, c).setvalue(datas[c]);
}
}
}
}
tab 3
using spire.presentation;
using spire.presentation.charts;
using system;
using system.data;
using system.drawing;
namespace demoonlinecode
{
class createcharts
{
public void chartdemo(string resultfilename, charttype charttype)
{
presentation presentation = new presentation();
rectanglef rect1 = new rectanglef(90, 100, 550, 320);
ichart chart = presentation.slides[0].shapes.appendchart(charttype, rect1, false);
//chart title
chart.charttitle.textproperties.text = "chart";
chart.charttitle.textproperties.iscentered = true;
chart.charttitle.height = 30;
chart.hastitle = true;
datatable datatable = getdatatable();
insertdatatabletochart(chart, datatable);
//set series label
chart.series.serieslabel = chart.chartdata["b1", "d1"];
if (charttype.tostring().contains("scatter") || charttype.tostring().contains("bubble"))
{
chart.series[0].xvalues = chart.chartdata["a2", "a7"];
chart.series[0].yvalues = chart.chartdata["b2", "b7"];
chart.series[1].xvalues = chart.chartdata["a2", "a7"];
chart.series[1].yvalues = chart.chartdata["c2", "c7"];
chart.series[2].xvalues = chart.chartdata["a2", "a7"];
chart.series[2].yvalues = chart.chartdata["d2", "d7"];
if (charttype.tostring().contains("bubble"))
{
for (int i = 0; i < chart.series.count; i )
{
chart.series[i].bubbles.add(1);
chart.series[i].bubbles.add(4);
chart.series[i].bubbles.add(3);
chart.series[i].bubbles.add(4);
chart.series[i].bubbles.add(2);
chart.series[i].bubbles.add(9);
}
}
}
else
{
//set category label
chart.categories.categorylabels = chart.chartdata["a2", "a7"];
//set values for series
chart.series[0].values = chart.chartdata["b2", "b7"];
chart.series[1].values = chart.chartdata["c2", "c7"];
chart.series[2].values = chart.chartdata["d2", "d7"];
if (charttype.tostring().contains("3d"))
{
chart.rotationthreed.xdegree = 10;
chart.rotationthreed.ydegree = 10;
}
}
presentation.savetofile(resultfilename ".pptx", fileformat.pptx2013);
}
private static datatable getdatatable()
{
datatable datatable = new datatable();
datatable.columns.add(new datacolumn("salespers", typeof(string)));
datatable.columns.add(new datacolumn("saleamt", typeof(int32)));
datatable.columns.add(new datacolumn("compct", typeof(int32)));
datatable.columns.add(new datacolumn("comamt", typeof(int32)));
datatable.rows.add("jeo", 250, 150, 99);
datatable.rows.add("robert", 270, 150, 99);
datatable.rows.add("michelle", 310, 120, 49);
datatable.rows.add("erich", 330, 120, 49);
datatable.rows.add("dafna", 360, 150, 141);
datatable.rows.add("rob", 380, 150, 135);
return datatable;
}
private static void insertdatatabletochart(ichart chart, datatable datatable)
{
for (int c = 0; c < datatable.columns.count; c )
{
chart.chartdata[0, c].text = datatable.columns[c].columnname;
}
for (int r = 0; r < datatable.rows.count; r )
{
object[] datas = datatable.rows[r].itemarray;
for (int c = 0; c < datas.length; c )
{
chart.chartdata[r 1, c].value = datas[c];
}
}
}
}
}