Spire.Doc for Java 4.11.3已发布。本次更新增强了转换Word到PDF/图片/HTML,以及转换HTML到Word的功能。此外,该版本还修复了比较Word文档等时出现的问题。详情请阅读以下内容。
问题修复:
Spire.PDF 7.11.1已发布。本次更新支持转线性化PDF的功能。此外,该版本增强了PDF到图片的转换功能,还修复了一些已知的问题。详情请阅读以下内容。
新功能:
PdfToLinearizedPdfConverter converter = new PdfToLinearizedPdfConverter("inputFile");
converter.ToLinearizedPdf("outputFile");
问题修复:
散点图(XY) 是一个二维图表,显示了两组变量之间的关系。每个散点图有两个轴:一个水平轴(x轴)和一个垂直轴(y轴),它只接受一个数据系列。在本文中,您将学习如何使用 Spire.Presentation for Java 向 PowerPoint 幻灯片添加散点图。
首先,您需要在 Java 程序中添加 Spire.Presentation.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.presentation</artifactId>
<version>10.11.4</version>
</dependency>
</dependencies>
Spire.Presentation for Java 提供了 ShapeCollection.appendChart(ChartType type, Rectangle2D rectangle, boolean init) 方法向幻灯片添加特定类型的图表,ChartType 枚举预定义了多达 73 种图表类型,包括但不限于散点图、柱图、饼图等。
下面是创建散点图的具体方法和步骤:
import com.spire.presentation.FileFormat;
import com.spire.presentation.Presentation;
import com.spire.presentation.SlideSizeType;
import com.spire.presentation.TextLineStyle;
import com.spire.presentation.charts.ChartType;
import com.spire.presentation.charts.IChart;
import com.spire.presentation.charts.entity.ChartDataLabel;
import com.spire.presentation.drawing.FillFormatType;
import java.awt.*;
import java.awt.geom.Rectangle2D;
public class ScatterChart {
public static void main(String[] args) throws Exception{
//创建Presentation类的实例
Presentation presentation = new Presentation();
presentation.getSlideSize().setType(SlideSizeType.SCREEN_16_X_9);
//添加散点图表到第一张幻灯片
IChart chart = presentation.getSlides().get(0).getShapes().appendChart(ChartType.SCATTER_MARKERS,new Rectangle2D.Float(180, 80, 550, 320),false);
//设置图表标题
chart.getChartTitle().getTextProperties().setText("散点图表");
chart.getChartTitle().getTextProperties().isCentered(true);
chart.getChartTitle().setHeight(20f);
chart.hasTitle(true);
//设置图表数据源
Double[] xData = new Double[] { 1.0, 2.4, 5.0, 8.9 };
Double[] yData = new Double[] { 5.3, 15.2, 6.7, 8.0 };
chart.getChartData().get(0,0).setText("X-值");
chart.getChartData().get(0,1).setText("Y-值");
for (int i = 0; i < xData.length; i++) {
chart.getChartData().get(i+1,0).setValue(xData[i]);
chart.getChartData().get(i+1,1).setValue(yData[i]);
}
//设置系列标签
chart.getSeries().setSeriesLabel(chart.getChartData().get("B1","B1"));
//设置X和Y轴值
chart.getSeries().get(0).setXValues(chart.getChartData().get("A2","A5"));
chart.getSeries().get(0).setYValues(chart.getChartData().get("B2","B5"));
//添加数据标签
for (int i = 0; i < 4; i++)
{
ChartDataLabel dataLabel = chart.getSeries().get(0).getDataLabels().add();
dataLabel.setLabelValueVisible(true);
}
//设置主轴标题和次轴标题
chart.getPrimaryValueAxis().hasTitle(true);
chart.getPrimaryValueAxis().getTitle().getTextProperties().setText("X-轴 标题");
chart.getSecondaryValueAxis().hasTitle(true);
chart.getSecondaryValueAxis().getTitle().getTextProperties().setText("Y-轴 标题");
//设置网格线
chart.getSecondaryValueAxis().getMajorGridTextLines().setFillType(FillFormatType.SOLID);
chart.getSecondaryValueAxis().getMajorGridTextLines().setStyle(TextLineStyle.THIN_THIN);
chart.getSecondaryValueAxis().getMajorGridTextLines().getSolidFillColor().setColor(Color.GRAY);
chart.getPrimaryValueAxis().getMajorGridTextLines().setFillType(FillFormatType.NONE);
//设置数据点线
chart.getSeries().get(0).getLine().setFillType(FillFormatType.SOLID);
chart.getSeries().get(0).getLine().setWidth(0.1f);
chart.getSeries().get(0).getLine().getSolidFillColor().setColor(Color.BLUE);
//保存文档
presentation.saveToFile("ScatterChart.pptx", FileFormat.PPTX_2013);
presentation.dispose();
}
}
如果您希望删除结果文档中的评估消息,或者摆脱功能限制,请 该Email地址已收到反垃圾邮件插件保护。要显示它您需要在浏览器中启用JavaScript。 获取有效期 30 天的临时许可证。
Spire.XLS for Java 4.11.0已发布。本次更新支持获取Excel文件的创建时间和最后保存时间,并增强Excel到PDF的转换功能。此外,该版本还修复了一些已知的问题。详情请阅读以下内容。
新功能:
BuiltInDocumentProperties properties1 = workbook.getDocumentProperties();
properties1.getCreatedTime();
properties1.getLastSaveTime();
问题修复:
Spire.PDF for Java 4.11.1已发布。本次更新支持转换PDF到透明背景图片的功能,并增强了转换PDF到Word的功能。此外,该版本还修复了对单元格设置不换行不起作用的问题。详情请阅读以下内容。
新功能:
PdfDocument doc = new PdfDocument();
doc.loadFromFile("http://cdn.e-iceblue.cn/input.pdf");
doc.getConvertOptions().setPdfToImageOptions(0);
BufferedImage image = doc.saveAsImage(0);
问题修复:
以 .et 格式结尾的文件是金山办公软件 WPS Office 中的电子表格文件,.ett 是一种模板文件格式。除了通过 WPS 软件可以创建该格式的电子表格外,也可以通过格式转换的方法来获得,本文将通过使用 Spire.XLS for Java 展示如何来实现 Excel 转为 .et 和 .ett 格式。以下是具体步骤和方法。
首先,您需要在 Java 程序中添加 Spire.Xls.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.xls</artifactId>
<version>15.11.3</version>
</dependency>
</dependencies>
使用 Spire.XLS for Java 来转换 Excel(以 .xlsx 格式为例)为 .et/.ett 格式,只需要简单三行代码即可:
import com.spire.xls.*;
public class ExcelToET{
public static void main(String[] args){
//实例化Workbook类的对象
Workbook workbook = new Workbook();
//加载Excel文档
workbook.loadFromFile("test.xlsx");
//保存为et格式
workbook.saveToFile("toET.et",FileFormat.ET);
//保存为ett格式
workbook.saveToFile("toETT.ett",FileFormat.ETT);
}
}转换结果:

如果您希望删除结果文档中的评估消息,或者摆脱功能限制,请 该Email地址已收到反垃圾邮件插件保护。要显示它您需要在浏览器中启用JavaScript。 获取有效期 30 天的临时许可证。
Spire.Office 6.10.3已发布。本次更新带来了一些新的功能,比如:Spire.PDF支持转换 PDF 到 Doc/Docx 时设置文档属性;Spire.XLS新增了实用图表,比如瀑布图、排列图和直方图等等;Spire.Presentation支持获取超链接的目标幻灯片。此外,该版本还修复了大量已知的问题。详情请阅读以下内容。
该版本涵盖了最新版的Spire.Doc, Spire.PDF, Spire.XLS, Spire.Presentation, Spire.Email, Spire.DocViewer, Spire.PDFViewer, Spire.Spreadsheet, Spire.OfficeViewer, Spire.DataExport, Spire.Barcode。
版本信息如下:
https://www.e-iceblue.cn/Downloads/Spire-Office-NET.html
新功能:
Spire.Pdf.Conversion.PdfToDocConverter doc = new Spire.Pdf.Conversion.PdfToDocConverter(inputFile);
doc.DocxOptions.Title = "PDFTODOCX";
doc.DocxOptions.Subject = "Set document properties.";
doc.DocxOptions.Tags = "Test Tags";
doc.DocxOptions.Categories = "PDF";
doc.DocxOptions.Commments = "This document just for testing the properties";
doc.DocxOptions.Authors = "TEST";
doc.DocxOptions.LastSavedBy = "/E-iceblue";
doc.DocxOptions.Revision = (int)7.9;
doc.DocxOptions.Version = "csharp V4.0";
doc.DocxOptions.ProgramName = "Spire.Pdf for .NET";
doc.DocxOptions.Company = "冰蓝科技";
doc.DocxOptions.Manager = "测试"
doc.SaveToDocx(outputFile);
PdfDocument pdf = new PdfDocument();
PdfPageBase page = pdf.Pages.Add();
PdfPolyLineAnnotation polyline = new PdfPolyLineAnnotation(page, new PointF[] { new PointF(0, 60),
new PointF(30, 45), new PointF(60, 90), new PointF(90, 80) });
polyline.Color = Color.PaleVioletRed;
polyline.Text = "This is a polygon annotation";
polyline.Author = "E-ICEBLUE";
polyline.Subject = "polygon annotation demo";
polyline.Name = "Summer";
polyline.Border = new PdfAnnotationBorder(1f);
polyline.ModifiedDate = DateTime.Now;
page.AnnotationsWidget.Add(polyline);
pdf.SaveToFile(output);
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile(inputPath);
StringBuilder builder = new StringBuilder();
//抽取表格
PdfTableExtractor extractor = new PdfTableExtractor(pdf);
PdfTable[] tableLists = null;
for (int pageIndex = 0; pageIndex < pdf.Pages.Count; pageIndex++)
{
tableLists = extractor.ExtractTable(pageIndex);
if (tableLists != null && tableLists.Length > 0)
{
foreach (PdfTable table in tableLists)
{
int row = table.GetRowCount();
int column = table.GetColumnCount();
for (int i = 0; i < row; i++)
{
for (int j = 0; j < column; j++)
{
string text = table.GetText(i, j);
builder.Append(text + " ");
}
builder.Append("\r\n");
}
}
}
}
File.WriteAllText(outputFile, builder.ToString());
问题修复:
新功能:
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");
问题修复:
问题修复:
新功能:
Presentation ppt = new Presentation();
ppt.LoadFromFile(inputFile);
IAutoShape shape = ppt.Slides[1].Shapes[0] as IAutoShape;
if (shape.Click.ActionType == HyperlinkActionType.GotoSlide)
{
ISlide targetSlide = shape.Click.TargetSlide;
Console.WriteLine("index = " + targetSlide.SlideNumber);
}
问题修复:
问题修复:
Spire.Spreadsheet 5.10.0已发布。该版本修复了查看Excel文档文本内容被剪切的问题。详情请阅读以下内容。
问题修复:
https://www.e-iceblue.cn/Downloads/Spire-Spreadsheet-NET.html
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.Doc for Java 中的 Document 类提供了 Document. saveToFile() 方法将 Word 源文档保存为指定格式的文档。本文以保存为 Html 格式为例,介绍如何实现转换。
首先,您需要在 Java 程序中添加 Spire.Doc.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.doc</artifactId>
<version>13.12.2</version>
</dependency>
</dependencies>
以下是实现格式转换的详细步骤:
import com.spire.doc.*;
public class WordtoHtml {
public static void main(String[] args) {
//实例化Document类的对象
Document doc = new Document();
//加载Word文档
doc.loadFromFile("http://cdn.e-iceblue.cn/inputfile.docx");
//保存为HTML格式
doc.saveToFile("ToHtml.html",FileFormat.Html);
doc.dispose();
}
}Word 测试文档:

转换后的 Html 文档:

如果您希望删除结果文档中的评估消息,或者摆脱功能限制,请 该Email地址已收到反垃圾邮件插件保护。要显示它您需要在浏览器中启用JavaScript。 获取有效期30天的临时许可证。