Код: Выделить всё
xlnt::workbook wb;
wb.load(WBurl);
auto ws = wb.active_sheet();
auto rows = ws.rows(false);
for (int i = 0; i < rows.length(); i++)
{
for (auto cell: rows[i])
{
xlnt::color cell_color = cell.font().color(); //
Я получаю это сообщение об ошибке: < /p>
Unhandled standard exception of type "N4xlnt17invalid_attributeE" with message
"xlnt::exception : bad attribute"; terminating the application.
https://xlnt-community.github.io/xlnt/c ... ad725ff208 функции alte alte ». src = "https://i.sstatic.net/vtkzy8po.png"/>
Обновление 1)
с:
Код: Выделить всё
for (auto& cell : row)
< /code>
Я получаю эту ошибку: < /p>
error: cannot bind non-const lvalue reference of type
‘xlnt::cell&’ to an rvalue of type
‘xlnt::cell_iterator::reference’ {aka ‘xlnt::cell’}
< /code>
Единственный способ не иметь такого рода ошибок: < /p>
for(auto row : rows)
{
for (auto cell : row)
{
}
}
< /code>
Но с: < /p>
xlnt::workbook wb;
wb.load(WBurl);
auto ws = wb.active_sheet();
auto rows = ws.rows(false);
for(auto row : rows)
{
for (auto cell : row)
{
if (cell.font().has_color())
{
xlnt::color cell_color = cell.font().color();
}
}
}
< /code>
Я все еще получаю ошибку: < /p>
Unhandled standard exception of type "N4xlnt17invalid_attributeE"
with message "xlnt::exception : bad attribute"; terminating the
application.
Код: Выделить всё
if (cell.font().has_color())
{
std::cout
(gdb) catch throw
Catchpoint 1 (throw)
(gdb) run
Но с этой строкой кода я получаю следующее:
Код: Выделить всё
Downloading source file /build/gcc-14-ig5ci0/gcc-14-14.2.0/build/x86_64-linux-gnu/libstdc++-v3/libsupc++/../../../../src/libstdc++-v3/libsupc++/eh_throw.cc
Thread 1 "Grasp" hit Catchpoint 1 (exception thrown), 0x00007fffe8abb35a in __cxxabiv1::__cxa_throw (obj=0x555557c4ea20,
tinfo=0x7fffeddaf2b8 , dest=0x7fffedb13e7a )
at ../../../../src/libstdc++-v3/libsupc++/eh_throw.cc:81
warning: 81 ../../../../src/libstdc++-v3/libsupc++/eh_throw.cc: No such file or directory
(gdb)
(gdb) bt
#0 0x00007fffe8abb35a in __cxxabiv1::__cxa_throw
(obj=0x555557c4ea20, tinfo=0x7fffeddaf2b8 , dest=0x7fffedb13e7a )
at ../../../../src/libstdc++-v3/libsupc++/eh_throw.cc:81
#1 0x00007fffedabc660 in xlnt::cell::format() const () at /usr/local/lib/libxlnt.so.1.5.0
#2 0x00007fffedabc827 in xlnt::cell::font() const () at /usr/local/lib/libxlnt.so.1.5.0
Как заставить его работать?
Подробнее здесь: https://stackoverflow.com/questions/796 ... -attribute
Мобильная версия