From 44df6b0c8ca008a3f829e6a180831e0b9dc173be Mon Sep 17 00:00:00 2001 From: Michael Firlus Date: Fri, 10 Jun 2022 16:07:03 +0200 Subject: [PATCH] Error handling for cell row/col smaller than 1 --- source/lib/cell/cell.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/source/lib/cell/cell.js b/source/lib/cell/cell.js index 90e2bb16..cd83a9f3 100644 --- a/source/lib/cell/cell.js +++ b/source/lib/cell/cell.js @@ -4,12 +4,14 @@ const Comment = require('../classes/comment'); // §18.3.1.4 c (Cell) class Cell { /** - * Create an Excel Cell - * @private - * @param {Number} row Row of cell. - * @param {Number} col Column of cell - */ + * Create an Excel Cell + * @private + * @param {Number} row Row of cell. + * @param {Number} col Column of cell + */ constructor(row, col) { + if (row <= 0) throw 'Row parameter must not be zero or negative.'; + if (col <= 0) throw 'Col parameter must not be zero or negative.'; this.r = `${utils.getExcelAlpha(col)}${row}`; // 'r' attribute this.s = 0; // 's' attribute refering to style index this.t = null; // 't' attribute stating Cell data type - §18.18.11 ST_CellType (Cell Type) @@ -77,4 +79,3 @@ class Cell { } module.exports = Cell; -