الحصول على أقصى مجال في ورقة العمل

كيفية الحصول على أقصى نطاق

في Aspose.Cells for Python via .NET ، إذا تم تهيئة الكائنات row و column ، سيتم عد هذه الصفوف والأعمدة للمنطقة القصوى ، حتى إذا كانت هناك بيانات في الصفوف أو الأعمدة الفارغة.

from aspose.cells import Workbook
workbook = Workbook("Book1.xlsx")
# Get all the worksheets in the book.
worksheets = workbook.worksheets
sheet = worksheets[0]
# Gets the max data range.
maxRow = sheet.cells.max_row
maxColumn = sheet.cells.max_column
# The range is A1:B3.
range = sheet.cells.create_range(0, 0, maxRow + 1, maxColumn + 1)
sheet.cells.get("A10").put_value(None)
maxRow = sheet.cells.max_row
maxColumn = sheet.cells.max_column
# The range is udpated to A1:B10.
range = sheet.cells.create_range(0, 0, maxRow + 1, maxColumn + 1)

كيفية الحصول على أقصى نطاق البيانات

في معظم الحالات ، نحتاج إلى الحصول على جميع المجالات التي تحتوي على جميع البيانات ، حتى لو كانت الخلايا الفارغة خارج المجال مهيأة. وسيتم تجاهل الإعدادات المتعلقة بالأشكال والجداول والجداول المدورة.

from aspose.cells import Workbook
# Instantiate a new Workbook.
workbook = Workbook("Book1.xlsx")
# Get all the worksheets in the book.
worksheets = workbook.worksheets
sheet = worksheets[0]
# Gets the max data range.
maxRow = sheet.cells.max_data_row
maxColumn = sheet.cells.max_data_column
# The range is A1:B3.
range = sheet.cells.create_range(0, 0, maxRow + 1, maxColumn + 1)
sheet.cells.get("A10").put_value(None)
maxRow = sheet.cells.max_data_row
maxColumn = sheet.cells.max_data_column
# The range is still A1:B3.
range = sheet.cells.create_range(0, 0, maxRow + 1, maxColumn + 1)

كيفية الحصول على أقصى نطاق العرض

عند تصدير جميع البيانات من ورقة العمل إلى HTML ، PDF ، أو الصور ، نحتاج إلى الحصول على منطقة تحتوي على جميع الكائنات المرئية ، بما في ذلك البيانات والأنماط والرسومات والجداول والجداول المدورة. الشفرات التالية تظهر كيفية عرض المجال الأقصى إلى HTML:

from aspose.cells import CellArea, HtmlSaveOptions, Workbook
# Instantiate a new Workbook.
workbook = Workbook("Book1.xlsx")
# Get all the worksheets in the book.
worksheets = workbook.worksheets
# Gets the max display range.
range = worksheets[0].cells.max_display_range
# Save the range to html
saveOptions = HtmlSaveOptions()
saveOptions.export_active_worksheet_only = True
saveOptions.export_area = CellArea.create_cell_area(range.first_row, range.first_column, range.first_row + range.row_count - 1, range.first_column + range.column_count - 1)
# Save the range.
workbook.save("html.html", saveOptions)

هنا ملف اكسل المصدر.