@gatekeeper_technology/excel-utils 1.0.6 → 1.0.8

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,9 +1,13 @@
1
1
  # Gatekeeper's Excel Utils
2
2
 
3
3
  ## Changelog
4
- ### [1.00.06] 18-03-2022
5
- ### Changed
6
- - Updated the structure of the package.
4
+ ### [1.00.08] 24-08-2022
5
+ ### Added
6
+ - Ability to get worksheet by name.
7
+ - Ability to get worksheet by index.
8
+ ### [1.00.07] 24-08-2022
9
+ ### Fixed
10
+ - Fixed bug where workbook_creator class was not exported properly.
7
11
  ### [1.00.05] 18-03-2022
8
12
  ### Changed
9
13
  - Fixed import bug
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
- const utils = require("./utils");
2
- const WorkbookCreator = require("./workbook_creator");
1
+ const workbookCreator = require("./workbook_creator.js");
2
+ const utils = require("./utils.js");
3
3
 
4
4
  module.exports = {
5
5
  utils,
6
- WorkbookCreator
6
+ workbookCreator
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gatekeeper_technology/excel-utils",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Gatekeeper's excel Utils - shared in NPM",
5
5
  "author": "David Holtzhausen",
6
6
  "main": "index.js",
package/utils.js CHANGED
@@ -1,7 +1,7 @@
1
- const WorkbookCreator = require("./workbook_creator");
1
+ const WorkbookCreator = require("./workbook_creator.js");
2
2
 
3
3
  async function generateXLSXBuffer(data, sheet_name) {
4
- const workbook_creator = new WorkbookCreator.WorkbookCreator();
4
+ const workbook_creator = new WorkbookCreator();
5
5
  let _workbook = workbook_creator.createWorkbook();
6
6
  let _worksheet = workbook_creator.createWorksheet(_workbook, sheet_name);
7
7
  workbook_creator.loadDataIntoWorksheet(_worksheet, data);
@@ -13,7 +13,7 @@ async function generateXLSXBuffer(data, sheet_name) {
13
13
  * Returns an array of all
14
14
  */
15
15
  async function getWorkbookData(data) {
16
- const workbook_creator = new WorkbookCreator.WorkbookCreator();
16
+ const workbook_creator = new WorkbookCreator();
17
17
  let _workbook = await workbook_creator.loadXLSX(data);
18
18
  let _worksheet = _workbook.worksheets[0];
19
19
 
@@ -28,4 +28,4 @@ async function getWorkbookData(data) {
28
28
  module.exports = {
29
29
  generateXLSXBuffer,
30
30
  getWorkbookData
31
- }
31
+ }
@@ -1,7 +1,9 @@
1
1
  const ExcelJS = require("exceljs");
2
2
 
3
- class WorkbookCreator {
4
- constructor() { }
3
+ let WorkbookCreator = class {
4
+ constructor() {
5
+
6
+ }
5
7
  /**
6
8
  * Create a new workbook
7
9
  * @returns {ExcelJS.Workbook} The created workbook
@@ -122,8 +124,26 @@ class WorkbookCreator {
122
124
  };
123
125
  }
124
126
 
127
+ /**
128
+ * Gets worksheet with specified name within workbook
129
+ * @param {ExcelJS.Workbook} workbook
130
+ * @param {string} worksheet_name
131
+ * @returns {ExcelJS.Worksheet} Worksheet with specified name
132
+ */
133
+ getWorksheetByName(workbook, worksheet_name) {
134
+ return workbook.getWorksheet(worksheet_name);
135
+ }
136
+
137
+ /**
138
+ * Gets worksheet at specified index within workbook
139
+ * @param {ExcelJS.Workbook} workbook
140
+ * @param {number} index
141
+ * @returns {ExcelJS.Worksheet} Worksheet at specified index
142
+ */
143
+ getWorksheetByIndex(workbook, worksheet_index) {
144
+ return workbook.worksheets[worksheet_index];
145
+ }
146
+
125
147
  }
126
148
 
127
- module.exports = {
128
- WorkbookCreator
129
- }
149
+ module.exports = WorkbookCreator;