All, I have this output that I am exporting onclick to excel:
const final = totalBatches.reduce((AB, now, idx) => {
let A1 = z(AB, 8);
let A2 = z(AB + now / 2 - 1, 8);
let B1 = z(AB + now / 2, 8);
let B2 = z(AB + now - 1, 8);
output += `Batch ${z(idx + 1, 2)}A | ${prefix} ${A1} - ${prefix} ${A2}\n`;
output += `Batch ${z(idx + 1, 2)}B | ${prefix} ${B1} - ${prefix} ${B2}\n`;
return AB + now;
}, init);
outputEl.innerHTML = output;
}
The problem is, it needs to be formatted into separate columns so the excel sheet is formatted properly. So I added the following to output +=:
output += `\<tr\>\<td\>Batch ${z(idx + 1, 2)}A \</td\>\<td\>${prefix} ${A1} \</td\>\<td\>${prefix} ${A2}\</td\>\</tr\>\n`;
output += `\<tr style="border-bottom: 1px solid black;"\>\<td\>Batch ${z(idx + 1, 2)}B \</td\>\<td\>${prefix} ${B1} \</td\>\<td\>${prefix} ${B2}\</td\>\</tr\>\n`;
This (mostly) works. My excel export is now formatted into separate columns. But there are at least two problems. 1, it's ugly/clunky and hard to read... there has to be a more efficient way of doing this.
2, I haven't figured out a way for this output to have inline style for the user to have visual cues on the html page before export (I want every other row to be underlined or colored for ease of reading).
I'm kindergarten level Javascript... do I use encodeURIComponent() or another global method?
Could I do something like
let TD = fancy.encoded.stringInColumn;
To make this cleaner and format properly? Thanks for any input it's greatly appreciated.
To clarify: this also needs to be displayed in a html page as well as export to Excel.