15#ifndef OPENXLSX_XLSTREAMREADER_HPP
16#define OPENXLSX_XLSTREAMREADER_HPP
18#include "OpenXLSX-Exports.hpp"
28#include <unordered_set>
143 explicit XLStreamColumns(std::vector<std::vector<XLCellValue>> columns);
148 const std::vector<XLCellValue>& values()
const;
152 std::vector<std::vector<XLCellValue>> m_columns;
154 bool m_started{
false};
191 std::vector<XLCellValue>
nextRow();
257 const std::string&
lastError()
const {
return m_lastError; }
271 void fetchMoreData();
273 void compactBufferIfNeeded();
276 bool loadNextPhysicalRow();
279 bool consumeNextLogicalRow();
281 void parsePhysicalRowSlice(
const char* p,
const char* end);
282 XLCellValue parseCellValue(
const std::string& cellType, std::string& cellValue)
const;
283 std::string resolveFormatCode(
XLStyleIndex styleIndex)
const;
284 std::string valueToRawString(
const XLCellValue& value)
const;
285 void ensureIndexedSst()
const;
286 std::string lookupIndexedSst(int32_t index)
const;
287 bool columnAllowed(uint16_t col)
const;
288 void rebuildColumnFilterSet()
const;
290 static std::string builtinNumFmtCode(uint32_t numFmtId);
293 IZipArchive m_archive{};
294 void* m_zipStream{
nullptr};
295 XLStreamReadOptions m_options{};
296 mutable std::unordered_set<uint16_t> m_columnFilterSet{};
297 mutable bool m_columnFilterReady{
false};
300 mutable bool m_sstIndexReady{
false};
301 mutable std::string m_sstXml;
302 mutable std::filesystem::path m_sstTempPath;
303 mutable bool m_sstFileBacked{
false};
304 mutable std::vector<uint32_t> m_sstOffsets;
306 std::string m_buffer;
310 uint32_t m_currentRow{0};
311 uint32_t m_lastPhysicalRow{0};
312 bool m_hasPendingPhysical{
false};
313 bool m_physicalExhausted{
false};
316 uint32_t m_pendingRowNum{0};
317 XLStreamRowOptsView m_pendingRowOpts{};
318 std::vector<XLStreamCellView> m_pendingCells{};
321 XLStreamRowOptsView m_currentRowOpts{};
324 std::string m_tagNameBuf;
325 std::string m_attrNameBuf;
326 std::string m_attrValueBuf;
327 std::string m_textContentBuf;
328 std::string m_lastError;
331 std::vector<XLCellValue> m_reuseValues;
332 std::vector<XLStreamCellView> m_reuseDetailed;
333 std::vector<std::string> m_reuseStrings;
Class encapsulating a cell value.
Definition XLCellValue.hpp:89
Column-oriented cursor over a worksheet (excelize Cols-like).
Definition XLStreamReader.hpp:140
bool next()
Definition XLStreamReader.cpp:942
uint16_t currentColumn() const
Definition XLStreamReader.hpp:147
XLStreamColumns()=default
size_t columnCount() const
Definition XLStreamReader.hpp:149
std::vector< std::string > nextRowStrings()
Next row as display strings (optionally applying number formats).
Definition XLStreamReader.cpp:1088
bool forEachCellInNextRow(const std::function< void(const XLStreamCellView &)> &fn)
Consume the next logical row and invoke fn for each projected cell.
Definition XLStreamReader.cpp:928
XLStreamRowOptsView currentRowOpts() const
Row options for the last returned row.
Definition XLStreamReader.cpp:1104
XLStreamReader(const XLStreamReader &)=delete
std::vector< XLStreamCellView > nextRowDetailed()
Next row with formula, style index, and column metadata per cell.
Definition XLStreamReader.cpp:856
friend class XLWorksheet
Definition XLStreamReader.hpp:267
uint32_t currentRow() const
1-based index of the row last returned by nextRow / nextRowDetailed / nextRowStrings.
Definition XLStreamReader.cpp:1102
bool nextRowDetailedInto(std::vector< XLStreamCellView > &out)
Fill out with the next detailed row; returns false at end.
Definition XLStreamReader.cpp:883
bool hasNext()
Checks if there are more rows to read (physical and/or synthetic empty).
Definition XLStreamReader.cpp:277
const std::string & lastError() const
Last error message from a soft parse failure (empty if none).
Definition XLStreamReader.hpp:257
std::vector< XLStreamCellView > nextRowProjected()
Next row with only columns listed in options.columnFilter (or non-empty cells if filter empty).
Definition XLStreamReader.cpp:909
XLStreamColumns streamColumns()
Materialize all columns via one full stream pass (excelize Cols equivalent).
Definition XLStreamReader.cpp:962
bool nextRowInto(std::vector< XLCellValue > &out)
Fill out with the next dense row values; returns false at end.
Definition XLStreamReader.cpp:873
const XLStreamReadOptions & options() const
Definition XLStreamReader.hpp:264
XLStreamReader & operator=(const XLStreamReader &)=delete
std::vector< XLCellValue > nextRow()
Parses and returns the next row of cell values (backward-compatible API).
Definition XLStreamReader.cpp:850
std::vector< XLStreamCellView > nextRowSparse()
Next row containing only non-empty cells (no sparse padding).
Definition XLStreamReader.cpp:862
std::string formattedValue(const XLStreamCellView &cell) const
Format a single cell view using workbook styles when applyNumberFormats is enabled.
Definition XLStreamReader.cpp:1073
A class encapsulating an Excel worksheet. Access to XLWorksheet objects should be via the workbook ob...
Definition XLWorksheet.hpp:132
Definition IXLCellProvider.hpp:24
XLStreamEmptyRowPolicy
Policy for logical row gaps (missing <row> elements in sheetData).
Definition XLStreamReader.hpp:39
@ EmitEmptyRows
Synthesize empty rows for gaps in row numbers (excelize GetRows-like).
Definition XLStreamReader.hpp:50
@ SkipMissingRows
Only return rows that exist in the XML (legacy default).
Definition XLStreamReader.hpp:45
size_t XLStyleIndex
Definition XLStyles_Common.hpp:36
XLStreamSharedStringMode
How shared-string cells (t="s") are resolved during streaming reads.
Definition XLStreamReader.hpp:56
@ Eager
Use the workbook's in-memory shared string table (default, fastest for small SST).
Definition XLStreamReader.hpp:60
@ Indexed
Build a byte-offset index into sharedStrings.xml and resolve strings on demand.
Definition XLStreamReader.hpp:65
Rich view of a single streamed cell (value + formula + style).
Definition XLStreamReader.hpp:118
std::optional< int > formulaSi
Definition XLStreamReader.hpp:127
std::optional< std::string > formula
Definition XLStreamReader.hpp:120
XLCellValue value
Definition XLStreamReader.hpp:119
std::optional< XLStyleIndex > styleIndex
Definition XLStreamReader.hpp:121
std::optional< std::string > formulaType
Definition XLStreamReader.hpp:125
std::optional< XLRichText > richText
Definition XLStreamReader.hpp:131
uint16_t column
Definition XLStreamReader.hpp:122
bool formulaCa
Definition XLStreamReader.hpp:128
std::optional< std::string > formulaRef
Definition XLStreamReader.hpp:126
Options for XLStreamReader construction.
Definition XLStreamReader.hpp:72
bool parseRichText
When true, parse inlineStr <r> runs into XLRichText on XLStreamCellView.
Definition XLStreamReader.hpp:107
size_t maxRowBytes
Reject a single physical <row> larger than this many bytes (0 = unlimited).
Definition XLStreamReader.hpp:85
bool applyNumberFormats
When true, formattedValue() / nextRowStrings() apply number formats via XLNumberFormatter.
Definition XLStreamReader.hpp:78
std::vector< uint16_t > columnFilter
1-based column projection mask. Empty = all columns.
Definition XLStreamReader.hpp:97
XLStreamSharedStringMode sharedStringMode
Definition XLStreamReader.hpp:79
size_t maxSstEntryBytes
Reject sharedStrings (or other bulk loads via this reader) larger than this (0 = unlimited).
Definition XLStreamReader.hpp:102
size_t maxColumnarCells
Max cells buffered when materializing streamColumns() (0 = unlimited). Default 50M cells.
Definition XLStreamReader.hpp:111
std::filesystem::path tempDir
Definition XLStreamReader.hpp:92
size_t sstSpillThreshold
When Indexed SST exceeds this size, keep payload on a temp file and mmap-style seek.
Definition XLStreamReader.hpp:90
XLStreamEmptyRowPolicy emptyRows
Definition XLStreamReader.hpp:73
Row-level attributes for the last consumed physical/logical row (excelize GetRowOpts).
Definition XLStreamReader.hpp:161
std::optional< double > height
Definition XLStreamReader.hpp:162
std::optional< uint8_t > outlineLevel
Definition XLStreamReader.hpp:164
std::optional< XLStyleIndex > styleIndex
Definition XLStreamReader.hpp:165
std::optional< bool > hidden
Definition XLStreamReader.hpp:163
bool isSyntheticEmpty
Definition XLStreamReader.hpp:166