xlsx-import
Version:
Import data from xlsx file using configured pattern and defined typescript types
53 lines • 2.22 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Importer = void 0;
var ImportType_1 = require("./config/ImportType");
var strategies_1 = require("./strategies");
var Importer = /** @class */ (function () {
function Importer(wb) {
this.wb = wb;
}
Importer.prototype.getAllItems = function (config) {
var worksheet = config.worksheet;
var type = config.type || ImportType_1.IMPORT_TYPE_DEFAULT;
var ws = this.wb.getWorksheet(worksheet);
if (!ws) {
throw new Error("Worksheet \"" + worksheet + "\" not found in workbook.");
}
return strategies_1.getStrategyByType(type)(config, ws);
};
Importer.prototype.getFirstItem = function (config) {
var wsData = this.getAllItems(config);
return wsData[0];
};
return Importer;
}());
exports.Importer = Importer;
/** @deprecated Default exports will be removed in January 2021. Please to use brackets (`{ Importer }`). */
// tslint:disable-next-line:no-empty-interface max-classes-per-file
var ImporterLegacy = /** @class */ (function (_super) {
__extends(ImporterLegacy, _super);
function ImporterLegacy() {
return _super !== null && _super.apply(this, arguments) || this;
}
/** @deprecated Refactoring performed, please to use `import { Importer }` and rename to camelCase version `getAllItems`. */
ImporterLegacy.prototype.GetAllItems = function (config) {
return this.getAllItems(config);
};
return ImporterLegacy;
}(Importer));
exports.default = ImporterLegacy;
//# sourceMappingURL=Importer.js.map