Skip to content Skip to sidebar Skip to footer

Export To Excel - Need Space In Between Text

I have a HTML table and a button to export into Excel. The exporting works well - every data from the table is brought into Excel, but in Excel, there is no space in between text

Solution 1:

I just changed

$(".exportExcel").click(function(e) {
                    e.stopPropagation();
                    var table = $("." + $(this).data('target'));
                    window.open('data:application/vnd.ms-excel,' + $(table).html());
                    e.preventDefault();
                    });

to

$(".exportExcel").click(function(e) {
                    e.stopPropagation();
                    var table = $("." + $(this).data('target'));
                    window.open('data:application/vnd.ms-excel,' +  encodeURIComponent(table[0].outerHTML));
                    e.preventDefault();
                    });

And I get spaces in between words.

Solution 2:

You could try wrapping your table with the pre tag - preserves formatting:

<pre><table><tr><td>Job Description</td></tr><tr><td><xsl:value-ofselect="job_desc" /></td></tr></table></pre>

Post a Comment for "Export To Excel - Need Space In Between Text"