Issue with the excel file opening.
Issue with the excel file opening.
srtota
Posts: 5Questions: 1Answers: 0
I have exported the excel file from datatable. When i try to open the file it is giving warning like " The file format and extension of file don't match . The file could be corrupted of unsafe.Unless you trust its source, don't open it. Do you want to open it anyway ?".
please suggest how to avoid this warning.
This discussion has been closed.
Replies
Are you trying to customize the data export? If so then the customization code is setting something improperly.
Please post your code for the Excel export.
Kevin
This is the code to export -
$("#mysowDTTableForExcel").table2excel({
Data table code :
mysowDTExcelTable=$('#mysowDTTableForExcel').dataTable({
https://github.com/rainabba/jquery-table2excel Look at their disclaimer.
It says you will probably get that warning.
Any particular reason you choose that one over the one that comes with DataTables?
If i use the one comes with data table..
1.i will get current page details . but we have pagination.
2. In table data we have column values as trimmed( like value...), but while export the complete value should go.
3. we are using separate icon for export functionality, if i use data table it will show the button.
As Bindrid mentioned table2excel is not a Datatables product.
As long as you are not using server side processing (which it doesn't look like you are by the code) then you will, by default, get all the data loaded on the client side.
With client side processing you should be able to do this also.
It is possible to call the export code from Javascript, see this thread for details:
https://datatables.net/forums/discussion/32764
Unless you are using server side processing you might find it easier to get the functionality needed from the Datatables export buttons than to troubleshoot why table2excel is writing a corrupt Excel file.
Kevin
Thanks for the Reply.
I tried this , but got "object doesn't support property or method button". Any input on this.
var tablex = $('#mysowDTTableForExcel').DataTable();
Did you load the appropriate buttons libraries?
If not the download builder might be the easiest way to get them:
https://datatables.net/download/index
Kevin