Skip to content

Commit

Permalink
Merge #3736
Browse files Browse the repository at this point in the history
3736: fix: parse <head> contents from XLS renderer r=jniles a=jniles

This removes are links from the <head> so they don't give us errors when we open the report in XLS.

Co-authored-by: Jonathan Niles <jonathanwniles@gmail.com>
  • Loading branch information
bors[bot] and jniles committed Jun 7, 2019
2 parents 30ea36d + f15481a commit f95255b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions server/lib/renderers/xls.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@ exports.render = render;
exports.extension = '.xls';
exports.headers = headers;


async function render(data, template, options) {
const htmlString = juice(await html.render(data, template, options));
return Buffer.from(htmlString, 'utf-8');

// NOTE(@jniles)
// This code replaces the <head></head> contents to avoid CSS <link> errors when
// opening in MS Excel.
const start = htmlString.substring(0, htmlString.search('<head>'));
const end = htmlString.substring(htmlString.search('</head>') + 7);

const tmpl = `${start}${end}`;

return Buffer.from(tmpl, 'utf-8');
}

0 comments on commit f95255b

Please sign in to comment.