查找XLS和XLSX格式支持的最大行数和列数,使用C++
Contents
[
Hide
]
可能的使用场景
不同的Excel格式支持不同的行和列。例如,XLS支持65536行和256列,而XLSX支持1048576行和16384列。若想知道某一格式支持多少行列,可使用 GetMaxRow() 和 GetMaxColumn() 属性。
查找XLS和XLSX格式支持的最大行数和列数
以下示例代码先创建XLS格式的工作簿,再创建XLSX格式的工作簿,之后输出 GetMaxRow() 和 GetMaxColumn() 属性的值。请参考以下控制台输出。
示例代码
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// Print message about XLS format.
std::cout << "Maximum Rows and Columns supported by XLS format." << std::endl;
// Create workbook in XLS format.
Workbook wb(FileFormatType::Excel97To2003);
// Print the maximum rows and columns supported by XLS format.
int maxRows = wb.GetSettings().GetMaxRow() + 1;
int maxCols = wb.GetSettings().GetMaxColumn() + 1;
std::cout << "Maximum Rows: " << maxRows << std::endl;
std::cout << "Maximum Columns: " << maxCols << std::endl;
std::cout << std::endl;
// Print message about XLSX format.
std::cout << "Maximum Rows and Columns supported by XLSX format." << std::endl;
// Create workbook in XLSX format.
wb = Workbook(FileFormatType::Xlsx);
// Print the maximum rows and columns supported by XLSX format.
maxRows = wb.GetSettings().GetMaxRow() + 1;
maxCols = wb.GetSettings().GetMaxColumn() + 1;
std::cout << "Maximum Rows: " << maxRows << std::endl;
std::cout << "Maximum Columns: " << maxCols << std::endl;
Aspose::Cells::Cleanup();
return 0;
}
控制台输出
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