[]
在 GcExcel Java 中,您可以将图表导出为 PDF 文档。这有助于从电子表格轻松生成 PDF 报告,例如财务、销售、营销、医疗保健等。以下图表类型可以导出为 PDF 文档:
柱状图
折线图
饼图
条形图
面积图
XY(散点)图
股票图
雷达图
组合图
漏斗图
注意:请确保所有GcExcel 依赖都添加到您的项目中。
请参考以下示例代码将 Excel 文件中的图表导出为 PDF 文档。
//create a new workbook
Workbook workbook = new Workbook();
IWorksheet worksheet = workbook.getWorksheets().get(0);
IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 230);
worksheet.getRange("A20:D21").setValue(new Object[][] { { 100, 200, 300, 400 }, { 100, 200, 300, 400 } });
shape.getChart().getSeriesCollection().add(worksheet.getRange("A20:D21"), RowCol.Columns);
shape.getChart().getChartTitle().setText("Column Clustered Chart");
//save to an pdf file
workbook.save("ColumnChartPdf.pdf");
当前不支持以下图表类型,导出为 PDF 时相应区域将显示为空:
柱状图
3D Clustered
3D Stacked
3D 100% Stacked
3D Column
折线图
3D Line
饼图
3D Pie
Pie of Pie
Bar of Pie
条形图
3D Clustered
3D Stacked
3D 100% Stacked
面积图
3D Area
3D Stacked Area
3D 100% Stacked Area
散点图
3D Bubble
Map
Surface
Histogram
Pareto
Box and Whisker
Waterfall
下表显示了导出为 PDF 时不同图表类型支持的功能。
通用功能 (所有图表类型均支持)
特点 | 设置 | 支持 |
---|---|---|
Chart Title | font size | Yes |
font color | Yes | |
border | Yes | |
fill | Yes | |
overlap with plot area | No | |
custom angle | No | |
text direction | No | |
Plot Area | border | Yes |
fill | Yes | |
free layout(resize) | Yes | |
Axes | show/hide | Yes |
fill | Yes | |
title | Yes | |
title free layout | No | |
border | Yes | |
angle(text rotate) | No | |
max/min bounds | Yes (when min/max is auto, the rendered result might be different between MSExcel and GcExcel) | |
major/minor unit | ||
horizontal axis cross position | No | |
display units | Yes | |
logrithimic scale | Yes | |
values in reverse order | Yes | |
tick marks | Yes | |
label position | Yes | |
number format | Yes | |
Data Label | fill | Yes |
border | Yes | |
font | Yes | |
position | Yes | |
number format | Yes | |
contains(series name/category name/values) | Yes | |
Data Table | No | |
Error Bars | direction | Yes (There can be some differences in the exported PDF) |
end style | ||
error amount | ||
Gridlines | major/minor | Yes |
value axis | Yes | |
category axis | Yes | |
color | Yes | |
Legend | fill | Yes |
border | Yes | |
location(top/bottom/left/right) | Yes | |
free layout(resize) | Yes | |
Trend Line | Yes | |
Series Option | primary axis | Yes |
secondary axis | Yes | |
series overlap | Yes | |
gap width | Yes | |
fill | Yes | |
border | Yes |
折线图
Excel导出 | PDF导出 |
---|---|
下表显示了导出为 PDF 时折线图类型支持的功能。
特点 | Settings | 支持 |
---|---|---|
Line | solid color | Yes |
gradient color | No | |
weight | Yes | |
cap type | No | |
join type | No | |
dash type | Yes | |
begin arrow | No | |
end arrow | No | |
smooth line | Yes | |
Marker | size | Yes |
fill | Yes | |
border | Yes | |
Drop Lines | - | No |
High-Low Lines | - | No |
Up-Down Bars | - | No |
饼图
Excel导出 | PDF导出 |
---|---|
下表显示了导出为 PDF 时饼图类型支持的功能。
Features | 设置 | 支持 |
---|---|---|
Pie Settings | angle of first slice | Yes |
explosion | No | |
Dought Chart | doughnut hole size | Yes |
条形图
Excel导出 | PDF导出 |
---|---|
下表显示了导出为 PDF 时条形图类型支持的功能。
特点 | 设置 | 支持 |
---|---|---|
Series Option | overlap | No |
gap width | Yes |
散点图
Excel导出 | PDF导出 |
---|---|
下表显示了导出为 PDF 时散点图类型支持的功能。
特点 | 设置 | 支持 |
---|---|---|
Chart Type | scatter | Yes |
scatter with smooth lines and markers | Yes | |
scatter with smooth lines | Yes | |
scatter with straight lines and markers | Yes | |
scatter with straight lines | Yes | |
bubble | Yes | |
3D-bubble | No | |
Bubble Settings | size represents | No |
scale bubble size | No | |
Line | smooth line | Yes |
股票图
Excel导出 | PDF导出 |
---|---|
下表显示了导出为 PDF 时股票图类型支持的功能。
特点 | 设置 | 支持 |
---|---|---|
Common Features | line color | Yes |
stock | Yes | |
line dash type | No | |
line cap | No | |
line join | No | |
series marker | No | |
series line | No | |
Open-High-Low-Close | gap width | No |
down-bar fill | Yes | |
down-bar border | No | |
up-bar | No | |
Volume-High-Low-Close / Volume-Open-High-Low-Close | volumn fill | Yes |
volume border | No |
雷达图
Excel导出 | PDF导出 |
---|---|
下表显示了导出为 PDF 时雷达图类型支持的功能。
特点 | 设置 | 支持 |
---|---|---|
Chart Type | radar | Yes |
radar with markers | Yes | |
filled radar | Yes | |
Series Line | width | Yes |
color | Yes | |
Marker | type | Yes |
size | Yes | |
fill | Yes | |
border | Yes |
树形图
Excel导出 | PDF导出 |
---|---|
下表显示了导出为 PDF 时 TreeMap 图表类型支持的功能。
特点 | Setttings | 支持 |
---|---|---|
Series Option | banner | No |
overlapping | No | |
Label Option | contains(series name/category name/value) | No |
number fromat | No | |
text font | Yes | |
text color | Yes | |
Point Formatting | fill | Yes (Only supports first level points) |
line | No |
旭日图
Excel导出 | PDF导出 |
---|---|
下表显示了导出为 PDF 时 Sunburst 图表类型支持的功能。
特点 | 设置 | 支持 |
---|---|---|
Plot Area | fill | No |
Label Option | contains(series name/category name/value) | No |
number fromat | No | |
text font | Yes | |
text color | Yes | |
Point Formatting | fill | Yes (Only supports first level points) |
line | Yes |