Spire.Office for Python 10.12.0 已正式发布。在该版本中,Spire.Doc for Python 优化并增强了 API;Spire.XLS for Python 支持删除 Excel 中的重复行;Spire.Presentation for Pytho 增强了 PPTX 到 PDF 的转换功能;Spire.PDF for Python 支持为数字签名添加时间戳;Spire.Barcode for Python 支持 Linux ARM 平台;Spire.OCR for Python 支持新平台并提升 OCR 识别准确性。此外,一些在转换、处理和保存 Word/Excel/PDF/PowerPoint 文件时出现的问题也已成功被修复。更多新功能及问题修复详情如下。
获取 Spire.Office for Python 10.12.0,请点击:
https://www.e-iceblue.cn/Downloads/Spire-Office-Python.html
Spire.Doc for Python
调整:
- 新增针对段落、表格、单元格、边框、样式等核心文档元素的精细化格式控制能力。
- 增强了 Chart 及其子对象的配置与操作能力。
- 增强了修订、内容控件及文档比较相关功能。
- 增强了辅助功能。
- 重构了列表系统。
- 为提升 API 的整体一致性,移除了部分冗余或设计不佳的属性和方法。例如,已废弃的导出方法 OfficeMath.SaveToImage 和 SaveImageToStream 已被删除。
| 类名 | 新功能 | 功能说明 |
|---|---|---|
| Paragraph | GetText | 获取段落的文本内容 |
| Table | SetBorders, ClearBorders |
设置表格边框样式;清除表格的所有边框格式 |
| CellFormat | ClearFormatting | 清除单元格的所有格式 |
| Borders | ClearFormatting, IsShadow |
清除边框格式设置;控制边框是否显示阴影效果 |
| RowFormat | ClearBackground, Height | 清除行背景色;设置行高 |
| StyleCollection | Add (重载) | 增加用于创建样式的重载方法 |
| PreferredWidth | FromPercent, FromPoints |
支持使用百分比或磅值定义宽度 |
| CharacterFormat | LocaleIdBi | 支持双向文本的区域设置 |
| Frame | IsFrame | 判断对象是否为 Frame |
| OfficeMath | ToLaTexMathCode, FromOMMLCode |
将公式对象转换为 LaTeX 数学代码;从 OMML 字符串创建公式对象 |
| 类名 | 新功能 | 功能说明 |
|---|---|---|
| Chart 及其子对象(包括 ChartAxis、ChartSeries、ChartDataLabelCollection、ChartLegend、ChartTitle 等) | 多个属性和方法 | 支持坐标轴配置、数据标签管理、图例/标题格式设置等 |
| 类名 | 新功能 | 功能说明 |
|---|---|---|
| CompareOptions | IgnoreTable, IgnoreHeadersAndFooters | 文档比较时忽略表格内容以及页眉/页脚 |
| DifferRevisions | MoveToRevisions, MoveFromRevisions | 获取“移入”和“移出”类型的修订内容 |
| StructureDocumentTag*(包括 Cell / Inline / Row) | RemoveSelfOnly | 仅删除内容控件本身,保留内部内容 |
| 类名 | 新功能 | 功能说明 |
|---|---|---|
| ToPdfParameterList | PdfImageCompression、DigitalSignatureInfo | 保存到PDF时配置图像压缩以及数字签名信息 |
| MarkdownExportOptions、ListReferences | MoveToRevisions, MoveFromRevisions | 支持 Markdown 导出选项及列表引用 |
| 类名 | 新功能 | 功能说明 |
|---|---|---|
| ListFormat | ApplyStyle, ApplyListRef | 支持直接应用列表引用及快速样式 |
| ListLevel | Equals, CreatePictureBullet, DeletePictureBullet, PictureBullet | 支持图片项目符号管理及列表级别比较 |
| ListStyle | ListRef, BaseStyle | 支持列表引用及基础样式配置 |
| Document | ListReferences | 获取文档中的列表引用集合 |
Spire.XLS for Python
新功能:
- 支持删除工作表中的重复行。
workbook = Workbook()
workbook.LoadFromFile(inputFile)
sheet = workbook.Worksheets[0]
sheet.RemoveDuplicates()
workbook.SaveToFile(outputFile, FileFormat.Version2013)
workbook.Dispose()
问题修复:
- 修复了调用 Range.Move() 后,公式错误的问题。
- 修复了 Excel 转 PDF,图表的标签丢失的问题。
- 修复了 Excel 转 PDF,效果不一致的问题。
- 修复了 SaveChartAsImage 图表转换不成功的问题。
- 修复了 Excel 转 PDF, 公式计算不正确的问题。
Spire.Presentation for Python
问题修复:
- 修复了转换 PPTX 到 PDF 时部分文本丢失的问题。
- 修复了转换 PPTX 到 PDF 时内容发生重叠的问题。
- 修复了转换 PPTX 到 PDF 时表格布局不正确的问题。
Spire.PDF for Python
新功能:
- 支持为数字签名添加时间戳。
- 支持转换PDF到Excel时配置文本布局选项。
- 支持转换PDF到Excel时配置行布局选项。
- 支持转换PDF到Excel配置表格布局选项。
- 支持配置OFD转换选项。
- 支持转换PDF到Markdown时配置忽略图片选项。
- 支持转换PDF到SVG时,配置SVG文件的宽度和高度。
doc = PdfDocument ()
doc. LoadFromFile (inputFile)
# Create a digital signature
signature = Security_PdfSignature (doc, doc.Pages.get_Item(0), inputFile_pfx,"08100601", "signature")
signature.SignDetailsFont = PdfFont(PdfFontFamily.Courier,8.0)
# Set the bounds of the signature box
signature.Bounds = RectangleF(PointF(90.0, 550.0), SizeF (180.0, 90.0))
# Configure signature appearance and details
signature.NameLabel = "Digitally signed by:Gary"
signature.LocationInfoLabel ="Location:"
signature.LocationInfo = "CN"
signature.ReasonLabel = "Reaseon:"
signature.Reason = "Ensure authenticity"
signature.ContactInfoLabel = "Contact Number:"
signature.ContactInfo = "028-81705109"
# Set document permissions
signature.DocumentPermissions = PdfCertificationFlags.ForbidChanges.value
# Set graphic mode for the signature
signature.GraphicsMode = Security_GraphicMode.SignImageAndSignDetail
# Set the signature image
signature.SignImageSource = PdfImage.FromFile(inputImage)
#When setting “none", the Image and Detail are distributed on both sides, when setting “Stretch", the image extends to the entire signatu
signature.SignImageLayout = SignImageLayout.none
url = "https://freetsa.org/tsr"
signature.ConfigureTimestamp(url)
signature.ConfigureHttpOCSP (None, None)
signature.Certificated = True
doc.SaveToFile(outputFile)
doc.Close()
pdf = PdfDocument()
pdf.LoadFromFile(inputFile)
textOption = XlsxTextLayoutOptions(True, False, False)
pdf.ConvertOptions.SetPdfToXlsxOptions(textOption)
pdf.SaveToFile(outputFile, FileFormat.XLSX)
pdf.Dispose()
pdf = PdfDocument()
pdf.LoadFromFile(inputFile)
lineOption = XlsxLineLayoutOptions(False,False,False,False)
pdf.ConvertOptions.SetPdfToXlsxOptions(lineOption)
pdf.SaveToFile(outputFile, FileFormat.XLSX)
pdf.Dispose()
# Load the PDF document from the specified input file path
pdf.LoadFromFile(inputFile)
# Set the XlsxSpecialTableLayoutOptions as the conversion options for PDF to XLSX conversion
options = XlsxSpecialTableLayoutOptions(False, False, False)
# Save the PDF document as an Excel file using the specified format and options
pdf.SaveToFile(outputFile, FileFormat.XLSX)
pdf = PdfDocument ()
pdf. LoadFromFile (inputFile)
ofdOptions = OfdOptions()
ofdOptions.UseTempFileStorage = True
pdf.ConvertOptions.SetPdfToOfdOptions(ofdOptions)
pdf.SaveToFile(outputFile,FileFormat.OFD)
# Create an instance of PdfToMarkdownConverter with the input PDF file
converter = PdfToMarkdownConverter(inputFile)
# Configure the converter to skip processing images in the PDF
converter.MarkdownOptions.IgnoreImage = True
# Convert the PDF content to Markdown format and save to the output file
converter.ConvertToMarkdown(outputFile)
converter = PdfToSvgConverter(inputFile)
converter.SvgOptions.ScaleX = 1.0
converter.SvgOptions.ScaleY = 1.0
converter.Convert(outputFile)
问题修复:
- 修复了转换PDF到PPTX,表格边框丢失的问题。
- 修复了设置PdfGird的单元格边框,程序抛异常的问题。
Spire.Barcode for Python
新功能:
- 升级 SkiaSharp 版本至 3.116.1。
- 新增支持 Linux ARM 平台。
Spire.OCR for Python
调整:
- 升级 SkiaSharp 至 3.116.1。
- 新增对 linux-arm 平台的支持。
- 调整 License 调用方式:改为使用 spire.ocr.LicenseProvider,不再使用 common 中的 license 对象。
优化:
- 增强了错误处理机制:当系统库 libdl.so 不可用时,扫描图片将给出明确的错误提示。(SPIREOCR-111)
- 增强了 OCR 识别能力:
1.支持识别旋转图片。
configureOptions.AutoRotate = True
2.支持按图像中文字的原始位置顺序输出识别结果。
visualText = VisualTextAligner(scanner.Text)
text = visualText.ToString()







