查找通过Node.js的XLS和XLSX格式支持的最大行数和列数
Contents
[
Hide
]
可能的使用场景
不同的Excel格式支持不同的行和列。例如,XLS支持65536行和256列,而XLSX支持1048576行和16384列。若想知道某一格式支持多少行列,可使用 WorkbookSettings.getMaxRow() 和 WorkbookSettings.getMaxColumn() 属性。
查找XLS和XLSX格式支持的最大行数和列数
以下示例代码先创建XLS格式的工作簿,再创建XLSX格式的工作簿,之后输出 WorkbookSettings.getMaxRow() 和 WorkbookSettings.getMaxColumn() 属性的值。请参考以下控制台输出。
示例代码
const AsposeCells = require("aspose.cells.node");
const path = require("path");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "sample.xlsx");
// Print message about XLS format.
console.log("Maximum Rows and Columns supported by XLS format.");
// Create workbook in XLS format.
let wb = new AsposeCells.Workbook(AsposeCells.FileFormatType.Excel97To2003);
// Print the maximum rows and columns supported by XLS format.
let maxRows = wb.getSettings().getMaxRow() + 1;
let maxCols = wb.getSettings().getMaxColumn() + 1;
console.log("Maximum Rows: " + maxRows);
console.log("Maximum Columns: " + maxCols);
console.log();
// Print message about XLSX format.
console.log("Maximum Rows and Columns supported by XLSX format.");
// Create workbook in XLSX format.
wb = new AsposeCells.Workbook(AsposeCells.FileFormatType.Xlsx);
// Print the maximum rows and columns supported by XLSX format.
maxRows = wb.getSettings().getMaxRow() + 1;
maxCols = wb.getSettings().getMaxColumn() + 1;
console.log("Maximum Rows: " + maxRows);
console.log("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