I'm encountering issues with my program today. I am developing a simple electron.js application to send payment talons to members from an Excel file.
The problem arises when trying to print out the member's name from a loop.
If I use:
'<p> ' + 'my name' + ' </p>' +
it works perfectly fine, but as soon as I substitute a variable in its place, everything gets jumbled up.
'<p> ' + first_name_val + ' </p>' +
https://i.sstatic.net/Z4TIp.png
Here is the entire JavaScript code:
var xlsx = require('xlsx');
var workbook = xlsx.readFile('./app/members.xlsx');
var first_sheet_name = workbook.SheetNames[0];
var worksheet = workbook.Sheets[first_sheet_name];
var members = [];
var count = 0;
var payed_count = 0;
for(var i = 12; i < 500; i++)
{
var id = 'A' + i;
var first_name = 'B' + i;
var last_name = 'C' + i;
var kommentar = 'H' + i;
var betalt = 'J' + i;
var d_id = worksheet[id];
var d_first_name = worksheet[first_name];
var d_last_name = worksheet[last_name];
var d_kommentar = worksheet[kommentar];
var d_betalt = worksheet[betalt];
if(betalt_val == ' '){
$("#pageswithpgtalon").append(
'<div class="page">' +
'<div class="from">' +
'<h2>title</h2>' +
'<p>Intresseförening</p>' +
'</div>' +
'<div class="to">' +
'<p> ' + first_name_val + ' </p>' +
'<p>address</p>' +
'</div>' +
'<div class="textbox">' +
'</div>' +
'<div class="toplusgiro">' +
'49 87 85 - 5' +
' </div>' +
'<div class="paymentrecipient">' +
'Joakim Wennergren' +
'</div>' +
'</div>'
)
}
var id_val = (d_id ? d_id.v : ' ');
var first_name_val = (d_first_name ? d_first_name.v : ' ');
var last_name_val = (d_last_name ? d_last_name.v : ' ');
var kommentar_val = (d_kommentar ? d_kommentar.v : ' ')
var betalt_val = (d_betalt ? d_betalt.v : ' ')
if(betalt_val != ' '){
payed_count++;
}
count++;
if(!d_first_name)
break;
}
$("#nusers").html(count);
$("#npages_with_pg").html(payed_count);
$("#npages_without_pg").html(count - payed_count);
Below is my CSS code:
html,
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
-webkit-print-color-adjust: exact;
font-size: 14px;
}
@media print {
body {
margin: 0px 0px 0px 0px !important;
}
}
@import "~bootstrap/dist/css/bootstrap.css";
/* Additional CSS rules here */