There is a class:

class xlsxRow{ constructor(name, articul, unit, quantity_ttk, quantity_fact, quantity_price_opt, unit_fact, name_db, percent, quantity_price_roz){ //name2 = name; //this.name2 = name; this.name = name; this.articul = articul; this.unit = unit; this.quantity_ttk = quantity_ttk; this.quantity_fact = quantity_fact; this.quantity_price_opt = quantity_price_opt; this.unit_fact = unit_fact; this.name_db = name_db; this.percent = percent; this.quantity_price_roz = quantity_price_roz; } getName(){ return this.name; } getArtucul(){ return this.articul; } getUnit(){ return this.unit; } getQuantityTtk(){ return this.quantity_ttk; } getQuantityFact(){ return this.quantity_fact; } getQuantityPriceOpt(){ return this.quantity_price_opt; } getUnitFact(){ return this.unitFact; } getNameDb(){ return this.name_db; } getPercent(){ return this.percent; } getQuantityPriceRoz(){ return this.quantity_price_roz; } setName(name){ this.name = name; } getArtucul(articul){ this.articul = articul; } setUnit(unit){ this.unit = unit; } setQuantityTtk(quantity_ttk){ this.quantity_ttk = quantity_ttk; } setQuantityFact(quantity_fact){ this.quantity_fact = quantity_fact; } setQuantityPriceOpt(quantity_price_opt){ this.quantity_price_opt = quantity_price_opt; } setUnitFact(unitFact){ this.unitFact = unitFact; } setNameDb(name_db){ this.name_db = name_db; } setPercent(percent){ this.percent = percent; } setQuantityPriceRoz(quantity_price_roz){ this.quantity_price_roz = quantity_price_roz; } } module.exports = xlsxRow; 

There is a pattern:

 html head bode table(border=1) <tr><th>№</th><th>Наименование ТТК</th><th>Артикул</th><th>Ед. изм</th> <th>Количество ТТК</th><th>Факт</th><th>Цена опт.</th><th>Наименование</th> <th>%</th><th>Розница</th></tr> each n, index in rows td=n // как здесь начать вытаскивать поля из класса 

There is a route:

 app.get('/simple2', (req, res) => { const table = XLSX.readFile('ex.xls'); const sheet = table.Sheets[table.SheetNames[0]]; const arrayData = XLSX.utils.sheet_to_json(table.Sheets[table.SheetNames[0]], {header: 1, raw: false, cellText: true}); let index_map = 0; var rows = []; for (let i = 1; i <= 24; i++) { if (!isNaN(parseInt(arrayData[i][1], 10)) && parseInt(arrayData[i][2], 10) !== 2) { // из всех столбцов нам нужно только 6ть rows[++index_map] = new xlsxRow(arrayData[i][1],arrayData[i][2],arrayData[i][7],arrayData[i][8],parseInt(arrayData[i][23]),parseInt(arrayData[i][23]),arrayData[i][25].replace(',', ''),"пока что пусто",1.25,parseFloat(arrayData[i][25].replace(',', '')*1.25).toFixed(2)); } } console.log(rows.size); res.render('index2', {'rows': rows}); }); 

How can I display the class fields in index2.pug, something like: n.getName ()?

    1 answer 1

      let rows = []; for (let i = 1; i <= 26; i++) if (!isNaN(parseInt(arrayData[i][1], 10)) && parseInt(arrayData[i][2], 10) !== 2) rows.push(new xlsxRow(arrayData[i][2],arrayData[i][7],arrayData[i][8],parseInt(arrayData[i][23]),parseInt(arrayData[i][23]),arrayData[i][25].replace(',', ''),"пока что пусто",1.25,parseFloat(arrayData[i][25].replace(',', '')*1.25).toFixed(2))); res.render('index', { rows: rows }); 

     html head bode table(border=1) <tr><th>№</th><th>Наименование ТТК</th><th>Артикул</th><th>Ед. изм</th> <th>Количество ТТК</th><th>Факт</th><th>Цена опт.</th><th>Наименование</th> <th>%</th><th>Розница</th></tr> each row, index in rows tr(id='we' + index) td(class='idposix' + index)=index td(class='nametd' + index)=row.name td(class='art' + index)=row.articul td=row.unit td(name='opt_size' id='opt_size' + index class='opt_size' +index)=row.quantity_ttk td input(type='text' name='my_size' id='my_size' + index class='my_size' +index value=row.quantity_fact) td(class='opt_price' + index)=row.quantity_price_opt td input(type='text' name='currency' class='biginput' id='autocomplete' + index value=row.name) td input(type='text' name='c_percent'+ index class='c_percent' id='c_percent' + index value=row.percent) td(name='r_price' class='c_price' id=r_price + index)=row.quantity_price_roz