BasicExcel根本没有SetStringHandling这个函数
时间: 2024-03-03 14:50:13 浏览: 93
非常抱歉,关于 BasicExcel 库的 `SetStringHandling()` 函数,我理解有误。实际上,BasicExcel 库没有提供这个函数。如果你想按照字符串格式读取单元格内容,可以使用以下方法:
```c++
#include "BasicExcel.hpp"
#include <iostream>
int main()
{
BasicExcel e;
e.Load("example.xls");
BasicExcelWorksheet* sheet = e.GetWorksheet(0);
for (int row = 0; row < sheet->GetTotalRows(); ++row)
{
for (int col = 0; col < sheet->GetTotalCols(); ++col)
{
BasicExcelCell* cell = sheet->Cell(row, col);
if (cell->Type() == BasicExcelCell::STRING)
{
std::cout << cell->GetString() << "\t";
}
else
{
std::cout << cell->Value() << "\t";
}
}
std::cout << std::endl;
}
return 0;
}
```
在这个示例中,我们遍历表格中的所有单元格,并通过 `cell->Type()` 函数来判断单元格的类型。如果单元格的类型是字符串,就使用 `cell->GetString()` 函数获取字符串类型的单元格内容。否则,我们使用 `cell->Value()` 函数获取单元格内容的数值类型。
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![application/x-zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)