SpreadsheetLayout.h header
#include <ew/core/SpreadsheetLayout.h>
Namespace ew::core
SpreadsheetGrid struct
struct ew::core::SpreadsheetGrid
A prospective spreadsheet grid: its dimensions, cells, per-cell formats, and custom column widths / row heights, as produced by a structural edit before it is committed. A structural edit moves each cell's format with the cell; inserting or deleting a row shifts the custom row heights to follow (a column edit shifts the column widths), so sizing stays aligned with the content it belongs to. A sort leaves widths and heights at their positions (only the content is reordered), matching common spreadsheet behavior.
Members
int ew::core::SpreadsheetGrid::rowCount = 0
The grid's row count.
int ew::core::SpreadsheetGrid::columnCount = 0
The grid's column count.
std::vector<SpreadsheetCell> ew::core::SpreadsheetGrid::cells
Every populated cell.
std::vector<SpreadsheetCellFormat> ew::core::SpreadsheetGrid::formats
Per-cell formats, moved with their cells by a structural edit.
std::map<int, int> ew::core::SpreadsheetGrid::columnWidths
Custom column widths, keyed by column index.
std::map<int, int> ew::core::SpreadsheetGrid::rowHeights
Custom row heights, keyed by row index.
Functions
QString ew::core::adjustFormulaReferences(const QString &formula, bool rowAxis, int at, int delta)
Rewrites the A1-style references in formula (a formula's text, with or without the leading '=') for a structural edit on the given axis: rowAxis selects rows vs columns, at is the inserted/removed index, and delta is +1 for an insert or -1 for a delete. A reference to a deleted line becomes "#REF!". A '$' pin is carried through but does not hold a reference still ($C$5 becomes $C$6 when a row is inserted above it), because a pin governs only which cell a formula points at once it is copied elsewhere. Exposed for testing.
SpreadsheetGrid ew::core::deleteColumn(const Spreadsheet &sheet, int at)
Returns sheet with column at removed (the column analogue of deleteRow).
SpreadsheetGrid ew::core::deleteRow(const Spreadsheet &sheet, int at)
Returns sheet with row at removed: its cells are dropped, lower cells move up one, the row count shrinks by one (never below one), and formula references are rewritten – a reference to the deleted row becomes the error token "#REF!".
SpreadsheetGrid ew::core::insertColumn(const Spreadsheet &sheet, int at)
Returns sheet with a blank column inserted at index at (the column analogue of insertRow).
SpreadsheetGrid ew::core::insertRow(const Spreadsheet &sheet, int at)
Returns sheet with a blank row inserted at index at: cells at or below at move down one, the row count grows by one, and A1-style references in every formula are rewritten so they keep pointing at the same data.
SpreadsheetGrid ew::core::sortRows(const Spreadsheet &sheet, int startRow, int endRow, int keyColumn, bool ascending)
Returns sheet with rows startRow..endRow (inclusive, clamped to the grid) reordered so their keyColumn values are sorted (ascending or descending); rows outside the range and every column stay put. Sorting is stable, keys compare by evaluated value (two numbers numerically, otherwise case-insensitively as text), and blank keys sort last in either direction. Cells and their formats move together, and A1 references to a moved row are rewritten so every formula keeps pointing at the same data (references inside string literals are left alone). A range that selects fewer than two rows returns sheet unchanged.