OpenXLSX icon indicating copy to clipboard operation
OpenXLSX copied to clipboard

The number in cell is formatted as text but need as float

Open Vernadskii opened this issue 2 years ago • 0 comments

Hello! I am a user of this library, thanks for it.
Unfortunately, I didn't find the same issue or example in the repo.

I faced a problem when I write floats numbers (as a std::string) in excel and get cells as a text data screenshot

code snippet how I get it:

const float board_value = 3.3188;
std::ostringstream streamObj;
streamObj << std::fixed;
streamObj << std::setprecision(2);
streamObj << board_value;
auto result = streamObj.str();
std::replace(this->result .begin(), this->result .end(), '.', ',');

wks.cell(2, 2).value() = result;

If I'll not use replacing excel formatting will be okay with formatting. But I should use ',' instead of '.' for float numbers in excel. Is it possible to affect excel formatting inside API? It would be very useful. Thank you!

Vernadskii avatar Sep 05 '22 11:09 Vernadskii