我有一个导出到excel的数据表,它正在工作,但是我想在悬停在一些单元格上添加注释。我面临的问题是,当它被导出到excel时,悬停文本鞋起来了,我不想要它。
这是控制我的悬停隐藏注释的样式表。
<style>
.CellWithComment{
position:relative;
}
.CellComment{
display:none;
position:absolute;
z-index:100;
border:1px;
background-color:white;
border-style:solid;
border-width:1px;
border-color:red;
padding:3px;
color:red;
top:20px;
left:20px;
}
.CellWithComment:hover span.CellComment{
display:block;
}
</style>下面是启动datatable的脚本。
<script>
var instances = $('#instances').DataTable({
columnDefs: [{
orderable: false,
className: 'td-body-center',
targets: 0
}],
select: {
style: 'os',
selector: 'td:first-child'
},
dom: 'Bfrtip',
buttons: ['excelHtml5'],
order: [[1, 'asc']]
});
</script>这是表格的一部分,显示了我是如何写评论的。
<tr>
<td><label for="running"> running</label></td>
<td><label for="Linux"> Linux</label></td>
<td class="CellWithComment"><label for="True"> True</label>
<span class="CellComment">Here is a comment</span>
</td>
<td class="CellWithComment"><label for="True"> True</label>
<span class="CellComment">Here is a comment</span>
</td>
</tr>"Here is a comment“是隐藏的,当你将鼠标悬停在web表格上时,它会显示出来,但是一旦你把它导出到excel中,下面的单元格就会显示出来……
True Here is a comment有没有办法防止注释被导出到excel中?
谢谢!
发布于 2021-01-14 03:54:36
我发现了如何解决这个问题:
我用下面的代码修改了datatable的创建:
var instances = $('#instances').DataTable({
columnDefs: [{
orderable: false,
className: 'td-body-center',
targets: 0
}],
select: {
style: 'os',
selector: 'td:first-child'
},
dom: 'Bfrtip',
buttons: [
{
extend: 'excelHtml5',
exportOptions: {
format: {
body: function ( data, row, column, node ) {
return data = node.innerText;
}
}
}
}
],
order: [[1, 'asc']]
});https://stackoverflow.com/questions/65708078
复制相似问题