From f15481a327941afd7032d222f33694b7d25e51c2 Mon Sep 17 00:00:00 2001 From: Jonathan Niles Date: Sat, 18 May 2019 17:40:39 +0100 Subject: [PATCH] fix: parse contents from XLS renderer This removes are links from the so they don't give us errors when we open the report in XLS. --- server/lib/renderers/xls.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/server/lib/renderers/xls.js b/server/lib/renderers/xls.js index 0c5d8e58fb..15c2323b5d 100644 --- a/server/lib/renderers/xls.js +++ b/server/lib/renderers/xls.js @@ -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 contents to avoid CSS errors when + // opening in MS Excel. + const start = htmlString.substring(0, htmlString.search('')); + const end = htmlString.substring(htmlString.search('') + 7); + + const tmpl = `${start}${end}`; + + return Buffer.from(tmpl, 'utf-8'); }