FIX: Download all selected area

We were previously downloading only the bounds of the visible cells,
without taking into account the frozen rows/colums.

Fixes #343
This commit is contained in:
Nicolás Hatcher
2025-05-17 11:38:05 +02:00
committed by Nicolás Hatcher Andrés
parent c554d929f4
commit a5d8ee9ef0

View File

@@ -567,19 +567,15 @@ const Workbook = (props: { model: Model; workbookState: WorkbookState }) => {
const { const {
range: [rowStart, columnStart, rowEnd, columnEnd], range: [rowStart, columnStart, rowEnd, columnEnd],
} = model.getSelectedView(); } = model.getSelectedView();
const { topLeftCell, bottomRightCell } = // NB: cells outside of the displayed area are not rendered
worksheetCanvas.getVisibleCells(); // I think the only reasonable way to do this would be server side.
const firstRow = Math.max(rowStart, topLeftCell.row);
const firstColumn = Math.max(columnStart, topLeftCell.column);
const lastRow = Math.min(rowEnd, bottomRightCell.row);
const lastColumn = Math.min(columnEnd, bottomRightCell.column);
let [x, y] = worksheetCanvas.getCoordinatesByCell( let [x, y] = worksheetCanvas.getCoordinatesByCell(
firstRow, rowStart,
firstColumn, columnStart,
); );
const [x1, y1] = worksheetCanvas.getCoordinatesByCell( const [x1, y1] = worksheetCanvas.getCoordinatesByCell(
lastRow + 1, rowEnd,
lastColumn + 1, columnEnd,
); );
const width = (x1 - x) * devicePixelRatio; const width = (x1 - x) * devicePixelRatio;
const height = (y1 - y) * devicePixelRatio; const height = (y1 - y) * devicePixelRatio;