Chúng tôi rất vui mừng thông báo việc phát hành GroupDocs.Assembly for Python v26.11, có sẵn từ tháng 11 năm 2026. Bản phát hành này mang lại các cải tiến quan trọng về hỗ trợ nền tảng — bao gồm các bánh xe (wheel) đầu tiên cho Linux và macOS — cùng với hỗ trợ nguồn dữ liệu Python gốc, xử lý lỗi được cải thiện và các phụ thuộc được nâng cấp. Nó cũng giới thiệu một số tính năng mới và các thay đổi gây phá vỡ để phù hợp với các thực tiễn Python hiện đại và .NET 10.
Những gì mới trong bản phát hành này
- [Feature] Thêm bánh xe cho Linux x64 và macOS (Intel và Apple Silicon) (ASSEMBLYPYTHON-26)
- [Feature] Thêm hỗ trợ cho một dict hoặc list của Python làm nguồn dữ liệu (ASSEMBLYPYTHON-27)
- [Feature] Thêm hỗ trợ cho trình xử lý tải bảng tài liệu Python (
IDocumentTableLoadHandler) (ASSEMBLYPYTHON-28) - [Feature] Thêm hỗ trợ cho các kiểu Python khi API nhận một .NET
Type(DocumentTableColumn.type,known_types) (ASSEMBLYPYTHON-29) - [Feature] Thêm hỗ trợ áp dụng giấy phép từ biến môi trường
GROUPDOCS_LIC_PATH(ASSEMBLYPYTHON-30) - [Enhancement] Cập nhật GroupDocs.Assembly lên 26.7 và runtime nhúng lên .NET 10.0.14 (ASSEMBLYPYTHON-31)
- [Enhancement] Phát hành gói pure-Python cho Python 3.5 – 3.14 thay cho phần mở rộng đã biên dịch (ASSEMBLYPYTHON-32)
- [Enhancement] Cho phép truyền một
DataSourceInfotrongassemble_document()cũng như một danh sách (ASSEMBLYPYTHON-33) - [Enhancement] Ném
FileNotFoundErrorkhi thiếu tệp,LicenseErrorkhi giấy phép không thể áp dụng, vàGroupDocsAssemblyExceptioncho các lỗi engine khác (ASSEMBLYPYTHON-34) - [Enhancement] Đổi tên
BarcodeSettings.x_resolution/y_resolutionthànhxresolution/yresolution, và biếnuse_reflection_optimizationthành thuộc tính lớp (ASSEMBLYPYTHON-35) - [Enhancement] Loại bỏ bánh xe Windows 32-bit (ASSEMBLYPYTHON-36)
- [Fix] Sửa các lỗ hổng CVE trong 25.5.1: zlib 1.2.11 → 1.2.12 (+4 nữa) (ASSEMBLYPYTHON-11)
Thay đổi API công cộng
Người nâng cấp cần đổi tên x_resolution/y_resolution và set_use_reflection_optimization(), đồng thời bắt GroupDocsAssemblyException và LicenseError thay vì RuntimeError. Các phần còn lại là bổ sung.
Các lớp và thành viên mới
groupdocs.assembly:FontSettings,FolderFontSource,IFontSource,SearchOption,OoxmlCompliance,GroupDocsAssemblyException,LicenseError,LicenseWarning.LoadSaveOptions:ooxml_compliance.KnownTypeSet:append().DocumentTableCollection,DocumentTableColumnCollection:get().DocumentTableRelationCollection:append(),get().
Được đổi tên
BarcodeSettings.x_resolution→BarcodeSettings.xresolutionBarcodeSettings.y_resolution→BarcodeSettings.yresolution
Các tên cũ sẽ ném AttributeError với gợi ý “Did you mean”, cả khi đọc và khi gán.
Được loại bỏ
DocumentAssembler.set_use_reflection_optimization(): thay vào đó gán trực tiếp thuộc tính lớp,DocumentAssembler.use_reflection_optimization = False.
Thay đổi
DataSourceInfonhận một dict hoặc một list.assemble_document()nhận mộtDataSourceInfohoặc một danh sách.DocumentTableSet(path, load_handler)nhận một hàm Python hoặc một đối tượng có phương thứchandle(args).DocumentTableColumn.typevàKnownTypeSet.add()nhận một kiểu Python.- Các lỗi engine ném
FileNotFoundError,RuntimeError,LicenseErrorhoặcGroupDocsAssemblyException.except Exceptionsẽ bắt các lỗi của cả hai phiên bản.
Các tính năng mới
Linux và macOS
26.11 có bánh xe cho Linux x64 (manylinux_2_27_x86_64, glibc 2.27 trở lên) và cho macOS 12 trở lên trên Intel (macosx_12_0_x86_64) và Apple Silicon (macosx_12_0_arm64), bên cạnh Windows x64. Phiên bản 25.5 chỉ có bánh xe Windows. pip 20.3 trở lên sẽ tự động chọn bánh xe phù hợp với nền tảng. Trên Linux runtime .NET cần ICU, và các mẫu trình bày cần libgdiplus (xem Requirements).
pip install groupdocs-assembly-net==26.11.0
Dữ liệu Python làm nguồn dữ liệu
DataSourceInfo nhận một dict, một list các dict hoặc một list các giá trị; phiên bản 25.5 ném TypeError khi truyền dict. Bộ bao bọc chuyển dữ liệu thành các đối tượng .NET được gán kiểu dựa trên cấu trúc, vì vậy các số, chuỗi, bool, datetime, date và giá trị Decimal sẽ tới mẫu với kiểu đã xác định: <<[o.OrderDate.Month]>> và <<if [c.Vip]>> hoạt động như trên các đối tượng .NET. Các dict trong một list sẽ chia sẻ một kiểu chung với hợp của các khóa.
from groupdocs.assembly import DataSourceInfo, DocumentAssembler
orders = [
{"Number": 10001, "Product": "Harbor Blend whole bean coffee", "Quantity": 30, "Price": 552.0},
{"Number": 10004, "Product": "Aged harbour cheddar", "Quantity": 8, "Price": 132.0},
]
# order-table.docx: một bảng mà hàng <<foreach [o in orders]>><<[o.Number]>> ... <</foreach>> lặp lại cho mỗi đơn hàng
DocumentAssembler().assemble_document("order-table.docx", "order-table-report.docx", [
DataSourceInfo("Quayside Bistro", "customer"),
DataSourceInfo(orders, "orders"),
])
Một nguồn dữ liệu mà không cần danh sách
assemble_document() nhận một DataSourceInfo hoặc một danh sách các DataSourceInfo, tương tự như params DataSourceInfo[] của .NET. Phiên bản 25.5 yêu cầu danh sách và ném TypeError: can't build Array value from 'groupdocs.assembly.DataSourceInfo' khi chỉ truyền một.
from groupdocs.assembly import DataSourceInfo, DocumentAssembler
customer = {"Name": "Quayside Bistro", "Product": "Harbor Blend whole bean coffee"}
DocumentAssembler().assemble_document("hello-world.docx", "hello-world-report.docx", DataSourceInfo(customer, "customer"))
Trình xử lý tải bảng
DocumentTableSet(path, load_handler) nhận một hàm Python (args), hoặc một đối tượng có phương thức handle(args), và gọi nó cho mỗi bảng của tài liệu trước khi tải. Trình xử lý sẽ đặt args.options cho bảng đó, hoặc bỏ qua bảng bằng cách đặt args.is_loaded = False; args.table_index cho biết bảng hiện tại là bảng số bao nhiêu. Phiên bản 25.5 ném TypeError khi truyền hàm Python.
from groupdocs.assembly.data import DocumentTableOptions, DocumentTableSet
def on_table(args):
options = DocumentTableOptions()
options.first_row_contains_column_names = True
args.options = options
tables = DocumentTableSet("contracts.xlsx", on_table)
for table in tables.tables:
print(table.name, [column.name for column in table.columns])
Kiểu Python khi API yêu cầu kiểu .NET
Một kiểu Python đại diện cho kiểu .NET mà thành viên nhận: float cho System.Double, int, str, bool, datetime. Một cột của bảng tài liệu có thể được đặt thành số để biểu đồ có thể tổng hợp, và known_types cho phép mẫu gọi các thành viên tĩnh của một kiểu; nó cũng chấp nhận tên kiểu .NET. Phiên bản 25.5 ném TypeError: can't build Type value from 'type'.
from groupdocs.assembly import DataSourceInfo, DocumentAssembler
from groupdocs.assembly.data import DocumentTable, DocumentTableOptions
options = DocumentTableOptions()
options.first_row_contains_column_names = True
contracts = DocumentTable("contracts.xlsx", 0, options)
contracts.columns["Price"].type = float
assembler = DocumentAssembler()
assembler.known_types.add("System.Math") # các mẫu có thể gọi <<[Math.Round(x, 1)]>>
assembler.assemble_document("table-row.docx", "table-row-report.docx", DataSourceInfo(contracts, "contracts"))
Giấy phép từ môi trường
Đặt GROUPDOCS_LIC_PATH thành đường dẫn tới tệp giấy phép, hoặc tới URL cung cấp tệp, và giấy phép sẽ được áp dụng ở lần gọi engine đầu tiên, không cần mã giấy phép; phiên bản 25.5 không đọc biến này. Nếu giấy phép không thể áp dụng (thiếu tệp, thuê bao hết hạn, giấy phép cho sản phẩm khác), mọi lần gọi engine sẽ ném LicenseError, chỉ ra biến và lý do của engine, cho đến khi License().set_license() áp dụng giấy phép. Đặt GROUPDOCS_LIC_STRICT=0 để nhận một LicenseWarning và chế độ đánh giá thay vì lỗi.
from groupdocs.assembly import DataSourceInfo, DocumentAssembler, LicenseError
customer = {"Name": "Quayside Bistro", "Product": "Harbor Blend whole bean coffee"}
try:
DocumentAssembler().assemble_document("hello-world.docx", "hello-world-report.docx", DataSourceInfo(customer, "customer"))
except LicenseError as e:
print(e) # GROUPDOCS_LIC_PATH=... could not be applied: <reason>
Lỗi theo loại
Phiên bản 25.5 ném RuntimeError("Proxy error(<.NET exception>): ...") cho mọi lỗi engine. Phiên bản 26.11 ném FileNotFoundError khi thiếu mẫu hoặc tệp dữ liệu (vẫn kế thừa từ RuntimeError); RuntimeError chỉ chứa thông điệp của engine cho lỗi mẫu hoặc thành viên dữ liệu thiếu; LicenseError cho giấy phép không thể áp dụng; và GroupDocsAssemblyException cho các lỗi engine khác. LicenseError và GroupDocsAssemblyException có thể import từ groupdocs.assembly và không kế thừa từ RuntimeError.
from groupdocs.assembly import DataSourceInfo, DocumentAssembler, GroupDocsAssemblyException
try:
DocumentAssembler().assemble_document("no-such-template.docx", "report.docx", DataSourceInfo({"Name": "A"}, "customer"))
except FileNotFoundError as e:
print("missing:", e)
except (RuntimeError, GroupDocsAssemblyException) as e:
print("engine:", e)
Ví dụ mã
from groupdocs.assembly import DataSourceInfo, DocumentAssembler, FileFormat, LoadSaveOptions, OoxmlCompliance
options = LoadSaveOptions(FileFormat.DOCX)
options.ooxml_compliance = OoxmlCompliance.STRICT
customer = {"Name": "Quayside Bistro", "Product": "Harbor Blend whole bean coffee"}
DocumentAssembler().assemble_document("hello-world.docx", "hello-world-strict.docx", options, DataSourceInfo(customer, "customer"))
Cách nhận bản cập nhật
PyPI
Nâng cấp lên gói mới nhất qua PyPI:
groupdocs-assembly-net 26.11.0
pip install groupdocs-assembly-net==26.11.0
Tải trực tiếp
Tải bánh xe cho nền tảng của bạn từ trang GroupDocs.Assembly for Python v26.11.