skrat
skrat

Reputation: 748

How to read floats from XLSX file with OpenXLSX

I'm trying to read a set of data from my Excel file. enter image description here

I am able to read the integers from the first column:

const auto sdf = sheet.cell(fmt::format("A{}", rowIndex)).value().get<int>();

I am also able to read the strings from the second column:

const auto sdf = sheet.cell(fmt::format("B{}", rowIndex)).value().get<std::string>();

but I can't figure out how to read the values in column C into doubles.

I tried:

const auto sdf = sheet.cell(fmt::format("C{}", rowIndex)).value().get<double>();

but that results in termination:

terminate called after throwing an instance of 'OpenXLSX::XLValueTypeError'
  what():  XLCellValue object does not contain the requested type.

Would anybody know what to do? How do I read a float from my file?

Edit

I also check some tests from the OpenXLSX repo. I don't find any differences.

Upvotes: 2

Views: 167

Answers (1)

Sergio
Sergio

Reputation: 931

Ther's an open issue on GitHub (OpenXLSX repository) with a proposal fix (https://github.com/troldal/OpenXLSX/issues/196).

Upvotes: 0

Related Questions