Skip to content

Commit

Permalink
hacky batch read
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanmajh committed Aug 27, 2021
1 parent 85508b3 commit 5b8ea7a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
16 changes: 7 additions & 9 deletions assets/spreadsheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class ExcelReader {
await wb.xlsx.readFile(this.filePath);
const ws = wb.getWorksheet('Sheet1');
let version = dt.DateTime.fromSeconds((parseFloat(ws.getCell('K2').text)-25569)*86400+14400).toFormat('yyyy-LL-dd HH:mm:ss')
debugger
return version;
}

Expand Down Expand Up @@ -72,23 +71,22 @@ class ExcelReader {
await workbook.xlsx.readFile(this.filePath);
fs.copyFileSync(this.filePath, `${this.filePath}.backup`);
postMessage(['info', `Backing up file as: "${this.filePath}.backup"`]);
debugger
if (!(workbook.SheetNames.includes(wsName))) {
const wsNames = workbook.worksheets.map(function (ele) {return ele.name;});
if (!(wsNames.includes(wsName))) {
postMessage(['info', 'Workbook has the following worksheets:']);
postMessage(['info', `${workbook.SheetNames}`]);
postMessage(['info', `${wsNames}`]);
postMessage(['error', `"${wsName} does not exist, Please check spelling & captitalization"`]);
return false;
}
let worksheet = workbook.Sheets[wsName];
let range = xlsx.utils.decode_range(worksheet[`!ref`]);
let lastrow = range.e.r + 1;
let worksheet = workbook.getWorksheet(wsName);
let lastrow = worksheet.lastRow.number;
let data = [];
let row = [];
for (let i = startRow; i <= lastrow; i++) {
row = [];
for (let j = 0; j < columns.length; j++) {
if (worksheet[`${columns[j]}${i}`]) {
row.push(worksheet[`${columns[j]}${i}`].v);
if (worksheet.getCell(`${columns[j]}${i}`).text) {
row.push(worksheet.getCell(`${columns[j]}${i}`).text);
}
}
data.push([i, row.join()]);
Expand Down
1 change: 0 additions & 1 deletion renderer/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ async function checkItemCache() {
let xlVersion = await excel.getVersion();
let curVersion = await db.getVersion('maximoItemCache');
curVersion = curVersion[0]?.version;
debugger;
if (!(curVersion >= xlVersion)) {
postMessage(['debug', `40%: Loading item cache data from file`]);
await db.db.itemCache.clear().then(function () {
Expand Down

0 comments on commit 5b8ea7a

Please sign in to comment.