Author Topic: exportData - Excel - rendering HTML text  (Read 690 times)

Webauthor

  • Pro OEM
  • Jr. Member
  • *
  • Posts: 51
    • View Profile
exportData - Excel - rendering HTML text
« on: March 09, 2022, 03:46:20 am »
Hi, I have an issue where a column with HTML renders just fine in the grid, but when exporting to excel, even with render:true, it only shows the HTML tags.  I took one of your demo examples and created a fiddle to show the behavior:

https://jsfiddle.net/webauthor/c30seLq8/3/

In the dataModel for company, I have one entry with a <ul> list.  It renders correctly in the grid, but not when exported via Excel.  I've tried playing with various options like render:true/false, exportRender:true/false on the column, but none worked.

Can you please help me export this while retaining the HTML - or if this is not possible, is there a way to strip the HTML tags before export?

Thank you

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: exportData - Excel - rendering HTML text
« Reply #1 on: March 09, 2022, 04:42:25 pm »
Html tags can't be meaningfully rendered in Excel.

They can be removed from intermediate js workbook before exporting it to Excel.

Code: [Select]
pq.excel.eachCell(w.sheets, function(cell){
                      var val = cell.value;
                        if(typeof val == "string" && val.indexOf("<") != -1){
                            var $p = $("<p>").html(val);
                            cell.value = $p.text();
                        }
            })   

https://jsfiddle.net/2rcL9jp5/

Webauthor

  • Pro OEM
  • Jr. Member
  • *
  • Posts: 51
    • View Profile
Re: exportData - Excel - rendering HTML text
« Reply #2 on: March 09, 2022, 05:50:46 pm »
Thank you very much.  This worked perfectly.