تصدير نطاق منطقة الطباعة إلى HTML
Contents
[
Hide
]
سيناريوهات الاستخدام المحتملة
هذا هو سيناريو شائع حيث نحتاج إلى تصدير فقط منطقة الطباعة أي نطاق الخلايا المحددة بدلاً من الورقة بأكملها إلى HTML. هذه الميزة متاحة بالفعل لعرض PDF، ومع ذلك، يمكنك الآن القيام بهذه المهمة أيضًا لتنسيق HTML. قم أولاً بتعيين منطقة الطباعة في كائن إعداد الصفحة الخاص بورقة العمل. بعد ذلك، استخدم الرمز HtmlSaveOptions.export_print_area_only لتصدير النطاق المحدد فقط.
كود عينة
يقوم الكود العيني التالي بتحميل دفتر عمل ثم يصدر منطقة الطباعة إلى HTML. يمكن تنزيل ملف العينة لاختبار هذه الميزة من الرابط التالي:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from aspose.cells import HtmlSaveOptions, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Load the Excel file. | |
wb = Workbook(sourceDir + "sampleInlineCharts.xlsx") | |
# Access the sheet | |
ws = wb.worksheets[0] | |
# Set the print area. | |
ws.page_setup.print_area = "D2:M20" | |
# Initialize HtmlSaveOptions | |
options = HtmlSaveOptions() | |
# Set flag to export print area only | |
options.export_print_area_only = True | |
# Save to HTML format | |
wb.save(outputDir + "outputInlineCharts.html", options) |