Find Maximum Rows and Columns supported by XLS and XLSX formats

Possible Usage Scenarios

There are different number of rows and columns supported by Excel formats. For example, XLS supports 65536 rows and 256 columns while XLSX supports 1048576 rows and 16384 columns. If you want to know how many rows and columns are supported by given format, you can use WorkbookSettings.max_row and Workbook.settings.max_column properties.

Find Maximum Rows and Columns supported by XLS and XLSX formats

The following sample code creates workbook first in XLS and then in XLSX format. After creation, it prints the values of Workbook.settings.max_row and Workbook.settings.max_column properties. Please see the console output of the code given below for your reference.

Sample Code

from aspose.cells import FileFormatType, Workbook
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# Print message about XLS format.
print("Maximum Rows and Columns supported by XLS format.")
# Create workbook in XLS format.
wb = Workbook(FileFormatType.EXCEL_97_TO_2003)
# Print the maximum rows and columns supported by XLS format.
maxRows = wb.settings.max_row + 1
maxCols = wb.settings.max_column + 1
print("Maximum Rows: " + str(maxRows))
print("Maximum Columns: " + str(maxCols))
print()
# Print message about XLSX format.
print("Maximum Rows and Columns supported by XLSX format.")
# Create workbook in XLSX format.
wb = Workbook(FileFormatType.XLSX)
# Print the maximum rows and columns supported by XLSX format.
maxRows = wb.settings.max_row + 1
maxCols = wb.settings.max_column + 1
print("Maximum Rows: " + str(maxRows))
print("Maximum Columns: " + str(maxCols))

Console Output

Maximum Rows and Columns supported by XLS format.

Maximum Rows: 65536

Maximum Columns: 256

Maximum Rows and Columns supported by XLSX format.

Maximum Rows: 1048576

Maximum Columns: 16384