Files
odoo_source/addons/spreadsheet/static/tests/utils/getters.js
T
Lucas Lefèvre 4bb43e2554 [IMP] spreadsheet: update o_spreadsheet to latest version
https://github.com/odoo/o-spreadsheet/commit/ab6f47f9 [FIX] InternalViewport: compute the actual visible rect of a zone
https://github.com/odoo/o-spreadsheet/commit/966c311e [REF] plugins: unify position getters API
https://github.com/odoo/o-spreadsheet/commit/9f1c9695 [IMP] model: ignore type property in command payload
https://github.com/odoo/o-spreadsheet/commit/862dacbc [REF] selection: rename getPosition to getActivePosition
https://github.com/odoo/o-spreadsheet/commit/0144515a [REF] selection: getPosition return main position
https://github.com/odoo/o-spreadsheet/commit/38422f4f [FIX] find and replace: scroll on single match.
https://github.com/odoo/o-spreadsheet/commit/9be582c7 [FIX] selection_input: traceback when using unbounded ranges
https://github.com/odoo/o-spreadsheet/commit/49285322 [IMP] doc: add tables of contents
https://github.com/odoo/o-spreadsheet/commit/2c5d86af [IMP] model: config to provide external dependencies
https://github.com/odoo/o-spreadsheet/commit/5b442218 [REF] plugins: use object in constructor
https://github.com/odoo/o-spreadsheet/commit/ef98be1b [REM] plugins: remove useless modes
https://github.com/odoo/o-spreadsheet/commit/4f20d05f [IMP] data: reorganize data top menu

closes odoo/odoo#106583

Related: odoo/enterprise#34412
Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com>
2022-11-28 14:51:24 +01:00

58 lines
1.7 KiB
JavaScript

/** @odoo-module */
import spreadsheet from "@spreadsheet/o_spreadsheet/o_spreadsheet_extended";
const { toCartesian } = spreadsheet.helpers;
/**
* Get the value of the given cell
*/
export function getCellValue(model, xc, sheetId = model.getters.getActiveSheetId()) {
const { col, row } = toCartesian(xc);
const cell = model.getters.getEvaluatedCell({ sheetId, col, row });
return cell.value;
}
/**
* Get the cell of the given xc
*/
export function getCell(model, xc, sheetId = model.getters.getActiveSheetId()) {
const { col, row } = toCartesian(xc);
return model.getters.getCell({ sheetId, col, row });
}
export function getEvaluatedCell(model, xc, sheetId = model.getters.getActiveSheetId()) {
const { col, row } = toCartesian(xc);
return model.getters.getEvaluatedCell({ sheetId, col, row });
}
/**
* Get the cells of the given sheet (or active sheet if not provided)
*/
export function getCells(model, sheetId = model.getters.getActiveSheetId()) {
return model.getters.getCells(sheetId);
}
/**
* Get the formula of the given xc
*/
export function getCellFormula(model, xc, sheetId = model.getters.getActiveSheetId()) {
const cell = getCell(model, xc, sheetId);
return cell && cell.isFormula ? model.getters.getFormulaCellContent(sheetId, cell) : "";
}
/**
* Get the content of the given xc
*/
export function getCellContent(model, xc, sheetId = model.getters.getActiveSheetId()) {
const { col, row } = toCartesian(xc);
return model.getters.getCellText({ sheetId, col, row }, true);
}
/**
* Get the list of the merges (["A1:A2"]) of the sheet
*/
export function getMerges(model, sheetId = model.getters.getActiveSheetId()) {
return model.exportData().sheets.find((sheet) => sheet.id === sheetId).merges;
}