I have a Japanese characters in my table. If I use excel button for exporting, it works fine but when I do for CSV. The data or the texts is not correct anymore. Do anyone know how to fix this? Thanks.
Here is my table
And for exporting to CSV and excel
I just used the simple way of creating the buttons for export
buttons: [
{
extend: 'excel',
text: 'Export to Excel',
className: 'btn btn-default',
exportOptions: {
columns: ':not(.notexport)'
},},
{
extend: 'csv',
text: 'Export to CSV',
className: 'btn btn-default',
exportOptions: {
columns: ':not(.notexport)'
},}
],
Related
i am trying to export data from a datatable to an excel file.
But everytime i use the excel button it changes the format of my numbers.
For example a 0,023 is copied to excel as a 23.
Is there a way to use the excel export button so that excel isnt changing the format?
The other things is that i use the datatable on different data from a DB. So the column isnt always the same which has to be formated. Even the User can select which column should be exported. So the Format sould be used.
So possible Datatable could look like:
A
B
C
abc
1
1,2
A
B
C
abc
1,2
dcf
Thx in advance.
<script type="text/javascript" language="javascript">
$(document).ready(function() {
var table = $('#tbl').DataTable( {
dom: "lfBptrip",
select: {
style: 'multi'
}
,
columnDefs: [
{
targets: 0,
className: 'noVis'
}
],
language: {
searchBuilder: {
button: 'Filter',
}
},
buttons:[
'searchBuilder',
{
extend: 'colvis',
columns: ':gt(0)',
collectionLayout: 'fixed columns',
text: 'Spaltenauswahl',
postfixButtons: [{
extend: 'colvisRestore',
text: 'Show All',
}, {
extend: 'colvisGroup',
text: 'Hide All',
hide: ':visible'
},
]
},
{
extend: 'copy',
text: 'Zwischenablage',
exportOptions: {
columns: ':visible'
}
},
{
extend: 'excelHtml5',
text: 'Excel',
exportOptions: {
columns: ':visible'
}
},
{
extend: 'pdf',
pageSize: 'LEGAL',
orientation: 'landscape',
text: 'PDF',
exportOptions: {
columns: ':visible'
}
}
],
colReorder: true,
scrollX: true,
});
});
</script>
$(document).ready(function () {
$.fn.dataTable.moment(lang == "en" ? 'DD/MM/YYYY' : 'DD.MM.YYYY');
categories_table = $('.datatable').DataTable({
order: [[1, 'desc']],
language: datatable_lang,
dom: 'Bfrtip',
buttons: [
{
extend: 'collection',
autoClose: 'true',
text: '<i class="download icon">',
tag: 'span',
buttons: ['csv', 'print', 'excel']
}
]
});
});
This gives nice looking format for price, like "8,00" as example. But when I export that to excel, I get "800" as value. And if number is "18,00", excel will show it as "1,800".
Is there any way to sort this out and have same values in excel as well? I try a lot thing but I didnt do it.
Sorry for my English
Thanks
I have excel button of data table and I want to change name of that button.
I am trying like this
$(document).ready(function() {
$('#loading_sheet_table').DataTable({
"paging": false,
dom: 'Bfrtip',
buttons: [
{
extend: 'excel',
name: 'export to excel'
}
]
});
});
But name not change and I want to add icon after name.
<i class="fa fa-file-excel-o" aria-hidden="true"></i>
You can do this to get the desired thing
$(document).ready(function() {
$('#loading_sheet_table').DataTable({
"paging": false,
dom: 'Bfrtip',
buttons: [
{
extend: 'excel',
text: 'Export to excel',
className: 'btn btn-default btn-xs'
}
]
});
});
I hope you can style your icon using the class.
I am trying to enable export buttons for a jQuery data table but the buttons don't get displayed.
$('#tblServicesReport').DataTable({
dom: 'Bfrtip',
buttons: [ 'copy', 'excel', 'pdf' ]
});
Datatables version is 1.10.15
Make sure that you integrate the buttons javascript library https://cdn.datatables.net/buttons/1.5.1/js/dataTables.buttons.min.js
Try this, ensure to load all necessary min files.
$(document).ready(function() {
$('#example').DataTable( {
dom: 'Bfrtip',
columns: [
{ data: 'name' },
{ data: 'surname' },
{ data: 'position' },
{ data: 'office' },
{ data: 'salary' }
],
buttons: [
{
extend: 'copyHtml5',
exportOptions: { orthogonal: 'export' }
},
{
extend: 'excelHtml5',
exportOptions: { orthogonal: 'export' }
},
{
extend: 'pdfHtml5',
exportOptions: { orthogonal: 'export' }
}
]
} );
} );
Demo - https://jsfiddle.net/4tuupc5f/6/
Ensure to load all required files
https://code.jquery.com/jquery-1.12.4.js
https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js
https://cdn.datatables.net/buttons/1.5.1/js/dataTables.buttons.min.js
https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js
https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js
https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js
https://cdn.datatables.net/buttons/1.5.1/js/buttons.html5.min.js
CSS files
https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css
https://cdn.datatables.net/buttons/1.5.1/css/buttons.dataTables.min.css
I'm trying to dynamically change the export title for datatable file export. I found a solution including AngularJS which I'm not going to be able to use. Is there a solution just using jquery?
Here is where I initialize the buttons:
var oTable = $("#standards").DataTable({
dom: 'lBfrtip',
buttons: [
{
extend: 'csvHtml5',
title: titleFinal,
exportOptions: {
columns: ':visible'
}
},
{
extend: 'excelHtml5',
title: titleFinal,
exportOptions: {
columns: ':visible'
}
}
],
I have a function makeTitle that returns a string built from the input string. Here is where I try to change the title after clicking a link.
$('ul').on('click', 'a', function () {
titleFinal = makeTitle('XYZ Standards Due for Testing, ');
oTable.buttons = [
{
extend: 'csvHtml5',
title: titleFinal
},
{
extend: 'excelHtml5',
title: titleFinal
}
];
oTable
.search('XYZ')
.draw();