From d7702dd47d889fc4bb0d003f5c1c9ec058ea8461 Mon Sep 17 00:00:00 2001 From: underdorff18 Date: Sat, 25 Jun 2022 16:07:36 -0400 Subject: [PATCH] added to excelreader and fixed some minor naming issues --- JS/Inventory/.~lock.samplepc1234.xlsx# | 1 + JS/excelreader.js | 19 +++++++++++++------ JS/{systems.js => system.js} | 4 ++-- 3 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 JS/Inventory/.~lock.samplepc1234.xlsx# rename JS/{systems.js => system.js} (83%) diff --git a/JS/Inventory/.~lock.samplepc1234.xlsx# b/JS/Inventory/.~lock.samplepc1234.xlsx# new file mode 100644 index 0000000..e0c6d68 --- /dev/null +++ b/JS/Inventory/.~lock.samplepc1234.xlsx# @@ -0,0 +1 @@ +,nick,nick-Kubuntu,25.06.2022 15:42,file:///home/nick/.config/libreoffice/4; \ No newline at end of file diff --git a/JS/excelreader.js b/JS/excelreader.js index 870e54a..fadfd78 100644 --- a/JS/excelreader.js +++ b/JS/excelreader.js @@ -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)); + diff --git a/JS/systems.js b/JS/system.js similarity index 83% rename from JS/systems.js rename to JS/system.js index fdfdb14..906dc71 100644 --- a/JS/systems.js +++ b/JS/system.js @@ -1,4 +1,4 @@ -class Systems { +class System { constructor (serialnum, model, OS, price, specs) { this.serialnum = serialnum; this.model = model; @@ -8,4 +8,4 @@ class Systems { } } -module.exports = Systems; \ No newline at end of file +module.exports = System; \ No newline at end of file