Skip to content

Commit

Permalink
added to excelreader and fixed some minor naming issues
Browse files Browse the repository at this point in the history
  • Loading branch information
underdorff18 committed Jun 25, 2022
1 parent 00249ed commit d7702dd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions JS/Inventory/.~lock.samplepc1234.xlsx#
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
,nick,nick-Kubuntu,25.06.2022 15:42,file:///home/nick/.config/libreoffice/4;
19 changes: 13 additions & 6 deletions JS/excelreader.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
const fs = require('fs');
const path = require('path');
const xlsx = require('xlsx');
const System = require('./system');

const myfilepath = path.join(__dirname, 'Inventory', 'samplepc1234.xlsx');

function readInventoryFile(filepath) {
const workbook = xlsx.readFileSync(filepath);
const sheetNames = workbook.SheetNames;
const data = workbook.Sheets[sheetNames[0]];
console.log(data);
let workbook = xlsx.readFileSync(filepath);
let sheetNames = workbook.SheetNames;
let sheetData = workbook.Sheets[sheetNames[0]];

//Here is where we use known cell locations of the specs needed to build the systems file
let serialNum = sheetData.D1.v;
let model = sheetData.D2.v;
let OS = sheetData.D3.v;
let price = sheetData.D4.v;
let specs = [sheetData.D5.v, sheetData.D6.v, sheetData.D7.v, sheetData.D8.v];

return new System(serialNum, model, OS, price, specs);
}


readInventoryFile(myfilepath);
//console.log('yo');
console.log(readInventoryFile(myfilepath));


4 changes: 2 additions & 2 deletions JS/systems.js → JS/system.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Systems {
class System {
constructor (serialnum, model, OS, price, specs) {
this.serialnum = serialnum;
this.model = model;
Expand All @@ -8,4 +8,4 @@ class Systems {
}
}

module.exports = Systems;
module.exports = System;

0 comments on commit d7702dd

Please sign in to comment.