Spire.Office 8.5.3 已发布。在该版本中,Spire.XLS 新增支持 ISO.CEILING 和 WORKDAY.INTL 函数,以及 WPS 中的 EVALUATE() 函数;Spire.Doc 支持了添加图表的功能;Spire.PDF 优化了压缩 PDF 文档的功能。此外,本次更新还成功修复了大量已知问题。详情请阅读以下内容。
该版本涵盖了最新版的 Spire.Doc,Spire.PDF,Spire.XLS,Spire.Email,Spire.DocViewer, Spire.PDFViewer,Spire.Presentation,Spire.Spreadsheet, Spire.OfficeViewer, Spire.DocViewer, Spire.Barcode, Spire.DataExport。
版本信息如下:
- Spire.Doc.dll v11.5.6
- Spire.Pdf.dll v9.5.4
- Spire.XLS.dll v13.5.1
- Spire.Presentation.dll v8.4.1
- Spire.Email.dll v6.5.7
- Spire.DocViewer.Forms.dll v8.5.1
- Spire.PdfViewer.Forms.dll v8.5.0
- Spire.PdfViewer.Asp.dll v8.5.0
- Spire.Spreadsheet.dll v7.4.2
- Spire.OfficeViewer.Forms.dll v8.5.3
- Spire.Barcode.dll v7.2.1
- Spire.DataExport.dll v4.8.0
- Spire.DataExport.ResourceMgr.dll v2.1.0
https://www.e-iceblue.cn/Downloads/Spire-Office-NET.html
Spire.Doc
新功能:
- 支持了添加图表的功能。
- 支持了添加SVG文档的功能。
- 支持打印多页到一页的功能。
- 支持了操作页面的功能比如获取页面的内容以及内容的坐标。
//创建word文档
Document document = new Document();
//新建一个节
Section section = document.AddSection();
//创建新段落并附加文本
section.AddParagraph().AppendText("Column chart.");
//创建一个新节以附加柱形图
Paragraph newPara = section.AddParagraph();
ShapeObject shape = newPara.AppendChart(ChartType.Column, 500, 300);
//清除图表的系列数据,以一个干净的图表开始。
Chart chart = shape.Chart;
chart.Series.Clear();
//将自定义系列添加到图表中,其中X轴为类别,Y轴为相应的大数值。
chart.Series.Add("Test Series",
new[] { "Word", "PDF", "Excel", "GoogleDocs", "Office" },
new double[] { 1900000, 850000, 2100000, 600000, 1500000 });
//将Y轴刻度标签的数字格式设置为使用逗号对数字进行分组。
chart.AxisY.NumberFormat.FormatCode = "#,##0";
//保存结果文档
document.SaveToFile("AppendColumnChart.docx", FileFormat.Docx);
//创建word文档
Document document = new Document();
//新建一个节
Section section = document.AddSection();
//创建新段落并附加文本
section.AddParagraph().AppendText("Bubble chart.");
//创建一个新段落并打开气泡图
Paragraph newPara = section.AddParagraph();
ShapeObject shape = newPara.AppendChart(ChartType.Bubble, 500, 300);
//清除字符的序列数据,以一个干净的图表开始
Chart chart = shape.Chart;
chart.Series.Clear();
// 添加带有X/Y坐标和每个气泡直径的自定义系列
ChartSeries series = chart.Series.Add("Test Series",
new[] { 2.9, 3.5, 1.1, 4.0, 4.0 },
new[] { 1.9, 8.5, 2.1, 6.0, 1.5 },
new[] { 9.0, 4.5, 2.5, 8.0, 5.0 });
//保存doc文件
document.SaveToFile("AppendBubbleChart.docx", FileFormat.Docx);
//创建word文档
Document document = new Document();
//新建一个节
Section section = document.AddSection();
//创建新段落并附加文本
section.AddParagraph().AppendText("Line chart.");
//创建一个新段落以附加折线图
Paragraph newPara = section.AddParagraph();
ShapeObject shape = newPara.AppendChart(ChartType.Line, 500, 300);
//清除折线图的系列数据以从干净的图表开始
Chart chart = shape.Chart;
ChartTitle title = chart.Title;
title.Text = "My Chart";
ChartSeriesCollection seriesColl = chart.Series;
seriesColl.Clear();
//在图表内设置新数据
string[] categories = { "C1", "C2", "C3", "C4", "C5", "C6" };
seriesColl.Add("AW Series 1", categories, new double[] { 1, 2, 2.5, 4, 5, 6 });
seriesColl.Add("AW Series 2", categories, new double[] { 2, 3, 3.5, 6, 6.5, 7 });
//保存doc文件
document.SaveToFile("AppendLineChart.docx", FileFormat.Docx);
//创建word文档
Document document = new Document();
//新建一个节
Section section = document.AddSection();
//创建新段落并附加文本
section.AddParagraph().AppendText("Pie chart.");
//创建一个新段落以附加饼图
Paragraph newPara = section.AddParagraph();
ShapeObject shape = newPara.AppendChart(ChartType.Pie, 500, 300);
Chart chart = shape.Chart;
//插入一个自定义图表系列,其中包含每个扇区的类别名称及其频率值。
ChartSeries series = chart.Series.Add("Test Series",
new[] { "Word", "PDF", "Excel" },
new[] { 2.7, 3.2, 0.8 });
//保存到docx文件。
document.SaveToFile("AppendPieChart.docx", FileFormat.Docx);
//创建word文档
Document document = new Document();
//新建一个节
Section section = document.AddSection();
//创建新段落并附加文本
section.AddParagraph().AppendText("Scatter chart.");
//创建一个新段落以附加散点图
Paragraph newPara = section.AddParagraph();
ShapeObject shape = newPara.AppendChart(ChartType.Scatter, 450, 300);
Chart chart = shape.Chart;
//清除图表的系列数据,以一个干净的图表开始
chart.Series.Clear();
//插入五个点的X/Y坐标系列
chart.Series.Add("Scatter chart",
new[] { 1.0, 2.0, 3.0, 4.0, 5.0 },
new[] { 1.0, 20.0, 40.0, 80.0, 160.0 });
//保存到docx文件
document.SaveToFile("AppendScatterChart.docx", FileFormat.Docx);
//创建word文档
Document document = new Document();
//新建一个节
Section section = document.AddSection();
//创建新段落并附加文本
section.AddParagraph().AppendText("Surface3D chart.");
//创建新段落以附加曲面三维图表
Paragraph newPara = section.AddParagraph();
ShapeObject shape = newPara.AppendChart(ChartType.Surface3D, 500, 300);
//清除其系列数据,以一个干净的图表开始
Chart chart = shape.Chart;
chart.Series.Clear();
chart.Title.Text = "My chart";
//添加三个系列
chart.Series.Add("Series 1",
new string[] { "Word", "PDF", "Excel", "GoogleDocs", "Office" },
new double[] { 1900000, 850000, 2100000, 600000, 1500000 });
chart.Series.Add("Series 2",
new string[] { "Word", "PDF", "Excel", "GoogleDocs", "Office" },
new double[] { 900000, 50000, 1100000, 400000, 2500000 });
chart.Series.Add("Series 3",
new string[] { "Word", "PDF", "Excel", "GoogleDocs", "Office" },
new double[] { 500000, 820000, 1500000, 400000, 100000 });
//保存到docx文件.
document.SaveToFile("AppendSurface3DChart.docx", FileFormat.Docx);
//创建word文档
Document document = new Document();
//新建一个节
Section section = document.AddSection();
//创建新段落并附加文本
section.AddParagraph().AppendText("Bar chart.");
//创建一个新段落以附加条形图
Paragraph newPara = section.AddParagraph();
ShapeObject chartShape = newPara.AppendChart(ChartType.Bar, 400, 300);
Chart chart = chartShape.Chart;
//使用“标题”属性为条形图提供一个标题,该标题显示在图表区域的顶部中心。
ChartTitle title = chart.Title;
title.Text = "My Chart";
//将“Show”属性设置为“true”以使标题可见。
title.Show = true;
//将“Overlay”属性设置为“true”。允许其他图表元素与标题重叠,从而给它们更多的空间
title.Overlay = true;
//保存到docx文件
document.SaveToFile("AppendBarChart.docx", FileFormat.Docx);
Document document = new Document();
Section section = document.AddSection();
string svgFile = "sample.svg";
Paragraph para = section.AddParagraph();
DocPicture svgPicture = para.AppendPicture(svgFile);
svgPicture.Width = 200;
svgPicture.Height = 200;
String DocxResult = "Result-AddSvg.docx";
document.SaveToFile(DocxResult, FileFormat.Docx2016);
Document doc = new Document();
doc.LoadFromFile(inputFile, FileFormat.Docx);
System.Windows.Forms.PrintDialog printDialog = new System.Windows.Forms.PrintDialog();
printDialog.PrinterSettings.PrintToFile = true;
printDialog.PrinterSettings.PrintFileName = "sample-new-4.xps";
doc.PrintDialog = printDialog;
doc.PrintMultipageToOneSheet(PagesPreSheet.FourPages, true);
Document doc = new Document();
doc.LoadFromFile(inputFile, FileFormat.Docx);
FixedLayoutDocument layoutDoc = new FixedLayoutDocument(doc);
// 访问第一页的行并打印到控制台。
FixedLayoutLine line = layoutDoc.Pages[0].Columns[0].Lines[0];
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine("Line: " + line.Text);
//使用渲染的行,可以返回文档对象模型中的原始段落。
Paragraph para = line.Paragraph;
stringBuilder.AppendLine("Paragraph text: " + para.Text);
// 以纯文本格式(包括页眉和页脚)检索第一页上显示的所有文本。
string pageText = layoutDoc.Pages[0].Text;
stringBuilder.AppendLine(pageText);
// 循环遍历文档中的每一页,并打印每页上显示的行数。
foreach (FixedLayoutPage page in layoutDoc.Pages)
{
LayoutCollection lines = page.GetChildEntities(LayoutElementType.Line, true);
stringBuilder.AppendLine("Page " + page.PageIndex + " has " + lines.Count + " lines.");
}
// 此方法为任何给定节点提供布局实体的反向查找
// (页眉和页脚中的管路和节点除外)。
stringBuilder.AppendLine("The lines of the first paragraph:");
foreach (FixedLayoutLine paragraphLine in layoutDoc.GetLayoutEntitiesOfNode(
((Section)doc.FirstChild).Body.Paragraphs[0]))
{
stringBuilder.AppendLine(paragraphLine.Text.Trim());
stringBuilder.AppendLine(paragraphLine.Rectangle.ToString());
}
File.WriteAllText("page.txt", stringBuilder.ToString());
Spire.XLS
新功能:
- 支持了ISO.CEILING函数。
- 支持了WORKDAY.INTL函数。
- 支持了WPS中的EVALUATE()函数。
Workbook workbook = new Workbook();
workbook.Worksheets[0].Range["A1"].Formula = "ISO.CEILING(12.69,2)";
workbook.CalculateAllValue();
workbook.SaveToFile("result.xlsx",ExcelVersion.Version2016);
Workbook workbook = new Workbook();
workbook.Worksheets[0].Range["A1"].Formula = "=WORKDAY.INTL(DATE(2023,3,17),25,1,DATE(2023,3,20))";
workbook.CalculateAllValue();
workbook.SaveToFile("result.xlsx",ExcelVersion.Version2016);
问题修复:
- 修复了并发转换Sheet到HTML程序抛System.ArgumentException异常的问题。
- 修复了填充部分单元格颜色时其他单元格也被填充的问题。
- 修复了拷贝部分单元格失败的问题。
- 修复了转换Excel到HTML时程序抛异常System.OutOfMemoryException的问题。
- 修复了加载Excel文档时程序抛异常System.IndexOutOfRangeException的问题。
- 修复了保存文档后菜单栏功能区不正确的问题。
- 修复了删除隐藏行后生成很多空白列的问题。
- 修复了使用.netstandard包转换Sheet到图片内容不正确的问题。
Spire.PDF
新功能:
- 优化了压缩 PDF 文档的功能。
PdfCompressor compressor = new PdfCompressor("input.pdf");
compressor.Options.TextCompressionOptions.UnembedFonts = true;
compressor.Options.ImageCompressionOptions.CompressImage = true;
compressor.Options.ImageCompressionOptions.ResizeImages = true;
compressor.Options.ImageCompressionOptions.ImageQuality = ImageQuality.Low;
compressor.CompressToFile("output.pdf");
问题修复:
- 修复了插入含有 <ul> 等标签的 HTML 代码不生效的问题。
- 修复了复制 PDF 页面后结果文档用 Adobe 工具打开失败的问题。
- 修复了转换 PDF 到 Word,文本换行不正确的问题。
- 修复了转换 PDF 到图片,单词之间空格消失的问题。
- 修复了高亮文本失败的问题。
- 修复了扁平化表单域后保存文档时程序报空指针异常的问题。
- 修复了打印带有注释的 PDF 文件时注释丢失的问题。
- 修复了提取 PDF 的表格结果不正确的问题。
- 修复了转换 PDF 到 OFD 程序报 System.InvalidOperationException 异常的问题。
- 修复了提取的文本超出表格范围的问题。
- 修复了 PdfAnnotationBorder border = new PdfAnnotationBorder() {Width = 20f} 方法设置宽度不生效的问题。
- 修复了填充 XFA Form 域的值失败的问题。
- 修复了转换 OFD 到 PDF 程序报 System.ArgumentException 异常的问题。
Spire.Email
问题修复:
- 修复了在NetFramework应用程序中使用时,无法连接到Imap服务器和Pop3服务器的问题。