Hey! Are you staying home? We are too. Still, we prepared a new product release for you!🚀

We hope it comes in handy for your business especially these days. Stay safe & pivot on!

How to get report table HTML content?

Answered

Hi guys,
The exportTo (‘html’, options) function generates a table in html and saves it to a file for download. Is there any function that just returns that html content in the code (without necessarily forcing the download)? For example:

let htmlTable = generateTableHtml(options);

6 answers

WebDataRocks Team WebDataRocks November 4, 2019

Hello, Gleyton,
 
Thank you for your question.
 
You can return the desired HTML content using the following construction:

function htmlToValue() {
webdatarocks.exportTo("html", null, res => { console.log(res) });
}

 
Find out an example by following the link: https://codepen.io/webdatarocks/pen/JjjpOyb.
 
For now, it’s impossible to call the exportTo method without downloading the file. We recommend you checking on Flexmonster which is a premium pivot table component developed by the same team. The exportTo method without necessarily forcing the download is available in Flexmonster: https://www.flexmonster.com/api/exportto/.
 
Kind regards,
WebDataRocks Team

Cihan June 5, 2020

Hello,
I have this problem. I just want the HTML content, but the exportTo method downloads as an html file.

Gleyton June 8, 2020

Unfortunately, still it’s impossible to call the exportTo method without downloading the file.

Hugo Martinez June 10, 2020

Hi,
 
It is possible to get the HTML content by exporting the report to a server. This way it won’t be downloaded as an HTML file. 
For example, by setting the destinationType export option to "server" and specifying the url property, the report will be sent as a POST parameter to the specified URL and the HTML content will be available in the callback:
 

webdatarocks.exportTo(
"html",
{
destinationType: "server",
url: "URL to server script saving the file"
},
res => {
console.log(res.data); //the HTML content
}
);

 
Further details can be found in this guide: https://www.webdatarocks.com/doc/exportto/ 
 
Hope this helps. 

Gleyton June 10, 2020

The main objective in obtaining the html in our case is to use the default browser print with this content. The standard print of webdatarocks when it has many columns is difficult to read. Take the test: at https://www.webdatarocks.com/demos/javascript-pivot-table-demo/ check the option flat form and add all columns. Now click on “export-> print”. Compare the result with the printing of the exported html file in the option “export-> html” via browser. This will, in my opinion, look much better.

Cihan June 10, 2020

Hi, first of all my question answering for thank you.
I understood what u said, but I use Angular 7 and unfortunately I don’t use ssr. What other solution can I come up with?
 
Thank u for all answers,
good workings ✋

Please login or Register to Submit Answer