我们很高兴地宣布,Spire.Office 11.4.0 正式发布。在此版本中,Spire.Doc 支持将图表保存为模板,以及通过 CompareOptions 进行多维度文档对比。Spire.XLS提升了 PDF 与 SVG 转换的稳定性。Spire.Presentation新增支持将 PPTX 保存为视频。Spire.PDF优化了 PDF 合并功能的内存占用,以及增强了 PDF 到 PDF/A 和图片的转换功能。此外,本版本还修复了大量已知问题。
本次发布集成了以下组件的最新版本:Spire.Doc、Spire.PDF、Spire.XLS、Spire.Presentation、Spire.Barcode、Spire.DocViewer、Spire.PDFViewer、Spire.Email、Spire.Spreadsheet 和 Spire.OfficeViewer。
版本信息如下:
- Spire.Doc.dll v14.4.9
- Spire.PDF.dll v12.4.5
- Spire.XLS.dll v16.4.2
- Spire.Presentation.dll v11.4.5
- Spire.Barcode.dll v7.5.0
- Spire.Email.dll v6.8.0
- Spire.DocViewer.Forms.dll v8.9.5
- Spire.PdfViewer.Asp.dll v8.2.13
- Spire.PdfViewer.Forms.dll v8.2.13
- Spire.Spreadsheet.dll v7.5.3
- Spire.OfficeViewer.Forms.dll v8.8.1
获取Spire.Office 11.4.0,请点击:
https://www.e-iceblue.cn/Downloads/Spire-Office-NET.html
Spire.Doc
调整:
- 将 ToPdfParameterList.IsAtlast 属性更名为 ToPdfParameterList.IsAtLeast。
- CompareOptions.IgnoreTable 已重命名为 CompareOptions.IgnoreTables。
ToPdfParameterList.IsAtlast-->ToPdfParameterList.IsAtLeast
新功能:
- 支持将图表保存为模板。
- 新增 GeneratorName 属性,支持在转换 Word 到 PDF 时配置 Producer 元数据。
- 新增 XValues 和 YValues 属性,支持获取图表指定系列的坐标轴数据值。
- 支持读取和设置图表数据标签的位置。
- CompareOptions 新增多个接口支持多维度对比文档:
Document doc = new Document();
doc.LoadFromFile(inputFile);
int count = 1;
foreach (Section sec in doc.Sections)
{
foreach (Spire.Doc.Documents.Paragraph paragraph in sec.Paragraphs)
{
foreach (DocumentObject obj in paragraph.ChildObjects)
{
if (obj is ShapeObject shape)
{
Chart chart = shape.Chart;
if (chart == null)
continue;
string fileName = Path.Combine(outputPath, $"{count}.crtx");
chart.SaveAsTemplate(fileName);
count++;
}
}
}
}
string genName = "Testing For Set Producer";
Document doc = new Document();
doc.LoadFromFile(filename);
ToPdfParameterList toPdf = new ToPdfParameterList();
toPdf.GeneratorName = genName;
doc.SaveToFile("result.pdf", toPdf);
Document doc = new Document();
doc.LoadFromFile(inputFile);
StringBuilder sb = new StringBuilder();
int number = 1;
foreach (Section sec in doc.Sections)
{
foreach (Paragraph paragraph in sec.Paragraphs)
{
for (int i = 0; i < paragraph.ChildObjects.Count; i++)
{
DocumentObject obj = paragraph.ChildObjects[i];
if (obj is ShapeObject)
{
ShapeObject shape = obj as ShapeObject;
Chart chart = shape.Chart;
sb.Append("\r\n\r\n第" + number + "页:\r\n" + "获取所有X轴数据:");
for (int x = 0; x < chart.XValues.Count; x++)
{
ChartValue xVal = chart.XValues[x];
// 获取所有X轴数据值
sb.Append(xVal.StringValue + " ");
}
//获取第一个系列
ChartSeries series = chart.Series[0];
sb.Append("\r\n获取Y轴数据:");
foreach (ChartValue yVal in series.YValues)
{
// 获取第一个系列所有的Y轴数据值
sb.Append(yVal.Value + " ");
}
}
}
}
number++;
}
Document doc = new Document();
foreach (ChartDataLabelPosition position in Enum.GetValues(typeof(ChartDataLabelPosition)))
{
Section section = doc.AddSection();
section.AddParagraph().AppendText(position.ToString());
Spire.Doc.Documents.Paragraph newPara = section.AddParagraph();
ShapeObject shape = newPara.AppendChart(ChartType.Pie, 500, 300);
Chart chart = shape.Chart;
chart.Series[0].HasDataLabels = true;
chart.Series[0].DataLabels.ShowCategoryName = true;
chart.Series[0].DataLabels.ShowValue = true;
// 设置Position
chart.Series[0].DataLabels.Position = position;
ShapeObject shape2 = newPara.AppendChart(ChartType.Bubble, 500, 300);
Chart chart2 = shape2.Chart;
chart2.Series[0].HasDataLabels = true;
chart2.Series[0].DataLabels.ShowCategoryName = true;
chart2.Series[0].DataLabels.ShowValue = true;
chart2.Series[0].DataLabels.Position = position;
}
doc.SaveToFile(outputFile, FileFormat.Docx);
doc.Dispose();
· CompareMoves: 比较是否忽略移动。
· IgnoreCaseChanges: 比较是否忽略大小写。
· IgnoreFields: 比较是否忽略域。
· IgnoreFootnotes: 比较是否忽略脚注。
· IgnoreComments: 比较是否忽略批注。
· IgnoreTextboxes: 比较是否忽略文本框。
· IgnoreCaseChanges: 比较是否忽略大小写。
· IgnoreFields: 比较是否忽略域。
· IgnoreFootnotes: 比较是否忽略脚注。
· IgnoreComments: 比较是否忽略批注。
· IgnoreTextboxes: 比较是否忽略文本框。
Document doc1 = new Document();
doc1.LoadFromFile(inputFile_1);
Document doc2 = new Document();
doc2.LoadFromFile(inputFile_2);
CompareOptions options = new CompareOptions();
options.CompareMoves = false;
options.IgnoreCaseChanges = false;
options.IgnoreComments = true;
options.IgnoreFields = true;
options.IgnoreFootnotes = true;
options.IgnoreTables = true;
options.IgnoreTextboxes = true;
doc1.Compare(doc2, "user", new DateTime(), options);
doc1.SaveToFile(outputFile, FileFormat.Docx2013);
问题修复:
- 修复了转换 Markdown 文件到 Docx 或 PDF 时,表格转换不正确的问题。
- 修复了拆分表格合并单元格时结果不正确的问题。
- 修复了合并 Word 文档时程序抛出 System.InvalidCastException 异常的问题。
- 修复了加载 HTML 文档时程序抛出 System.NullReferenceException 异常的问题。
Spire.XLS
调整:
- 将 SortComparsionType 枚举名称更正为 SortComparisonType。
问题修复:
- 修复了透视表单元格设置文本换行样式不生效的问题。
- 修复了加载 Excel 文档时程序抛出 “ArgumentOutOfRangeException” 异常的问题。
- 修复了 Excel 转 PDF 或 SVG 时格式不正确的问题。
Spire.Presentation
新功能:
- 支持将 PPTX 保存为视频(.mp4/.wmv)。
注意:使用此功能需要指定 ffmpeg 路径。
Presentation ppt = new Presentation();
ppt.LoadFromFile(inputFile);
SaveToVideoOption saveOption = new SaveToVideoOption(ffmpegDir);
ppt.SaveToVideoOption=saveOption;// 默认每张幻灯片5秒
ppt.SaveToFile(outputFile_mp4, FileFormat.MP4);
ppt.SaveToFile(outputFile_wmv, FileFormat.WMV);
ppt.Dispose();
问题修复:
- 修复了 PowerPoint 转 PDF 时数据标签格式不正确的问题。
- 修复了将图形转换为 SVG 时程序抛出 InvalidOperationException 异常的问题。
- 修复了拆分 PowerPoint 文件后输出文件过大的问题。
- 修复了 PowerPoint 转 PDF 时形状被裁切的问题。
- 修复了幻灯片转图片时部分图片丢失的问题。
- 修复了 PowerPoint 转 PDF 时出现多余错误图片的问题。
Spire.PDF
优化:
- 优化了 PDF 合并功能的内存占用。
问题修复:
- 修复了删除 PDF 图片水印失败的问题。
- 修复了配置 TextFindParameter.WholeWord 查找关键词不正确的问题。
- 修复了 BeginMarkedContent 方法在传入 ArtifactPropertyList 对象时,内容流标记未正确包含属性占位符的问题。
- 修复了创建模板复制页面内容,印章变形的问题。
- 修复了并发转换 HTML 到 PDF,偶发性出现结果文档不生成的问题。
- 修复了打印 PDF 多出其他内容的问题。
- 修复了同名的文本框域无法建立关联的问题。
- 修复了转换 PDF 到图片,部分内容丢失的问题。
- 修复了合并 PDF,程序抛出 ArgumentOutRangeException 异常的问题。
- 修复了在未应用授权的情况下合并PDF文档,程序抛出 ArgumentOutRangeException 异常的问题。
- 修复了转换 PDF 到 PDF/A,文档属性中的描述不正确的问题。
- 修复了获取 PDF 中视频的位置和尺寸信息失败的问题。







