For large files where RAM usage is a concern, use read_sheet_sax instead of standard loading. This uses a SAX parser to process cells one by one via a callback.
Configuration with sax_options:
resolve_shared_strings: Set to true to resolve strings, or false to save RAM (though you may get shared string indices instead).read_formulas_as_text: If true, outputs the formula string instead of the calculated result.stop_on_empty_sheetdata: If false, continues processing even if sheetData is empty.
void dump_all_sheets_sax(QXlsx::Document& doc)
{
QXlsx::sax_options opt;
opt.resolve_shared_strings = true;
opt.read_formulas_as_text = true;
opt.stop_on_empty_sheetdata = false;
const QStringList sheets = doc.sheetNames();
for (const QString& sheet_name : sheets) {
doc.read_sheet_sax(
sheet_name,
opt,
[&](const QXlsx::sax_cell& cell) -> bool {
qDebug().noquote()
<< QString("%1!R%2C%3 = %4")
.arg(cell.sheet_name)
.arg(cell.row)
.arg(cell.col)
.arg(cell.value.toString());
return true; // continue
});
}
}