Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 突出显示包含单词的表格行并导出到excel_Javascript_Html_Jquery - Fatal编程技术网

Javascript 突出显示包含单词的表格行并导出到excel

Javascript 突出显示包含单词的表格行并导出到excel,javascript,html,jquery,Javascript,Html,Jquery,我使用这个jQuery脚本突出显示html表中的行。它工作得很好,但当我在excel中导出该表时,excel的所有行都得到了该格式,甚至是表外的部分。我还粘贴了导出脚本 var tableToExcel=(函数(){ var uri='data:application/vnd.ms excel;base64,' ,template='您不想在excel中格式化吗?是的,我想,请查看附加的屏幕截图。突出显示在表外,看起来很糟糕。 $("#X tr:contains(' Total')&

我使用这个jQuery脚本突出显示html表中的行。它工作得很好,但当我在excel中导出该表时,excel的所有行都得到了该格式,甚至是表外的部分。我还粘贴了导出脚本


var tableToExcel=(函数(){
var uri='data:application/vnd.ms excel;base64,'

,template='您不想在excel中格式化吗?是的,我想,请查看附加的屏幕截图。突出显示在表外,看起来很糟糕。
$("#X tr:contains(' Total')").css("background-color", "Gainsboro");
$("#X tr:contains(' Total')").css("font-weight", "bold");
$("#X tr:contains('Grand Total')").css("background-color", "yellow");
$("#X tr:contains('Grand Total')").css("font-weight", "bold");
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
  <script type="text/javascript">
    var tableToExcel = (function () {
    var uri = 'data:application/vnd.ms-excel;base64,'
        , template = '<html xmlns: <head><!--[if gte mso 9]><xml><x: <x: <x: <x: {worksheet}</x: <x: <x:DisplayGridlines/></x:WorksheetOptions></x: ExcelWorksheet ></x: ExcelWorksheets ></x: ExcelWorkbook ></xml >< ![endif]-- ></head > <body><table>{table}</table></body></html > '
  , base64 = function (s) { return window.btoa(unescape(encodeURIComponent(s))) }
  , format = function (s, c) { return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; }) }
return function (table, name) {
  if (!table.nodeType) table = document.getElementById(table)
  var ctx = { worksheet: name || 'Worksheet', table: table.innerHTML }
  window.location.href = uri + base64(format(template, ctx))
}
})();
</script>