เรามีความยินดีที่จะประกาศการปล่อย GroupDocs.Assembly for Python v26.11 ซึ่งพร้อมให้ใช้งานตั้งแต่ พฤศจิกายน 2026. การปล่อยนี้มอบการปรับปรุงการสนับสนุนแพลตฟอร์มอย่างสำคัญ—รวมถึง wheel แรกสำหรับ Linux และ macOS—พร้อมกับการสนับสนุนแหล่งข้อมูล Python แบบเนทีฟ, การจัดการข้อผิดพลาดที่ดีขึ้น, และการอัปเกรด dependencies. นอกจากนี้ยังแนะนำฟีเจอร์ใหม่หลายอย่างและการเปลี่ยนแปลงที่ทำให้แตกต่างเพื่อให้สอดคล้องกับแนวปฏิบัติ Python สมัยใหม่และ .NET 10.
สิ่งใหม่ในรุ่นนี้
- [Feature] เพิ่ม wheel สำหรับ Linux x64 และ macOS (Intel และ Apple Silicon) (ASSEMBLYPYTHON-26)
- [Feature] เพิ่มการสนับสนุน Python dict หรือ list เป็นแหล่งข้อมูล (ASSEMBLYPYTHON-27)
- [Feature] เพิ่มการสนับสนุนตัวจัดการ Python สำหรับการโหลดตารางเอกสาร (
IDocumentTableLoadHandler) (ASSEMBLYPYTHON-28) - [Feature] เพิ่มการสนับสนุนประเภท Python เมื่อ API ต้องการ .NET
Type(DocumentTableColumn.type,known_types) (ASSEMBLYPYTHON-29) - [Feature] เพิ่มการสนับสนุนการใช้ใบอนุญาตจากตัวแปรสภาพแวดล้อม
GROUPDOCS_LIC_PATH(ASSEMBLYPYTHON-30) - [Enhancement] อัปเดต GroupDocs.Assembly เป็นเวอร์ชัน 26.7 และ runtime ที่ฝังมาเป็น .NET 10.0.14 (ASSEMBLYPYTHON-31)
- [Enhancement] จัดจำหน่ายแพคเกจ pure-Python สำหรับ Python 3.5 – 3.14 แทนส่วนขยายที่คอมไพล์ (ASSEMBLYPYTHON-32)
- [Enhancement] ยอมรับ
DataSourceInfoหนึ่งรายการในassemble_document()รวมถึงรายการ (ASSEMBLYPYTHON-33) - [Enhancement] โยน
FileNotFoundErrorเมื่อไฟล์หาย,LicenseErrorสำหรับใบอนุญาตที่ไม่สามารถใช้ได้, และGroupDocsAssemblyExceptionสำหรับข้อผิดพลาดของเอนจินอื่น ๆ (ASSEMBLYPYTHON-34) - [Enhancement] เปลี่ยนชื่อ
BarcodeSettings.x_resolution/y_resolutionเป็นxresolution/yresolutionและทำให้use_reflection_optimizationเป็นแอตทริบิวต์ของคลาส (ASSEMBLYPYTHON-35) - [Enhancement] ลบ wheel Windows 32-bit (ASSEMBLYPYTHON-36)
- [Fix] แก้ไขปัญหา CVE ในเวอร์ชัน 25.5.1: zlib 1.2.11 → 1.2.12 (+4 รายการเพิ่มเติม) (ASSEMBLYPYTHON-11)
การเปลี่ยนแปลง Public API
ผู้อัปเกรดต้องเปลี่ยนชื่อ x_resolution/y_resolution และ set_use_reflection_optimization() และจับ GroupDocsAssemblyException และ LicenseError แทนที่เคยจับ RuntimeError. ส่วนอื่น ๆ จะเป็นการเพิ่มเท่านั้น.
คลาสและสมาชิกใหม่
groupdocs.assembly:FontSettings,FolderFontSource,IFontSource,SearchOption,OoxmlCompliance,GroupDocsAssemblyException,LicenseError,LicenseWarning.LoadSaveOptions:ooxml_compliance.KnownTypeSet:append().DocumentTableCollection,DocumentTableColumnCollection:get().DocumentTableRelationCollection:append(),get().
เปลี่ยนชื่อ
BarcodeSettings.x_resolution→BarcodeSettings.xresolutionBarcodeSettings.y_resolution→BarcodeSettings.yresolution
ชื่อเก่าจะโยน AttributeError พร้อมข้อความแนะนำ “Did you mean” ทั้งเมื่ออ่านและเมื่อกำหนดค่า.
ถูกลบออก
DocumentAssembler.set_use_reflection_optimization(): กำหนดค่าแอตทริบิวต์ของคลาสแทน,DocumentAssembler.use_reflection_optimization = False.
มีการเปลี่ยนแปลง
DataSourceInfoรับ dict หรือ list.assemble_document()รับDataSourceInfoหนึ่งรายการรวมถึงรายการ.DocumentTableSet(path, load_handler)รับฟังก์ชัน Python หรืออ็อบเจ็กต์ที่มีhandle(args).DocumentTableColumn.typeและKnownTypeSet.add()รับประเภท Python.- ข้อผิดพลาดของเอนจินจะโยน
FileNotFoundError,RuntimeError,LicenseErrorหรือGroupDocsAssemblyException.except Exceptionจะจับข้อผิดพลาดของทั้งสองรุ่น.
ฟีเจอร์ใหม่
Linux และ macOS
26.11 มี wheel สำหรับ Linux x64 (manylinux_2_27_x86_64, glibc 2.27 หรือใหม่กว่า) และสำหรับ macOS 12 หรือใหม่กว่า บน Intel (macosx_12_0_x86_64) และ Apple Silicon (macosx_12_0_arm64), นอกจากนี้ยังมี Windows x64. เวอร์ชัน 25.5 มีเฉพาะ wheel สำหรับ Windows เท่านั้น. pip 20.3 หรือใหม่กว่า จะเลือก wheel ที่ตรงกับแพลตฟอร์ม. บน Linux runtime ของ .NET ต้องการ ICU, และเทมเพลตการนำเสนอจำเป็นต้องใช้ libgdiplus (ดู Requirements).
pip install groupdocs-assembly-net==26.11.0
ข้อมูล Python เป็นแหล่งข้อมูล
DataSourceInfo รับ dict, รายการของ dict หรือรายการของค่าแบบตรง; เวอร์ชัน 25.5 โยน TypeError สำหรับ dict. ตัวห่อแปลงข้อมูลเป็นอ็อบเจ็กต์ .NET ที่มีประเภทตามโครงสร้าง, ดังนั้นตัวเลข, สตริง, bool, datetime, date และค่า Decimal จะเข้าถึงเทมเพลตตามประเภท: <<[o.OrderDate.Month]>> และ <<if [c.Vip]>> ทำงานเช่นเดียวกับบนอ็อบเจ็กต์ .NET. Dicts ในรายการเดียวกันจะใช้ประเภทเดียวกันที่เป็นการรวมของคีย์ทั้งหมด.
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: a table whose row <<foreach [o in orders]>><<[o.Number]>> ... <</foreach>> repeats per order
DocumentAssembler().assemble_document("order-table.docx", "order-table-report.docx", [
DataSourceInfo("Quayside Bistro", "customer"),
DataSourceInfo(orders, "orders"),
])
แหล่งข้อมูลเดียวโดยไม่มีรายการ
assemble_document() รับ DataSourceInfo หนึ่งรายการหรือรายการของมัน, เช่นเดียวกับ params DataSourceInfo[] ของ .NET. เวอร์ชัน 25.5 ต้องการรายการและโยน TypeError: can't build Array value from 'groupdocs.assembly.DataSourceInfo' เมื่อใช้เพียงหนึ่ง.
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"))
ตัวจัดการการโหลดตาราง
DocumentTableSet(path, load_handler) รับฟังก์ชัน Python (args), หรืออ็อบเจ็กต์ที่มีเมธอด handle(args), และเรียกมันสำหรับแต่ละตารางของเอกสารก่อนที่จะโหลด. ตัวจัดการจะตั้งค่า args.options ของตารางนั้น, หรือข้ามตารางด้วย args.is_loaded = False; args.table_index บอกว่าตารางใด. เวอร์ชัน 25.5 โยน TypeError สำหรับฟังก์ชัน 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])
ประเภท Python เมื่อ API ต้องการประเภท .NET
ประเภท Python แทนประเภท .NET ที่สมาชิกรับ: float สำหรับ System.Double, int, str, bool, datetime. คอลัมน์ของตารางเอกสารสามารถกำหนดให้เป็นตัวเลขเพื่อให้แผนภูมิเบิกผลรวมได้, และ known_types ทำให้เทมเพลตสามารถเรียกสมาชิกแบบ static ของประเภทนั้น; มันยังรับชื่อประเภท .NET ด้วย. เวอร์ชัน 25.5 โยน 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") # templates can call <<[Math.Round(x, 1)]>>
assembler.assemble_document("table-row.docx", "table-row-report.docx", DataSourceInfo(contracts, "contracts"))
ใบอนุญาตจากสภาพแวดล้อม
ตั้งค่า GROUPDOCS_LIC_PATH ให้เป็นเส้นทางของไฟล์ใบอนุญาต, หรือเป็น URL ที่ให้ไฟล์นั้น, และใบอนุญาตจะถูกนำไปใช้ในการเรียกเอนจินครั้งแรก, โดยไม่ต้องระบุโค้ดใบอนุญาต; เวอร์ชัน 25.5 ไม่ได้อ่านตัวแปรนี้. หากใบอนุญาตนั้นไม่สามารถใช้ได้ (ไฟล์หาย, การสมัครสมาชิกหมดอายุ, ใบอนุญาตสำหรับผลิตภัณฑ์อื่น), การเรียกเอนจินทุกครั้งจะโยน LicenseError, ระบุชื่อตัวแปรและเหตุผลของเอนจิน, จนกว่า License().set_license() จะนำใบอนุญาตมาใช้. ตั้งค่า GROUPDOCS_LIC_STRICT=0 เพื่อรับ LicenseWarning หนึ่งรายการและโหมดประเมินผลแทน.
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>
ข้อผิดพลาดตามประเภท
เวอร์ชัน 25.5 โยน RuntimeError("Proxy error(<.NET exception>): ...") สำหรับทุกข้อผิดพลาดของเอนจิน. เวอร์ชัน 26.11 จะโยน FileNotFoundError เมื่อเทมเพลตหรือไฟล์ข้อมูลหาย, ซึ่งยังสืบทอดจาก RuntimeError; RuntimeError พร้อมข้อความของเอนจินเท่านั้นสำหรับข้อผิดพลาดของเทมเพลตหรือสมาชิกที่ข้อมูลไม่มี; LicenseError สำหรับใบอนุญาตที่ไม่สามารถใช้ได้; และ GroupDocsAssemblyException สำหรับข้อผิดพลาดเอนจินอื่น ๆ. LicenseError และ GroupDocsAssemblyException สามารถนำเข้าได้จาก groupdocs.assembly และไม่ได้สืบทอดจาก 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)
ตัวอย่างโค้ด
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"))
วิธีรับการอัปเดต
PyPI
อัปเกรดเป็นแพคเกจล่าสุดผ่าน PyPI:
groupdocs-assembly-net 26.11.0
pip install groupdocs-assembly-net==26.11.0
ดาวน์โหลดโดยตรง
ดาวน์โหลด wheel สำหรับแพลตฟอร์มของคุณจากหน้า GroupDocs.Assembly for Python v26.11 .