Spire.Office for Java 8.1.2 已发布。在该版本中,Spire.Doc for Java 支持内容控件“内容被编辑后删除内容控件”的功能;Spire.PDF for Java 新增了压缩文档的方法;Spire.XLS for Java 支持了FILTER函数;Spire.Presentation for Java 支持了瀑布图表、树形图表、箱线图表、直方图表、排列图表、旭日图表、和漏斗图表。此外,本次更新还成功修复了许多已知问题。详情请阅读以下内容。
获取 Spire.Office for Java 8.1.2请点击:https://www.e-iceblue.cn/Downloads/Spire-Office-JAVA.html
新功能:
Document doc = new Document();
doc.loadFromFile("1.docx");
StructureTags structureTags = GetAllTags(doc);
List tagInlines = structureTags.getM_tagInlines();
for (int i = 0; i<tagInlines.size(); i++)
{
StructureDocumentTagInline std = tagInlines.get(i);
std.getSDTProperties().isTemporary(true);
}
List<StructureDocumentTag> tags = structureTags.getM_tags();
for (int i = 0; i<tags.size(); i++) {
StructureDocumentTag std = tags.get(i);
std.getSDTProperties().isTemporary(true);
}
List<StructureDocumentTagRow> rowtags = structureTags.getM_rowtags();
for (int i = 0; i<rowtags.size(); i++) {
StructureDocumentTagRow std = rowtags.get(i);
std.getSDTProperties().isTemporary(true);
}
List<StructureDocumentTagCell> celltags = structureTags.getM_celltags();
for (int i = 0; i<celltags.size(); i++) {
StructureDocumentTagCell std = celltags.get(i);
std.getSDTProperties().isTemporary(true);
}
doc.saveToFile("tags.docx",FileFormat.Docx_2013); 问题修复:
新功能:
PdfCompressor compressor = new PdfCompressor(fileName);
compressor.compressToFile(outputName);问题修复:
新功能:
问题修复:
新功能:
Spire.Presentation for Java 8.1.2已发布。 此版本支持创建 PowerPoint 2016 中新增的图表类型。即瀑布图表,树形图表,箱线图表,直方图表,排列图表,旭日图表 和 漏斗图表。详情请阅读以下内容。
新功能:
https://www.e-iceblue.cn/Downloads/Spire-Presentation-JAVA.html
Spire.PDF for Java 9.1.4 已发布。本次更新增加了压缩 PDF 文档的方法。同时 PDF 到 PDFA 的转换也得到了增强。此外,该版本还修复了一些已知问题,详情请阅读以下内容。
新功能:
PdfCompressor compressor = new PdfCompressor(fileName);
compressor.compressToFile(outputName);问题修复:
列表是一种很好的组织信息的方式,与大段的文字西相比,列表能够更清楚明了地展示出重要信息。PDF 中有两种不同列表:有序列表和无序列表,这两种列表还可以同时应用在嵌套列表中。本文将介绍如何使用 Spire.PDF for Java 提供的类和方法在 PDF 文档中创建各种形式的列表。
在 Spire.PDF for Java 中,PdfSortedList 类和 PdfUnorderedList 类分别代表有序列表和无序列表,其中包含设置列表的内容、缩进、字体、样式以及其他属性的方法。下表列出了创建列表所需的一些核心类和方法。
| 类或方法 | 说明 |
| PdfSortedList 类 | 代表PDF文档中的有序列表。 |
| PdfUnorderedList 类 | 代表PDF文档中的无序列表。 |
| PdfListBase.setBrush() 方法 | 设置列表画笔。 |
| PdfListBase.setFont() 方法 | 设置列表字体。 |
| PdfListBase.sertIndent() 方法 | 设置列表缩进。 |
| PdfListBase.setTextIndent() 方法 | 设置项目标记和项目之间的缩进。 |
| PdfListBase.getItems() 方法 | 获取列表的项目。 |
| PdfListBase.setMarker() 方法 | 设置列表的项目标记。 |
| PdfListBase.draw() 方法 | 将列表绘制在页面的指定位置 |
| PdfOrderedMarker 类 | 代表有序列表的项目标记,如数字、字母、罗马数字。 |
| PdfMarker 类 | 代表无序列表的项目符号样式。 |
首先,您需要在 Java 程序中添加 Spire.Pdf.jar 文件作为依赖项。JAR 文件可以从此链接下载。如果您使用 Maven,则可以将以下代码添加到项目的 pom.xml 文件中,从而在应用程序中导入 JAR 文件。
<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>https://repo.e-iceblue.cn/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.pdf</artifactId>
<version>12.9.0</version>
</dependency>
</dependencies>
有序列表按一定顺序排列一系列项目,每个项目前都有一个数字、字母或罗马数字作为项目标记。以下是使用 Spire.PDF for Java 在 PDF 文档中创建有序列表的详细操作步骤:
import com.spire.pdf.PdfDocument;
import com.spire.pdf.PdfNumberStyle;
import com.spire.pdf.PdfPageBase;
import com.spire.pdf.PdfPageSize;
import com.spire.pdf.graphics.*;
import com.spire.pdf.lists.PdfOrderedMarker;
import com.spire.pdf.lists.PdfSortedList;
import java.awt.*;
public class createOrderedList {
public static void main(String[] args) {
//创建PdfDocument类的对象
PdfDocument doc = new PdfDocument();
//设置页边距
PdfMargins margins = new PdfMargins(30);
//添加一个页面
PdfPageBase page = doc.getPages().add(PdfPageSize.A4, margins);
//创建画笔
PdfBrush brush = PdfBrushes.getBlack();
//创建字体
PdfTrueTypeFont titleFont = new PdfTrueTypeFont(new Font("黑体", Font.BOLD,14));
PdfTrueTypeFont listFont = new PdfTrueTypeFont(new Font("黑体", Font.BOLD,12));
//创建有序列表的项目标记
PdfOrderedMarker marker = new PdfOrderedMarker(PdfNumberStyle.Lower_Latin, listFont);
//指定初始坐标
float x = 10;
float y = 20;
//绘制标题
String title = "Web开发必备技能";
page.getCanvas().drawString(title, titleFont, brush, x, y);
y = y + (float) titleFont.measureString(title).getHeight();
y = y + 5;
//创建有序列表
String listContent = "命令行Unix\n"
+ "Vim\n"
+ "HTML\n"
+ "CSS\n"
+ "Python\n"
+ "JavaScript\n"
+ "SQL";
PdfSortedList list = new PdfSortedList(listContent);
//设置列表的字体、列表缩进、文本缩进、画笔及项目标记
list.setFont(listFont);
list.setIndent(2);
list.setTextIndent(4);
list.setBrush(brush);
list.setMarker(marker);
//将列表绘制在页面上的指定位置
list.draw(page, x, y);
//保存文档
doc.saveToFile("有序列表.pdf");
}
}
无序列表也叫项目符号列表,包含没有特别顺序的相关项目,列表的每个项目前都有一个项目符号。以下是使用 Spire.PDF for Java 在 PDF 文档中创建无序列表的详细操作步骤:
import com.spire.pdf.PdfDocument;
import com.spire.pdf.PdfPageBase;
import com.spire.pdf.PdfPageSize;
import com.spire.pdf.graphics.*;
import com.spire.pdf.lists.PdfMarker;
import com.spire.pdf.lists.PdfUnorderedList;
import com.spire.pdf.lists.PdfUnorderedMarkerStyle;
import java.awt.*;
public class createUnorderedList {
public static void main(String[] args) {
//创建PdfDocument类的对象
PdfDocument doc = new PdfDocument();
//设置页边距
PdfMargins margin = new PdfMargins(30);
//添加一个页面
PdfPageBase page = doc.getPages().add(PdfPageSize.A4, margin);
//创建字体
PdfTrueTypeFont titleFont = new PdfTrueTypeFont(new Font("黑体", Font.BOLD,14));
PdfTrueTypeFont listFont = new PdfTrueTypeFont(new Font("黑体", Font.PLAIN,12));
PdfTrueTypeFont markerFont = new PdfTrueTypeFont(new Font("黑体", Font.PLAIN,8));
//创建画笔
PdfBrush brush = PdfBrushes.getBlack();
//指定初始坐标
float x = 10;
float y = 20;
//绘制标题
String title = "计算机科学科目";
page.getCanvas().drawString(title, titleFont, brush, x, y);
y = y + (float)titleFont.measureString(title).getHeight();
y = y + 5;
//设置项目标记样式
PdfMarker marker = new PdfMarker(PdfUnorderedMarkerStyle.Asterisk);
marker.setFont(markerFont);
//创建无序列表
String listContent = "数据结构\n"
+ "算法\n"
+ "计算机科学\n"
+ "操作系统\n"
+ "计算理论\n"
+ "C语言编程\n"
+"计算机组织和结构";
PdfUnorderedList list = new PdfUnorderedList(listContent);
//设置列表字体、列表缩进、文本缩进、画笔和项目标记
list.setFont(listFont);
list.setIndent(2);
list.setTextIndent(4);
list.setBrush(brush);
list.setMarker(marker);
//将列表绘制在页面的指定位置
list.draw(page, x, y);
//保存文档
doc.saveToFile("项目符号列表.pdf");
}
}
除了普通符号之外,还可以用图片作为无序列表的项目符号。创建图片项目符号无序列表的操作步骤如下:
import com.spire.pdf.PdfDocument;
import com.spire.pdf.PdfPageBase;
import com.spire.pdf.PdfPageSize;
import com.spire.pdf.graphics.*;
import com.spire.pdf.lists.PdfMarker;
import com.spire.pdf.lists.PdfUnorderedList;
import com.spire.pdf.lists.PdfUnorderedMarkerStyle;
import java.awt.*;
public class customizeBulletPointsWithImage {
public static void main(String[] args) {
//创建PdfDocument类的对象
PdfDocument doc = new PdfDocument();
//设置页边距
PdfMargins margin = new PdfMargins(30);
//添加一个页面
PdfPageBase page = doc.getPages().add(PdfPageSize.A4, margin);
//创建字体
PdfTrueTypeFont titleFont = new PdfTrueTypeFont(new Font("黑体", Font.BOLD, 14));
PdfTrueTypeFont listFont = new PdfTrueTypeFont(new Font("黑体", Font.PLAIN, 12));
//创建画笔
PdfBrush brush = PdfBrushes.getBlack();
//指定初始坐标
float x = 10;
float y = 20;
//绘制标题
String title = "项目待办事项";
page.getCanvas().drawString(title, titleFont, brush, x, y);
y = y + (float)titleFont.measureString(title).getHeight();
y = y + 5;
//将项目标记样式指定为图片
PdfMarker marker = new PdfMarker(PdfUnorderedMarkerStyle.Custom_Image);
//将图片设置为项目标记
marker.setImage(PdfImage.fromFile("核查标志.png"));
//順序なしリストを作成する
String listContent = "确定你正在进行的项目或任务。\n"
+ "分配任务。\n"
+ "确定任务的优先次序。\n"
+ "跟踪任务的进展状况。\n"
+ "任务完成后,将其标记为已完成。";
PdfUnorderedList list = new PdfUnorderedList(listContent);
//设置列表字体、列表缩进、文本缩进、画笔和项目标记
list.setFont(listFont);
list.setIndent(2);
list.setTextIndent(4);
list.setBrush(brush);
list.setMarker(marker);
//将列表绘制在页面上的指定位置
list.draw(page, x, y);
//保存文档
doc.saveToFile("图片项目符号列表.pdf");
}
}
嵌套列表是包含至少1个子列表的多级列表,用于显示数据的层次结构。以下是使用 Spire.PDF for Java 在 PDF 文档中创建嵌套列表的操作步骤:
import com.spire.pdf.PdfDocument;
import com.spire.pdf.PdfNumberStyle;
import com.spire.pdf.PdfPageBase;
import com.spire.pdf.PdfPageSize;
import com.spire.pdf.graphics.*;
import com.spire.pdf.lists.PdfListItem;
import com.spire.pdf.lists.PdfOrderedMarker;
import com.spire.pdf.lists.PdfSortedList;
import java.awt.*;
public class createMultiLevelList {
public static void main(String[] args) {
//创建PdfDocument类的对象
PdfDocument doc = new PdfDocument();
//设置页边距
PdfMargins margin = new PdfMargins(30);
//添加一个页面
PdfPageBase page = doc.getPages().add(PdfPageSize.A4, margin);
//指定初始坐标
float x = 10;
float y = 20;
//创建画笔
PdfBrush blackBrush = PdfBrushes.getBlack();
PdfBrush purpleBrush = PdfBrushes.getPurple();
//创建字体
PdfTrueTypeFont titleFont = new PdfTrueTypeFont(new Font("黑体", Font.BOLD, 14));
PdfTrueTypeFont listFont = new PdfTrueTypeFont(new Font("黑体", Font.PLAIN, 12));
//创建有序列表的项目标记
PdfOrderedMarker marker = new PdfOrderedMarker(PdfNumberStyle.Numeric, listFont);
//绘制标题
String title = "以下是一个嵌套列表。";
page.getCanvas().drawString(title, titleFont, blackBrush, x, y);
y = y + (float)titleFont.measureString(title).getHeight();
y = y + 5;
//创建主列表
String parentListContent = "项目 1\n"
+ "项目 2";
PdfSortedList parentList = new PdfSortedList(parentListContent);
parentList.setFont(listFont);
parentList.setIndent(2);
parentList.setBrush(purpleBrush);
parentList.setMarker(marker);
//创建一个名为“subList_1”的子列表
String subListContent_1 = "子项目 1\n"
+ "子项目 2\n"
+ "子项目 3\n"
+ "子项目 4";
PdfSortedList subList_1 = new PdfSortedList(subListContent_1);
subList_1.setIndent(12);
subList_1.setFont(listFont);
subList_1.setBrush(blackBrush);
subList_1.setMarker(marker);
subList_1.setMarkerHierarchy(true);
//创建一个名为“subList_2”的子列表
String subListContent_2 = "子项目 1\n"
+ "子项目 2\n"
+ "子项目 3";
PdfSortedList subList_2 = new PdfSortedList(subListContent_2);
subList_2.setIndent(12);
subList_2.setFont(listFont);
subList_2.setBrush(blackBrush);
subList_2.setMarker(marker);
subList_2.setMarkerHierarchy(true);
//创建一个名为“subList_2”的二级子列表
String subSubListContent_1 = "二级子项目 1\n"
+ "二级子项目 2";
PdfSortedList subSubList = new PdfSortedList(subSubListContent_1);
subSubList.setIndent(20);
subSubList.setFont(listFont);
subSubList.setBrush(blackBrush);
subSubList.setMarker(marker);
subSubList.setMarkerHierarchy(true);
//设置“subList_1”为主列表中第一个项目的子列表
PdfListItem item_1 = parentList.getItems().get(0);
item_1.setSubList(subList_1);
//设置“subList_2”为主列表中第二个项目的子列表
PdfListItem item_2 = parentList.getItems().get(1);
item_2.setSubList(subList_2);
//设置“subSubList”为“subList_1”中第一个项目的子列表
PdfListItem item_1_1 = subList_1.getItems().get(0);
item_1_1.setSubList(subSubList);
//绘制主列表
parentList.draw(page, x, y);
//保存文档
doc.saveToFile("多级列表.pdf");
}
}
如果您希望删除结果文档中的评估消息,或者摆脱功能限制,请该Email地址已收到反垃圾邮件插件保护。要显示它您需要在浏览器中启用JavaScript。获取有效期 30 天的临时许可证。
Spire.XLS 13.1.1 已发布。本次更新增强了 Excel 到 PDF、XLS 到 XLSX 的转换。此外,该版本还修复了许多已知问题,如转换图表到图片时条形图从坐标轴左侧突出和加载保存 XLSM 文档后宏丢失等问题。详情请阅读以下内容。
问题修复:
Spire.Presentation 8.1.1 已发布。本次更新支持了回复评论功能。此外,该版本还修复了一些已知问题,如:修复了生成的 Excel 文档中的图表数据 null 值变成0的问题。详情请阅读以下内容。
新功能:
Presentation ppt = new Presentation();
ICommentAuthor author = ppt.CommentAuthors.AddAuthor("E-iceblue", "comment");
ppt.Slides[0].AddComment(author, "Add comment", new System.Drawing.Point(18, 25), DateTime.Now);
Comment comment = ppt.Slides[0].Comments[0];
if (!comment.IsReply)
{
comment.Reply(author, "Add Reply1", DateTime.Now);
comment.Reply(author, "Add Reply2", DateTime.Now);
}
ppt.Slides[0].DeleteComment(author, "Add Reply1");
ppt.SaveToFile(outputFile, FileFormat.Pptx2013);问题修复:
https://www.e-iceblue.cn/Downloads/Spire-Presentation-NET.html
Spire.Spreadsheet 7.1.0 已发布。本次更新修复了加载 Excel 文档时程序抛出 System.ArgumentOutOfRangeException 的问题。详情请阅读以下内容。
问题修复:
https://www.e-iceblue.cn/Downloads/Spire-Spreadsheet-NET.html
Spire.Doc for Java 11.1.1已发布。本次更新新增支持内容控件“内容被编辑后删除内容控件”的功能。同时,此版本增强了 Word 到 PDF 的转换功能。此外,该版本还修复了一些已知问题,如:修复了加载文档报错“Value (11) does not exist in the
新功能:
Document doc = new Document();
doc.loadFromFile("1.docx");
StructureTags structureTags = GetAllTags(doc);
List tagInlines = structureTags.getM_tagInlines();
for (int i = 0; i<tagInlines.size(); i++)
{
StructureDocumentTagInline std = tagInlines.get(i);
std.getSDTProperties().isTemporary(true);
}
List<StructureDocumentTag> tags = structureTags.getM_tags();
for (int i = 0; i<tags.size(); i++) {
StructureDocumentTag std = tags.get(i);
std.getSDTProperties().isTemporary(true);
}
List<StructureDocumentTagRow> rowtags = structureTags.getM_rowtags();
for (int i = 0; i<rowtags.size(); i++) {
StructureDocumentTagRow std = rowtags.get(i);
std.getSDTProperties().isTemporary(true);
}
List<StructureDocumentTagCell> celltags = structureTags.getM_celltags();
for (int i = 0; i<celltags.size(); i++) {
StructureDocumentTagCell std = celltags.get(i);
std.getSDTProperties().isTemporary(true);
}
doc.saveToFile("tags.docx",FileFormat.Docx_2013); 问题修复:
条形图是图表的一种,可以等宽但不同长度的水平矩形条的形式展示或汇总数据。在 MS Excel 中,条形图可以用于对不同数据组的数据进行比较,帮助用户快速分析数据并得出结论。本文将介绍如何使用 Spire.XLS for Java 通过代码在 Excel 工作表中创建簇状条形图或堆积条形图。
首先,您需要在 Java 程序中添加 Spire.XLS for Java 文件作为依赖项。JAR 文件可以从此链接下载。如果您使用 Maven,则可以将以下代码添加到项目的 pom.xml 文件中,从而轻松地在应用程序中导入 JAR 文件。
<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>https://repo.e-iceblue.cn/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.xls</artifactId>
<version>16.9.2</version>
</dependency>
</dependencies>
簇状条形图中,不同系列的数据并排显示在单独的条形中,可方便对各个类别的多项数据系列直接进行比较。
以下是在 Excel 工作表中创建簇状条形图的详细步骤:
import com.spire.xls.*;
import com.spire.xls.charts.ChartSerie;
import com.spire.xls.charts.ChartSeries;
import java.awt.*;
public class CreateClusterBarChart {
public static void main(String[] args) {
//创建一个Workbook类的对象
Workbook workbook = new Workbook();
//获取第一个工作表
Worksheet sheet = workbook.getWorksheets().get(0);
//向指定单元格插入数据
sheet.getCellRange("A1").setValue("国家");
sheet.getCellRange("A2").setValue("古巴");
sheet.getCellRange("A3").setValue("墨西哥");
sheet.getCellRange("A4").setValue("法国");
sheet.getCellRange("A5").setValue("德国");
sheet.getCellRange("B1").setValue("六月");
sheet.getCellRange("B2").setNumberValue(60000);
sheet.getCellRange("B3").setNumberValue(80000);
sheet.getCellRange("B4").setNumberValue(90000);
sheet.getCellRange("B5").setNumberValue(85000);
sheet.getCellRange("C1").setValue("八月");
sheet.getCellRange("C2").setNumberValue(30000);
sheet.getCellRange("C3").setNumberValue(20000);
sheet.getCellRange("C4").setNumberValue(60000);
sheet.getCellRange("C5").setNumberValue(35000);
//设置单元格样式
sheet.getCellRange("A1:C1").setRowHeight(15);
sheet.getCellRange("A1:C1").getCellStyle().setColor(Color.darkGray);
sheet.getCellRange("A1:C1").getCellStyle().getExcelFont().setColor(Color.white);
sheet.getCellRange("A1:C5").getCellStyle().setVerticalAlignment(VerticalAlignType.Center);
sheet.getCellRange("A1:C5").getCellStyle().setHorizontalAlignment(HorizontalAlignType.Center);
//设置数值格式
sheet.getCellRange("B2:C5").getCellStyle().setNumberFormat("\"¥\"#,##0");
//在此工作表中插入一个簇状条形图
Chart chart = sheet.getCharts().add(ExcelChartType.BarClustered);
//设置簇状条形图的数据范围
chart.setDataRange(sheet.getCellRange("A1:C5"));
chart.setSeriesDataFromRange(false);
//设置簇状条形图的位置
chart.setLeftColumn(1);
chart.setTopRow(6);
chart.setRightColumn(11);
chart.setBottomRow(29);
//设置簇状条形图标题及其格式
chart.setChartTitle("销售报告");
chart.getChartTitleArea().isBold(true);
chart.getChartTitleArea().setSize(12);
//设置类别轴标题及其格式
chart.getPrimaryCategoryAxis().setTitle("国家");
chart.getPrimaryCategoryAxis().getFont().isBold(true);
chart.getPrimaryCategoryAxis().getTitleArea().isBold(true);
chart.getPrimaryCategoryAxis().getTitleArea().setTextRotationAngle(90);
//设置数据轴标题及其格式
chart.getPrimaryValueAxis().setTitle("销售额(元)");
chart.getPrimaryValueAxis().hasMajorGridLines(false);
chart.getPrimaryValueAxis().setMinValue(1000);
chart.getPrimaryValueAxis().getTitleArea().isBold(true);
//设置数据点标签
ChartSeries series = chart.getSeries();
for (int i = 0;i < series.size();i++)
{
ChartSerie cs = series.get(i);
cs.getFormat().getOptions().isVaryColor(true);
cs.getDataPoints().getDefaultDataPoint().getDataLabels().hasValue(true);
}
//设置簇状条形图图例的位置
chart.getLegend().setPosition(LegendPositionType.Top);
//保存结果文件
workbook.saveToFile("簇状条形图.xlsx", ExcelVersion.Version2016);
}
}
堆积条形图中,不同系列的数据在同一个条形图中分别堆积起来。与簇状条形图相比,堆积条形图增加对每个类别中数据的部分与整体的比较,使数据对比更加清晰可见。
以下是在 Excel 工作表中创建堆积条形图的详细步骤:
import com.spire.xls.*;
import com.spire.xls.charts.ChartSerie;
import com.spire.xls.charts.ChartSeries;
import java.awt.*;
public class CreateStackBarChart {
public static void main(String[] args) {
//创建一个Workbook类的对象
Workbook workbook = new Workbook();
//获取第一个工作表
Worksheet sheet = workbook.getWorksheets().get(0);
//向指定单元格插入数据
sheet.getCellRange("A1").setValue("国家");
sheet.getCellRange("A2").setValue("古巴");
sheet.getCellRange("A3").setValue("墨西哥");
sheet.getCellRange("A4").setValue("法国");
sheet.getCellRange("A5").setValue("德国");
sheet.getCellRange("B1").setValue("六月");
sheet.getCellRange("B2").setNumberValue(60000);
sheet.getCellRange("B3").setNumberValue(80000);
sheet.getCellRange("B4").setNumberValue(90000);
sheet.getCellRange("B5").setNumberValue(85000);
sheet.getCellRange("C1").setValue("八月");
sheet.getCellRange("C2").setNumberValue(30000);
sheet.getCellRange("C3").setNumberValue(20000);
sheet.getCellRange("C4").setNumberValue(60000);
sheet.getCellRange("C5").setNumberValue(35000);
//设置单元格样式
sheet.getCellRange("A1:C1").setRowHeight(15);
sheet.getCellRange("A1:C1").getCellStyle().setColor(Color.darkGray);
sheet.getCellRange("A1:C1").getCellStyle().getExcelFont().setColor(Color.white);
sheet.getCellRange("A1:C5").getCellStyle().setVerticalAlignment(VerticalAlignType.Center);
sheet.getCellRange("A1:C5").getCellStyle().setHorizontalAlignment(HorizontalAlignType.Center);
//设置数值格式
sheet.getCellRange("B2:C5").getCellStyle().setNumberFormat("\"¥\"#,##0");
//在此工作表中创建一个堆积条形图
Chart chart = sheet.getCharts().add(ExcelChartType.BarStacked);
//设置堆积条形图的数据范围
chart.setDataRange(sheet.getCellRange("A1:C5"));
chart.setSeriesDataFromRange(false);
//设置堆积条形图的位置
chart.setLeftColumn(1);
chart.setTopRow(6);
chart.setRightColumn(11);
chart.setBottomRow(29);
//设置堆积条形图标题及其格式
chart.setChartTitle("销售报告");
chart.getChartTitleArea().isBold(true);
chart.getChartTitleArea().setSize(12);
//设置类别轴标题及其格式
chart.getPrimaryCategoryAxis().setTitle("国家");
chart.getPrimaryCategoryAxis().getFont().isBold(true);
chart.getPrimaryCategoryAxis().getTitleArea().isBold(true);
chart.getPrimaryCategoryAxis().getTitleArea().setTextRotationAngle(90);
//设置数据轴标题及其格式
chart.getPrimaryValueAxis().setTitle("销售额(元)");
chart.getPrimaryValueAxis().hasMajorGridLines(false);
chart.getPrimaryValueAxis().setMinValue(1000);
chart.getPrimaryValueAxis().getTitleArea().isBold(true);
//显示数据点标签
ChartSeries series = chart.getSeries();
for (int i = 0;i < series.size();i++)
{
ChartSerie cs = series.get(i);
cs.getFormat().getOptions().isVaryColor(true);
cs.getDataPoints().getDefaultDataPoint().getDataLabels().hasValue(true);
}
//设置堆积条形图图例的位置
chart.getLegend().setPosition(LegendPositionType.Top);
//保存结果文件
workbook.saveToFile("堆积条形图.xlsx", ExcelVersion.Version2016);
}
}
如果您希望删除结果文档中的评估消息,或者摆脱功能限制,请该Email地址已收到反垃圾邮件插件保护。要显示它您需要在浏览器中启用JavaScript。获取有效期 30 天的临时许可证。
Spire.Presentation for Android 8.1.1 已发布。该版本支持设置自定义字体。此外,该版本还修复了转换PPT到PDF程序抛出ArrayIndexOutOfBoundsException的问题。详情请阅读以下内容。
新功能:
Presentation ppt = new Presentation();
ppt.loadFromFile(PptFile);
ppt.setCustomFontsFolder(fontFolderPath);
ppt.saveToFile(PdfFile, FileFormat.PDF);问题修复:
https://www.e-iceblue.cn/Downloads/presentation-for-android-via-java.html