committed by
GitHub
parent
1edfb2df1c
commit
a890865eaf
@@ -1,36 +1,12 @@
|
||||
import type { Area, Cell } from "./types";
|
||||
|
||||
import { type SelectedView, columnNameFromNumber } from "@ironcalc/wasm";
|
||||
import {
|
||||
type SelectedView,
|
||||
columnNameFromNumber,
|
||||
quoteName,
|
||||
} from "@ironcalc/wasm";
|
||||
import { LAST_COLUMN, LAST_ROW } from "./WorksheetCanvas/constants";
|
||||
|
||||
// FIXME: Use the `quoteName` function from the wasm module
|
||||
function nameNeedsQuoting(name: string): boolean {
|
||||
// it contains any of these characters: ()'$,;-+{} or space
|
||||
for (const char of name) {
|
||||
if (" ()'$,;-+{}".includes(char)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO:
|
||||
// - cell reference in A1 notation, e.g. B1048576 is quoted, B1048577 is not
|
||||
// - cell reference in R1C1 notation, e.g. RC, RC2, R5C, R-4C, RC-8, R, C
|
||||
// - integers
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quotes a string sheet name if it needs to
|
||||
* NOTE: Invalid characters in a sheet name: \, /, *, [, ], :, ?
|
||||
*/
|
||||
export function quoteName(name: string): string {
|
||||
if (nameNeedsQuoting(name)) {
|
||||
return `'${name.replace(/'/g, "''")}'`;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the keypress should start editing
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user