@gatekeeper_technology/excel-utils 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # Gatekeeper's Excel Utils
2
2
 
3
3
  ## Changelog
4
+ ### [1.00.09] 24-08-2022
5
+ ### Added
6
+ - Ability to load data into worksheet with row offset.
7
+ ### [1.00.08] 24-08-2022
8
+ ### Added
9
+ - Ability to get worksheet by name.
10
+ - Ability to get worksheet by index.
4
11
  ### [1.00.07] 24-08-2022
5
12
  ### Fixed
6
13
  - Fixed bug where workbook_creator class was not exported properly.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gatekeeper_technology/excel-utils",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "Gatekeeper's excel Utils - shared in NPM",
5
5
  "author": "David Holtzhausen",
6
6
  "main": "index.js",
@@ -62,6 +62,23 @@ let WorkbookCreator = class {
62
62
  return worksheet;
63
63
  }
64
64
 
65
+ /**
66
+ * Load data into worksheet
67
+ * @param {ExcelJS.Worksheet} worksheet Worksheet
68
+ * @param {string[][]} data Data array
69
+ * @param {number} offset Number of rows to skip before writing data
70
+ * @returns {ExcelJS.Worksheet} The created workbook
71
+ */
72
+ loadDataIntoWorksheetWithRowOffset(worksheet, data, row_offset) {
73
+ for (let _row_data of data.entries()) {
74
+ // Get a row object. If it doesn't already exist, a new empty one will be returned
75
+ let row = worksheet.getRow(row_offset + 1);
76
+ row.values = _row_data;
77
+ }
78
+
79
+ return worksheet;
80
+ }
81
+
65
82
  /**
66
83
  * Save workbook as XLSX
67
84
  * @param {ExcelJS.Workbook} workbook Workbook
@@ -124,6 +141,26 @@ let WorkbookCreator = class {
124
141
  };
125
142
  }
126
143
 
144
+ /**
145
+ * Gets worksheet with specified name within workbook
146
+ * @param {ExcelJS.Workbook} workbook
147
+ * @param {string} worksheet_name
148
+ * @returns {ExcelJS.Worksheet} Worksheet with specified name
149
+ */
150
+ getWorksheetByName(workbook, worksheet_name) {
151
+ return workbook.getWorksheet(worksheet_name);
152
+ }
153
+
154
+ /**
155
+ * Gets worksheet at specified index within workbook
156
+ * @param {ExcelJS.Workbook} workbook
157
+ * @param {number} index
158
+ * @returns {ExcelJS.Worksheet} Worksheet at specified index
159
+ */
160
+ getWorksheetByIndex(workbook, worksheet_index) {
161
+ return workbook.worksheets[worksheet_index];
162
+ }
163
+
127
164
  }
128
165
 
129
166
  module.exports = WorkbookCreator;