تحويل جدول Excel إلى نطاق من البيانات
Contents
[
Hide
]
تحويل جدول Excel إلى نطاق من البيانات
Aspose.Cells for Python via Java يوفر خيار تحويل جدول Excel إلى نطاق من البيانات. لهذا ، يوفر API امتدادListObject.convertToRange طريقة. يوضح مقتطف الشفرة التالي استخدامListObject.convertToRange لتحويل جدول Excel إلى نطاق من البيانات.
This file contains 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
source_directory = "Examples/SampleFiles/SourceDirectory/" | |
output_directory = "Examples/SampleFiles/OutputDirectory/" | |
workbook = Workbook(source_directory + "Book2.xlsx") | |
# Convert the first table/list object (from the first worksheet) to normal range | |
workbook.getWorksheets().get(0).getListObjects().get(0).convertToRange() | |
# Save the excel file. | |
workbook.save(output_directory + "ConvertTableToRange_out.xlsx") |
تحويل جدول Excel إلى نطاق مع خيارات
يمكنك توفير خيارات إضافية أثناء تحويل جدول إلى نطاق بامتدادTableToRangeOptions صف دراسي. يمكنك تمرير مثيل منTableToRangeOptionsفئة لListObject.convertToRange لتحديد خيارات إضافية. يوضح مقتطف الشفرة التالي استخدام ملفTableToRangeOptionsفئة لتعيين فهرس الصف الأخير من الجدول. سيتم الاحتفاظ بتنسيق الجدول حتى فهرس الصف المحدد وستتم إزالة باقي التنسيق.
This file contains 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
source_directory = "Examples/SampleFiles/SourceDirectory/" | |
output_directory = "Examples/SampleFiles/OutputDirectory/" | |
workbook = Workbook(source_directory + "Book2.xlsx") | |
# Convert the first table/list object (from the first worksheet) to normal range | |
tableToRangeOptions = TableToRangeOptions() | |
tableToRangeOptions.setLastRow(5) | |
# Convert the first table/list object (from the first worksheet) to normal range | |
workbook.getWorksheets().get(0).getListObjects().get(0).convertToRange(tableToRangeOptions) | |
# Save the excel file. | |
workbook.save(output_directory + "ConvertTableToRangeWithOptions_out.xlsx") |