Je dois supprimer la class "toucher" lors de la livraison de données à une feuille Excel

Voici mon problème, toutes datatables à l'intérieur de la touche qui est une boîte de sélection sont en cours d'implémentation dans Excel et la création d'espaces blancs.

entrez la description de l'image ici

<tr class="proj_rec" data-id="4"> <td class="proj_id"> 4 </td> <td> Music in the stores </td> <td class="edit"> <select class="touch" style="display: none;"> <option value="13">Bloopers</option><option value="1">Customer Service</option><option value="2">DC</option><option value="3">Ecommerce</option><option value="4">Finance/Accounting</option><option value="5">Human Resources</option><option value="6">Inbound Logistics</option><option value="7">Information Systems</option><option value="14">Management</option><option value="8">Marketing</option><option value="9">Merchandising</option><option value="10">Property</option><option value="11">Rebuying</option><option value="12">Sales</option> </select> <span class="look"> Sales </span> </td> <td class="edit"> <select class="touch" style="display: none;"> <option value="1">As is review</option><option value="2">Complete</option><option value="3">Development</option><option value="4">Implemented</option><option value="5">Not started</option><option value="6">To be design</option> </select> <span class="look"> As is review </span> </td> <td class="edit"> <select class="touch" style="display: none;"> <option value="1"> Objective</option><option value="2"> People</option><option value="3"> Process</option><option value="4"> Systems</option> </select> <span class="look"> Process </span> </td> 

J'utilise ce code pour créer les classs td

 function back_to_look() { $('td.editing ,td.edit.new').each(function() { $(this).children('.look').show(); $(this).children('.touch').hide(); if (!$(this).hasClass('edit')) { $(this).addClass('edit'); } if ($(this).hasClass('editing')) { $(this).removeClass('editing'); } }); } function back_to_look() { $('td.editing ,td.edit.new').each(function() { $(this).children('.look').show(); $(this).children('.touch').hide(); if (!$(this).hasClass('edit')) { $(this).addClass('edit'); } if ($(this).hasClass('editing')) { $(this).removeClass('editing'); } }); } function back_to_look() { $('td.editing ,td.edit.new').each(function() { $(this).children('.look').show(); $(this).children('.touch').hide(); if (!$(this).hasClass('edit')) { $(this).addClass('edit'); } if ($(this).hasClass('editing')) { $(this).removeClass('editing'); } }); 

}

Voici ce que j'utilise pour passer mes données dans Excel:

 <td><input type="button" id="dlink" onclick="tableToExcel('project_table', 'W3C Example Table')" value="Export to Excel"></td> <a id="dlink" style="display:none;"></a> var tableToExcel = (function () { var uri = 'data:application/vnd.ms-excel;base64,' , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><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, filename) { if (!table.nodeType) table = document.getElementById(table) var ctx = { worksheet: name || 'Worksheet', table: table.innerHTML } document.getElementById("dlink").href = uri + base64(format(template, ctx)); document.getElementById("dlink").download = filename; document.getElementById("dlink").click(); } })() } <td><input type="button" id="dlink" onclick="tableToExcel('project_table', 'W3C Example Table')" value="Export to Excel"></td> <a id="dlink" style="display:none;"></a> var tableToExcel = (function () { var uri = 'data:application/vnd.ms-excel;base64,' , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><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, filename) { if (!table.nodeType) table = document.getElementById(table) var ctx = { worksheet: name || 'Worksheet', table: table.innerHTML } document.getElementById("dlink").href = uri + base64(format(template, ctx)); document.getElementById("dlink").download = filename; document.getElementById("dlink").click(); } })() 

  var tableToExcel = (function () { $('#clonedtable .touch').each(function(){ $(this).parent().prepend($(this).val()); //if you want to keep the values. }); $('#clonedtable .touch').remove(); var uri = 'data:application/vnd.ms-excel;base64,' , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><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, filename) { if (!table.nodeType) table = document.getElementById(table) var ctx = { worksheet: name || 'Worksheet', table: table.innerHTML } document.getElementById("dlink").href = uri + base64(format(template, ctx)); document.getElementById("dlink").download = filename; document.getElementById("dlink").click(); $('#clonedtable').remove(); } })() });  var tableToExcel = (function () { $('#clonedtable .touch').each(function(){ $(this).parent().prepend($(this).val()); //if you want to keep the values. }); $('#clonedtable .touch').remove(); var uri = 'data:application/vnd.ms-excel;base64,' , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><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, filename) { if (!table.nodeType) table = document.getElementById(table) var ctx = { worksheet: name || 'Worksheet', table: table.innerHTML } document.getElementById("dlink").href = uri + base64(format(template, ctx)); document.getElementById("dlink").download = filename; document.getElementById("dlink").click(); $('#clonedtable').remove(); } })() }  var tableToExcel = (function () { $('#clonedtable .touch').each(function(){ $(this).parent().prepend($(this).val()); //if you want to keep the values. }); $('#clonedtable .touch').remove(); var uri = 'data:application/vnd.ms-excel;base64,' , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><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, filename) { if (!table.nodeType) table = document.getElementById(table) var ctx = { worksheet: name || 'Worksheet', table: table.innerHTML } document.getElementById("dlink").href = uri + base64(format(template, ctx)); document.getElementById("dlink").download = filename; document.getElementById("dlink").click(); $('#clonedtable').remove(); } })() 

Vous pouvez saisir les valeurs et les terminer dans les lignes ou les supprimer complètement avant de convertir le tableau en excel.

Si vous souhaitez garder votre table intacte, je reorderais de cloner le tableau, puis de supprimer le file Excel de la table clonée et de le supprimer ensuite.

Cela ressemblerait à quelque chose comme ça

 return function (table, name, filename) { $('#clonedtable .touch').each(function(){ $(this).parent().prepend($(this).val()); //if you want to keep the values. }); $('#clonedtable .touch').remove(); .... //create the excel of the cloned table $('#clonedtable').remove(); } })() }); return function (table, name, filename) { $('#clonedtable .touch').each(function(){ $(this).parent().prepend($(this).val()); //if you want to keep the values. }); $('#clonedtable .touch').remove(); .... //create the excel of the cloned table $('#clonedtable').remove(); } })() } return function (table, name, filename) { $('#clonedtable .touch').each(function(){ $(this).parent().prepend($(this).val()); //if you want to keep the values. }); $('#clonedtable .touch').remove(); .... //create the excel of the cloned table $('#clonedtable').remove(); } })() 

Mise à jour Essayez ceci à la place.

 var tableToExcel = (function () { .... return function (table, name, filename) { $('#'+table+' .touch').each(function(){ $(this).parent().prepend($(this).val()); //if you want to keep the values. }); $('#'+table+' .touch').remove(); .... //create the excel of the cloned table $('#'+table).remove(); } })() .... var tableToExcel = (function () { .... return function (table, name, filename) { $('#'+table+' .touch').each(function(){ $(this).parent().prepend($(this).val()); //if you want to keep the values. }); $('#'+table+' .touch').remove(); .... //create the excel of the cloned table $('#'+table).remove(); } })() }); var tableToExcel = (function () { .... return function (table, name, filename) { $('#'+table+' .touch').each(function(){ $(this).parent().prepend($(this).val()); //if you want to keep the values. }); $('#'+table+' .touch').remove(); .... //create the excel of the cloned table $('#'+table).remove(); } })() } var tableToExcel = (function () { .... return function (table, name, filename) { $('#'+table+' .touch').each(function(){ $(this).parent().prepend($(this).val()); //if you want to keep the values. }); $('#'+table+' .touch').remove(); .... //create the excel of the cloned table $('#'+table).remove(); } })()