NamedRanges changes

This commit is contained in:
francisco aloi
2024-12-28 12:32:40 +01:00
committed by Nicolás Hatcher Andrés
parent cbda30f951
commit 832ca02e16
6 changed files with 445 additions and 7 deletions

View File

@@ -1,6 +1,10 @@
import type { Area, Cell } from "./types";
import { columnNameFromNumber } from "@ironcalc/wasm";
import {
type SelectedView,
type WorksheetProperties,
columnNameFromNumber,
} from "@ironcalc/wasm";
/**
* Returns true if the keypress should start editing
@@ -57,7 +61,24 @@ export function rangeToStr(
if (rowStart === rowEnd && columnStart === columnEnd) {
return `${sheetName}${columnNameFromNumber(columnStart)}${rowStart}`;
}
return `${sheetName}${columnNameFromNumber(
columnStart,
)}${rowStart}:${columnNameFromNumber(columnEnd)}${rowEnd}`;
return `${sheetName}${columnNameFromNumber(columnStart)}${rowStart}:${columnNameFromNumber(
columnEnd,
)}${rowEnd}`;
}
export function getFullRangeToString(
selectedView: SelectedView,
worksheets: WorksheetProperties[], // solo pasar names
): string {
// order of values is confusing compared to rangeToStr range type, needs refactoring for consistency
const [rowStart, columnStart, rowEnd, columnEnd] = selectedView.range;
const sheetNames = worksheets.map((s) => s.name);
const sheetName = `${sheetNames[selectedView.sheet]}!`;
if (rowStart === rowEnd && columnStart === columnEnd) {
return `${sheetName}${columnNameFromNumber(columnStart)}${rowStart}`;
}
return `${sheetName}${columnNameFromNumber(columnStart)}${rowStart}:${columnNameFromNumber(
columnEnd,
)}${rowEnd}`;
}