导出到 Excel - 文本之间需要 Space

Export to Excel - Need Space in Between Text

我有一个 HTML table 和一个导出到 Excel 的按钮。导出效果很好——来自 table 的每个数据都被导入 Excel,但是在 Excel 中,当我使用 Chrome 时,文本之间没有 space或 Firefox 查看页面并导出!

这是HTML代码

<table>
<tr><td>Job Description</td></tr>
<tr><td><xsl:value-of select="job_desc" /></td></tr>
</table>

这是它在浏览器中的样子

Job Description
The process of writing a job description requires having a clear...

下面是导出后在 Excel 中的样子

JobDescription
Theprocessofwritingajobdescriptionrequireshavingaclear...

然后,我尝试在我的硬代码中得到一个space:Job&#160;Description。它有效,让我有一个 space: Job Description

问题是:如何获取动态数据的space?

这与我用来将数据导出到 Excel 的 Jquery 语法有关吗?

要导出的 JS

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

您可以尝试使用 pre 标签包装您的 table - 保留格式:

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

我刚换了

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

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

而且我在单词之间有空格。