查找XLS和XLSX格式支持的最大行数和列数
Contents
[
Hide
]
可能的使用场景
Excel格式支持不同数量的行和列。例如,XLS支持65536行和256列,而XLSX支持1048576行和16384列。如果要知道给定格式支持多少行和列,可以使用Workbook.Settings.MaxRow和Workbook.Settings.MaxColumn属性。
查找XLS和XLSX格式支持的最大行数和列数
以下示例代码首先创建XLS和XLSX格式的工作簿。创建后,打印Workbook.Settings.MaxRow和Workbook.Settings.MaxColumn属性的值。 请参考下面给出的代码的控制台输出。
示例代码
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
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// Print message about XLS format. | |
System.out.println("Maximum Rows and Columns supported by XLS format."); | |
// Create workbook in XLS format. | |
Workbook wb = new Workbook(FileFormatType.EXCEL_97_TO_2003); | |
// Print the maximum rows and columns supported by XLS format. | |
int maxRows = wb.getSettings().getMaxRow() + 1; | |
int maxCols = wb.getSettings().getMaxColumn() + 1; | |
System.out.println("Maximum Rows: " + maxRows); | |
System.out.println("Maximum Columns: " + maxCols); | |
System.out.println(); | |
// Print message about XLSX format. | |
System.out.println("Maximum Rows and Columns supported by XLSX format."); | |
// Create workbook in XLSX format. | |
wb = new Workbook(FileFormatType.XLSX); | |
// Print the maximum rows and columns supported by XLSX format. | |
maxRows = wb.getSettings().getMaxRow() + 1; | |
maxCols = wb.getSettings().getMaxColumn() + 1; | |
System.out.println("Maximum Rows: " + maxRows); | |
System.out.println("Maximum Columns: " + maxCols); |
控制台输出
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