Spire.Office 9.3.1 已发布。在该版本中,Spire.Doc 支持解析 Word 文档中的 GIF 格式内容;Spire.XLS 支持数据透视表分组功能;Spire.Presentation 新增 AI 功能并支持设置 PPTX 转 SVG 的转换选项;Spire.DocViewer 支持 WPF 和 MAUI 平台;Spire.PDFViewer 支持获取鼠标点击时相对于 PDF 页面内容的坐标。此外,许多已知问题也在该版本中成功修复。详情请阅读以下内容。
该版本涵盖了最新版的 Spire.Doc,Spire.PDF,Spire.XLS,Spire.Email,Spire.DocViewer,Spire.PDFViewer,Spire.Presentation,Spire.Spreadsheet,Spire.OfficeViewer,Spire.Barcode,Spire.DataExport。
版本信息如下:
- Spire.Doc.dll v12.2.10
- Spire.Pdf.dll v10.3.7
- Spire.XLS.dll v14.3.3
- Spire.Presentation.dll v9.3.4
- Spire.Barcode.dll v7.2.9
- Spire.Spreadsheet.dll v7.4.6
- Spire.Email.dll v6.5.10
- Spire.DocViewer.Forms.dll v8.7.8
- Spire.PdfViewer.Forms.dll v7.12.11
- Spire.PdfViewer.Asp.dll v7.12.11
- Spire.OfficeViewer.Forms.dll v8.7.6
- Spire.DataExport.dll v4.9.0
- Spire.DataExport.ResourceMgr.dll v2.1.0
https://www.e-iceblue.cn/Downloads/Spire-Office-NET.html
Spire.Doc
新功能:
- 支持解析Word文档中的GIF格式内容。
问题修复:
- 修复了获取出的项目符号不正确的问题。
- 修复了邮件合并后,GIF格式被转换为PNG格式的问题。
- 修复了转换Word文档到PDF文档后,私有字体嵌入失败的问题。
- 修复了转换Word文档到PDF文档后,字符不正确的问题。
- 修复了在MAC系统上转换Word文档到PDF文档时,读取字体失败的问题。
- 修复了加载一个Docx文档时,程序抛出System.NullReferenceException异常的问题。
- 修复了加载一个Docx文档并另存为新文档后,表格多出边框的问题。
- 修复了比较两个Word文档时,程序抛出System.ArgumentException异常的问题。
- 修复了获取页面数量时程序挂起的问题。
- 修复了比较两个Word文档时,程序抛出System.InvalidCastException异常的问题。
Spire.XLS
新功能:
- 支持数据透视表分组功能。
- 支持对CellRange添加FindAll()方法。
- 支持为透视表设置“Repeat All Item Labels”。
XlsPivotTable pt = worksheet.PivotTables[0] as XlsPivotTable;
IPivotField field = pt.RowFields[0];
DateTime start = new DateTime(2024, 5, 6);
DateTime end = new DateTime(2024, 10, 6);
PivotGroupByTypes[] types = new PivotGroupByTypes[]{ PivotGroupByTypes.Days };
field.CreateGroup(start, end, types, 1);
Workbook workbook = new Workbook();
workbook.LoadFromFile(@"test.xlsx");
Worksheet sheet = workbook.Worksheets[0];
sheet.Range["A1"].FindAll()
foreach (XlsPivotTable pt in wb.Worksheets["PivotTable"].PivotTables)
{
pt.Options.RepeatAllItemLabels = true;
}
问题修复:
- 修复了保存Excel文件后内容不正确的问题。
- 修复了使用ExportDataTable导出sheet后,内容不正确的问题。
- 修复了将Excel转换为PDF后,公式值不正确的问题。
- 修复了将Excel转换为图片时,程序抛出“Size of image is too large”异常的问题。
- 修复了将Excel转换为图片后,透视表的列名不一致的问题。
- 修复了使用CellRange.Comment.Text后,结果文档多出空白注释的问题。
- 修复了将Excel转换为PDF后样式不正确的问题。
- 修复了加载文件时,程序抛出“ArgumentNullException”异常的问题。
- 修复了拆分文档时,程序抛出“NullReferenceException”异常的问题。
Spire.PDF
问题修复:
- 优化了多个 TIFF 转 PDF 过程中内存消耗高的问题。
- 修复了打印 PDF 时程序抛出 "System.NullReferenceException" 异常的问题。
- 修复了转为灰度 PDF 后部分内容还是彩色的问题。
- 修复了使用 split() 方法时,程序抛出 "System.NullReferenceException" 异常的问题。
- 修复了提取文本时程序抛出 "System.IndexOutOfRangeException" 异常的问题。
- 修复了查找高亮文本的结果不正确的问题。
- 修复了用 PdfCode39Barcode 对带 “*” 的数据生成条码时程序抛异常的问题。
- 修复了数字签名验证结果不正确的问题。
- 修复了 PDF 转 PPT 后,空格消失的问题。
- 修复了保存 PDF 文档时程序抛出 “Empty convert-string” 异常的问题。
- 修复了加载 PDF 文档时程序抛出 “System.OverflowException” 异常的问题。
- 修复了 PDF 转 XPS 时程序抛出 “System.ArgumentException” 异常的问题。
- 修复了无法获取表单按钮域的动作的 JavaScript 代码的问题。
Spire.Presentation
新功能:
- 支持获取 PPT 默认字体样式。
- 新增 SaveToSvgOption 用于设置 PPTX 转 Svg 的转化选项。
- 在 ILayout 类中新增属性用于显示背景形状
Presentation presentation = new Presentation();
presentation.LoadFromFile(inputFile);
IAutoShape shape = presentation.Slides[0].Shapes[0] as IAutoShape;
DefaultTextRangeProperties format = shape.TextFrame.Paragraphs[0].TextRanges[0].DisPlayFormat;
File.AppendAllText(outputFile, "text :" + shape.TextFrame.Paragraphs[0].TextRanges[0].Text + "\r\n");
File.AppendAllText(outputFile, "is bold :" + format.IsBold + "\r\n");
File.AppendAllText(outputFile, "is italic :" + format.IsItalic + "\r\n");
Presentation ppt = new Presentation();
ppt.LoadFromFile(inputFile);
ppt.SaveToSvgOption.SaveUnderlineAsDecoration = true;
byte[] svgByte = ppt.Slides[0].Shapes[0].SaveAsSvgInSlide();
FileStream fs = new FileStream(outputFile + "1.svg", FileMode.Create);
fs.Write(svgByte, 0, svgByte.Length);
fs.Close();
Presentation presentation = new Presentation();
presentation.LoadFromFile(@"in.pptx");
bool showMasterShape = presentation.Slides[1].Layout.ShowMasterShapes;
问题修复:
- 修复了 PPTX 转 SVG 渐变色不正确的问题。
- 修复了 PPTX 转 PDF 图片质量降低的问题。
- 修复了形状转 SVG 文本空格丢失的问题。
- 修复了加载保存 PPTX 文档内容不正确的问题。
主要 AI 功能及对应的 API:
功能 | API |
文本润色 | public string Polish(IShape shape, string language); |
翻译 | public string Translate(ISlide slide, string language); |
总结 | public string Summarize(IShape shape, string language); |
幻灯片生成 | public Presentation Generate(string describe, string language, bool genareteBackGroundImage); |
提问 | public string Ask(string question, bool enableHistory = false); |
文档搜索 | public string DocumentSearch(string question, string file_server_path, bool enableHistory = false); |
图片生成 | public Stream ImageGenerate(string description); |
Spire.DocViewer
新功能:
- 支持 .NET 6.0,包括 WPF 和 Windows Form。
- 支持 MAUI 平台(.NET 7.0),目前仅支持 Windows 和 Android。
Spire.PDFViewer
新功能:
- Spire.PdfDocumentViewer控件支持了获取鼠标点击时相对于PDF页面内容的坐标。
private void Form1_Load(object sender, EventArgs e)
{
this.pdfDocumentViewer1.LoadFromFile("1.pdf");
this.pdfDocumentViewer1.MouseDown += new MouseEventHandler(PV_Click);
}
private void PV_Click(object sender, MouseEventArgs e)
{
string outputFile = "out.Pdf";
string outputFile_TXT = "out.txt";
File.Delete(outputFile_TXT);
if (e.Button == MouseButtons.Left)
{
PointF[] controlPositions = new PointF[] { e.Location};
Spire.PdfViewer.Forms.PagePosition[] pagePositions = this.pdfDocumentViewer1.ControlToPage(controlPositions);
string fileName = this.pdfDocumentViewer1.FileName;
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(fileName,FileFormat.PDF);
PdfPageBase page = doc.Pages[pagePositions[0].PageIndex];
RectangleF bounds = new RectangleF(pagePositions[0].Position, new SizeF(100, 100));
PdfTextExtractor textExtractor = new PdfTextExtractor(page);
PdfTextExtractOptions option = new PdfTextExtractOptions();
option.ExtractArea = bounds;
string text = textExtractor.ExtractText(option);
PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 11);
PdfTextWidget pdfTextbox = new PdfTextWidget();
pdfTextbox.Font = font;
pdfTextbox.Brush = PdfBrushes.Red;
pdfTextbox.Text = "stamp";
pdfTextbox.Draw(page, bounds);
doc.Pages[pagePositions[0].PageIndex].Canvas.DrawRectangle(PdfPens.Red, bounds);
doc.SaveToFile(outputFile);
File.AppendAllText(outputFile_TXT, "Position: " + pagePositions[0].Position.ToString() + "\ntext:\r\n " + text);
MessageBox.Show("finish");
doc.Dispose();
}
}