Spire.Office 10.9.0 现已发布。在这个版本中,Spire.Doc 提供了用于细粒度文档样式控制的核心接口;Spire.XLS 支持创建和修改公式;Spire.Presentation 修复了文档无法打开的问题;Spire.PDF 改进了 OFD 到 PDF 的转换;Spire.DocViewer 调整了与安全相关的依赖项;Spire.PDFViewer 添加了一个跨平台的 .NET 7.0 版本;Spire.Barcode 修复了字体应用问题。此外,本版本成功修复了许多已知问题。更多详细信息见下文。
该版本涵盖了最新版的 Spire.Doc、Spire.PDF、Spire.XLS、Spire.Presentation、Spire.Barcode、Spire.Email、Spire.DocViewer、Spire.PDFViewer、Spire.OfficeViewer 和 Spire.DataExport。
版本信息如下:
- Spire.Doc.dll v13.9.10
- Spire.Pdf.dll v11.9.17
- Spire.XLS.dll v15.9.7
- Spire.Presentation.dll v10.9.3
- Spire.Barcode.dll v7.4.1
- Spire.Email.dll v6.6.3
- Spire.DocViewer.Forms.dll v8.9.4
- Spire.PdfViewer.Asp.dll v8.2.1
- Spire.PdfViewer.Forms.dll v8.2.1
- Spire.Spreadsheet.dll v7.5.2
- Spire.OfficeViewer.Forms.dll v8.8.0
- Spire.DataExport.dll 4.9.0
- Spire.DataExport.ResourceMgr.dll v2.1.0
获取Spire.Office 10.9.0,请点击:
https://www.e-iceblue.cn/Downloads/Spire-Office-NET.html
Spire.Doc
新功能:
- 公开类 PdfDigitalSignatureHashAlgorithm、PdfDigitalSignatureInfo 和 PdfDigitalSignatureTimestampConfiguration,实现保存 PDF 文档时添加数字签名和时间戳的功能。
- Bookmark 对象公开 FirstColumn 和 LastColumn 属性,支持获取书签开始所在的列和结束所在的列。
- 新增 SearchOptions 类,支持在替换文本时选择忽略或包含 OfficeMath 公式文本。
- 新增 PageLayout 属性,支持在转换到 PDF 时设置页面布局。 Default:不写出值,按照PDF阅读器的默认视图显示; SinglePage:单页视图; OneColumn:单页连续视图; TwoColumnLeft:双页连续视图,奇数页靠左; TwoColumnRight:双页连续视图,奇数页靠右; TwoPageLeft:双页视图,奇数页靠左; TwoPageRight:双页视图,奇数页靠右。
- 公开 ICharacterStyle、IListStyle和 ITableStyle 等核心接口,支持更精细的文档样式控制。
- Style接口移除了CharacterFormat属性,此属性分别在TableStyle,ParagraphStyle和CharacterStyle接口中进行实现。
- Style接口提供RemoveSelf()的方法,支持移除样式。
- TableStyle 实现 ITableStyle 接口。同时新增 TableConditionalStyle、TableConditionalStyleCollection 和 TableConditionalStyleType 类型,支持对表格的奇偶行、奇偶列等条件格式进行精细化控制。
- Table.TableStyleName 属性已标记为过时,建议使用 table.Format.StyleName替换。增加Table.Format.Style 和 Table.ApplyStyle(ITableStyle) 应用表格样式。
- TableFormat类提供了Style,StyleOptions,StyleName 属性以及 TableStyleOptions 枚举。
- Document类新增AddStyle(DefaultTableStyle builtinStyle) 方法,支持添加预置表格样式。
Document sDoc = new Document();
sDoc.LoadFromFile(inputFile);
ToPdfParameterList toPdfParameter = new ToPdfParameterList();
toPdfParameter.DigitalSignatureInfo = new PdfDigitalSignatureInfo(pfxInputFile, pfxPassword, "Test signing", "Spire Doc"); // 数字签名
toPdfParameter.DigitalSignatureInfo.HashAlgorithm = PdfDigitalSignatureHashAlgorithm.RipeMD160;
toPdfParameter.DigitalSignatureInfo.SignatureDate = nowDateTime;
toPdfParameter.DigitalSignatureInfo.TimestampConfiguration = new PdfDigitalSignatureTimestampConfiguration("https://freetsa.org/tsr", "bill", "Password"); // 时间戳
sDoc.SaveToFile(outputFile3, toPdfParameter);
int firstColumn = doc.Bookmarks["t_insert"].FirstColumn;
int lastColumn = doc.Bookmarks["t_insert"].LastColumn;
SearchOptions op = new SearchOptions();
op.IgnoreOfficeMath = false;
doc.Replace("ab","new", op);
Document doc = new Document("xx.docx");
ToPdfParameterList toPdf = new ToPdfParameterList(){ PageLayout = PdfPageLayout.TwoColumnLeft };
doc.SaveToFile("xx.pdf", toPdf);
IStyle style = document.Styles.FindByName("Normal");
if (style != null && style is ICharacterStyle)
{
ICharacterStyle cStyle = style as ICharacterStyle;
cStyle.CharacterFormat.FontName = "cambria";
cStyle.CharacterFormat.FontSize = 14;
cStyle.CharacterFormat.Bold = true;
cStyle.CharacterFormat.TextColor = Color.FromArgb(42, 123, 136);
}
string pStyleName = "testStyle";
Document document = new Document();
ParagraphStyle pStyle = (ParagraphStyle)document.Styles.Add(StyleType.ParagraphStyle, pStyleName);
pStyle.CharacterFormat.FontName = "Calibri";
pStyle.CharacterFormat.FontSize = 16;
pStyle.CharacterFormat.Bold = true;
pStyle.CharacterFormat.TextColor = Color.DarkRed;
Section section = document.AddSection();
Paragraph para = section.AddParagraph();
para.ApplyStyle(pStyle);
para.AppendText("Hello world!");
Style firstParaStyle = document.FirstSection.Body.FirstParagraph.Format.Style;
document.SaveToFile(outputDocxFile1, FileFormat.Docx);
document.Styles[pStyleName].RemoveSelf();
document.SaveToFile(outputDocxFile2, FileFormat.Docx);
Document doc = new Document();
Section section = doc.AddSection();
Table table = section.AddTable();
table.ResetCells(15, 4);
for (int i = 0; i < 15; i++)
{
TableRow row = table.Rows[i];
for (int j = 0; j < 4; j++)
{
TableCell cell = row.Cells[j];
cell.AddParagraph().AppendText(string.Format("{0} column.", (j % 2 == 0 ? "Even" : "Odd")));
cell.AddParagraph().AppendText(string.Format("Row banding {0}", (i % 3 == 0 ? "start" : "continuation")));
}
}
TableStyle tableStyle = (TableStyle)doc.Styles.Add(StyleType.TableStyle, "TestTableStyle1");
tableStyle.Borders.Color = Color.Black;
tableStyle.Borders.BorderType = BorderStyle.Double;
tableStyle.RowStripe = 3;
tableStyle.ConditionalStyles[TableConditionalStyleType.OddRowStripe].Shading.BackgroundPatternColor = Color.LightBlue;
tableStyle.ConditionalStyles[TableConditionalStyleType.EvenRowStripe].Shading.BackgroundPatternColor = Color.LightCyan;
tableStyle.ColumnStripe = 1;
tableStyle.ConditionalStyles[TableConditionalStyleType.EvenColumnStripe].Shading.BackgroundPatternColor = Color.LightPink;
table.ApplyStyle(tableStyle);
table.Format.StyleOptions = table.Format.StyleOptions | TableStyleOptions.ColumnStripe;
doc.SaveToFile(outputDocxFile1, FileFormat.Docx);
Document doc = new Document();
Section section = doc.AddSection();
TableStyle tableStyle = (TableStyle)doc.Styles.Add(StyleType.TableStyle, "TestTableStyle1");
tableStyle.HorizontalAlignment = RowAlignment.Center;
tableStyle.Borders.Color = Color.Blue;
tableStyle.Borders.BorderType = BorderStyle.Single;
Table table = section.AddTable();
table.ResetCells(1, 1);
table.Rows[0].Cells[0].AddParagraph().AppendText("Aligned to the center of the page");
table.PreferredWidth = PreferredWidth.FromPoints(300);
table.ApplyStyle(tableStyle);
section.AddParagraph().AppendText(" ");
tableStyle = (TableStyle)doc.Styles.Add(StyleType.TableStyle, "TestTableStyle2");
tableStyle.LeftIndent = 55;
tableStyle.Borders.Color = Color.Green;
tableStyle.Borders.BorderType = BorderStyle.Single;
table = section.AddTable();
table.ResetCells(1, 1);
table.Rows[0].Cells[0].AddParagraph().AppendText("Aligned according to left indent");
table.PreferredWidth = PreferredWidth.FromPoints(300);
table.Format.Style = tableStyle;
doc.SaveToFile(outputDocxFile1, FileFormat.Docx);
Document doc = new Document();
Section section = doc.AddSection();
Table table = section.AddTable();
table.ResetCells(15, 4);
for (int i = 0; i < 15; i++)
{
TableRow row = table.Rows[i];
for (int j = 0; j < 4; j++)
{
TableCell cell = row.Cells[j];
cell.AddParagraph().AppendText(string.Format("{0} column.", (j % 2 == 0 ? "Even" : "Odd")));
cell.AddParagraph().AppendText(string.Format("Row banding {0}", (i % 2 == 0 ? "Even" : "Odd")));
}
}
TableStyle tableStyle = doc.AddStyle(DefaultTableStyle.LightListAccent3);
table.ApplyStyle(tableStyle);
doc.SaveToFile(outputDocxFile1, FileFormat.Docx);
问题修复:
- 修复了解析 LaTeX 公式不正确的问题。
- 修复了转换 Word 到 PDF 时表格样式不一致的问题。
- 修复了转换 Word 到 PDF 时页眉图片被遮盖的问题。
- 修复了转换 Word 到 PDF 时文本位置不正确的问题。
- 修复了转换 Word 到 PDF 时段落缩进不正确的问题。
- 修复了转换 Word 到 PDF 时表格内容发生偏移的问题。
- 修复了转换 Word 到 PDF 时表格列宽不正确的问题。
- 修复了转换 Word 到 PDF 时多出空白页的问题。
- 修复了转换 Word 到 PDF 时程序抛出 System.NullReferenceException 异常的问题。
- 修复了加载 Word 文档时程序抛出 ArgumentOutOfRangeException 异常的问题。
- 修复了获取页面数量不正确的问题。
Spire.XLS
优化:
- 优化了转换 Excel 到 PDF 的耗时。
- 优化了转换 Excel 到 HTML 的耗时。
新功能:
- 新增 IXlsEquation 公式接口,支持创建和修改数学公式。
- 支持转换 Excel 到 HTML 时保留冻结的行。
- 支持 ISOMITTED 函数。
- 支持 LAMBDA 函数。
Workbook workbook = new Workbook();
workbook.LoadFromFile("Equation_1.xlsx");
Worksheet sheet = workbook.Worksheets[0];
//添加公式
sheet.Equations.AddEquation(1, 1, 50, 50, "\frac{A}{B}");
// 获取该工作表中的第一个公式对象
IXlsEquation equation = sheet.Equations[0];
// 使用 LaTeX 语法更新该公式的文本内容
equation.UpdateByLatexText("\\text{tan}\\frac{\\alpha}{2}=\\frac{\\text{sin}\\alpha}{1+ \\text{cos}\\alpha}");
// 设置公式在工作表中的位置和大小
equation.Top = 19;
equation.Left = 72;
equation.Width = 100;
equation.Height = 100;
// 获取该工作表中的第二个公式对象
IXlsEquation equation1 = sheet.Equations[1];
// 获取该公式的子项集合
IEquationItemCollection equationItems = equation1.EquationItems;
// 获取第一个子项
IEquationItem item1 = equationItems[0];
item1.Text = "e-iceblue";
// 在公式末尾添加一个新的 LaTeX 公式
equationItems.AddByLatex("\\frac{n!}{r!(n-r)!} ");
// 在索引为 0 的位置插入一个 LaTeX 公式
equationItems.InsertByLatex(0, "\\Delta A B C");
workbook.SaveToFile("out.xlsx");
HTMLOptions.Default.IsSaveFreezedPanes = true; //true为保留冻结效果,false为不保留
sheet.Range["D7"].Formula = "=LAMBDA(val,max,IF(ISOMITTED(max),val,IF(AND(val>0,val
sheet.Range["D5"].Formula = "=LAMBDA(a,b,IF(ISOMITTED(b),a*a,a*b))(A1,A2)";
问题修复:
- 修复了获取行高不正确的问题。
- 修复了转换Excel到PDF,文本框丢失的问题。
- 修复了转换Excel到PDF,文本框中的文本对齐方式不正确的问题。
- 修复了转换Excel到PDF,数据不正确的问题。
- 修复了转换Excel到PDF,内容不正确的问题。
- 修复了转换Excel到PDF,效果不正确的问题。
- 修复了转换Excel到PDF,边框不正确的问题。
- 修复了复制含有Slicer的工作表到其他工作簿,程序抛出异常“System,ArgumentOutOfRangeException”的问题。
- 增强对包含错误值的 NamedRange 的兼容性处理。
- 修复了转换Excel到图片,图表格式不正确的问题。
Spire.PDF
新功能:
- NETStandard dll 新增 SaveAsImage(int pageIndex, int dpiX, int dpiY) 方法支持转换 PDF 到图片时自定义图片 DPI。
- NETStandard dll 新增 Collate 属性支持设置多份打印的顺序。
// true:逐份打印 ; 默认false:逐页打印
doc.PrintSettings.Collate = true;
问题修复:
- 修复了使用 NETStandard dll 转换 PDF 到图片,内存消耗高的问题。
- 修复了查找文本,获取其字体名称不准确的问题。
- 修复了转换 OFD 到 PDF,效果不正确的问题。
- 修复了转换 PDF 到 XPS,注释内容不显示的问题。
- 修复了加载 PDF 文档,程序抛出 “Unexpected token before 158586” 异常的问题。
- 修复了提取文本,程序抛出 “ArgumentOutOfRangeException” 异常的问题。
- 修复了转换 OFD 到 PDF,程序抛出 “未知的注释类取值:‘Free Text’” 异常的问题。
- 修复了绘制文本,部分字体无法正确嵌入的问题。
- 修复了希伯来语与英语混合文本绘制时顺序错误的问题。
- 修复了阿拉伯语文本在 TextBox 表单域中显示异常的问题。
- 修复了文本提取后重新绘制导致出现多余字符的问题。
- 修复了绘制阿拉伯文文本效果不正确的问题。
- 修复了转换 OFD 到 PDF 时线条被加粗的问题。
- 修复了提取页面文本时程序抛出异常的问题。
- 修复了调用 .NET Standard DLL 打印 PDF 文档失败的问题。
Spire.Presentation
问题修复:
- 修复了在多页 PPT 中将 SVG 插入指定 Shape 时意外创建新幻灯片的问题。
- 修复了在 .NET 9.0 平台使用 netstandard 库时,生成文档无法正常打开的问题
Spire.Barcode
调整:
- NET Core和.NET Standard平台删除了对这三个外部包“System.Security.Cryptography.Pkcs”、“System.Security.Permissions”、“System.Security.Cryptography.Xml”的依赖。
修复:
- 修复了创建条码时,应用个别字体不生效的问题。
Spire.DocViewer
调整:
- 移除了 "System.Security.Cryptography.Pkcs"、"System.Security.Permissions" 和"System.Security.Cryptography.Xml" 依赖项。
- 优化了平台专用的 .NET 7.0-Android33.0 与 .NET 7.0-Windows10.0.19041 版本。
新功能:
- 推出跨平台的 .NET 7.0 版本,支持在所有操作系统上运行
Spire.PDFViewer
调整:
- 优化了平台专用的.NET 7.0-Windows10.0.19041 版本,确保对系统特性和 API 的完整支持。
新功能:
- 推出了跨平台的 .NET 7.0 版本,支持在所有操作系统上运行。