how to remove file_name from Excel sheet after export excel file using datatables?

datatables excel export customize header
jquery datatable export to excel example
datatables export title
datatables pdf header
datatables export title dynamic
messagetop in datatable
datatables exportoptions header
datatables buttons print title

I have 2 buttons Excel and CSV to export into excel and csv sheets respectively for jquery datatable, Till now our jquery datatable data is getting exported and downloaded into an excel and csv files fine. But my problem here is after export into excel sheet the file name is also inserted into the first row of excel sheet along with datatable data. I want to remove that file name because as I need only the datatable data.

$(document).ready(function () {
  $('#example thead tr:eq(1) th').each( function () {
       var title = $('#example thead tr:eq(0) th').eq( $(this).index() ).text();

       if(title!="Action"){
          $(this).html( '<input type="text" placeholder="Search '+title+'" />' );
           }
         } );

         var table = $('#example').DataTable( {
              dom: 'Bfrtip',
              buttons: [
                {
                    extend: 'excel',
                    title: 'My_Report_'+$('#from_date').val()+'_'+$('#to_date').val()
                },
                {
                    extend: 'csv',
                    title: 'My_Report_'+$('#from_date').val()+'_'+$('#to_date').val() 
                }
              ],
              "bInfo": false,
              fixedHeader: true,
              "iDisplayLength": 100,
          } ); 
});

My html Datatable is:

<table class="table table-hover table-condensed dataTable no-footer table-bordered" id="example" role="grid" >
              <thead>
                <tr>
                   <th>Column1</th>
                   <th>Column2</th>
                   <th>Column3</th>
                   <th>Column4</th>
                   <th>Column5</th>
                   <th>Column6</th>
                   <th>Column7</th>
                   <th>Column8</th>
                   <th>Column8</th>
                   <th>Column10</th>
                </tr>
                </thead>
              <tbody>
                <td>---</td>
                -----------
              </tbody>
            </table>

My Problem is File name as "My_Report_startDate_endDate.xls" is getting inserted into the first row in the exported excel sheet. I want to remove that file name from the excel sheet. CSV file data is getting exported fine. Any help would be appreciated. Thanks.


I had same problem. This is how i solved it:

buttons: [
            {
                extend: 'excel',

 filename:'My_Report_'+$('#from_date').val()+'_'+$('#to_date').val() 
 title:'',
            },
            {
                extend: 'csv',

filename:'My_Report_'+$('#from_date').val()+'_'+$('#to_date').val() 
title:'',
            }
          ],

File name, By default the name of the file created by the excelFlash , csvFlash and pdfFlash button types will This example shows the filename option being set for the excelFlash and pdfFlash buttons. In addition to the above code, the following Javascript library files are loaded for use in this example: HTML 5 data export. File name. By default the name of the file created by the excelFlash, csvFlash and pdfFlash button types will automatically be taken from the document's title element. It is also possible to set the file name to a specific value using the filename option of these three button types. This example shows the filename option being set


Add filename instead of title and set title null

$(document).ready(function () {
  $('#example thead tr:eq(1) th').each( function () {
       var title = $('#example thead tr:eq(0) th').eq( $(this).index() ).text();

       if(title!="Action"){
          $(this).html( '<input type="text" placeholder="Search '+title+'" />' );
           }
         } );

         var table = $('#example').DataTable( {
              dom: 'Bfrtip',
              buttons: [
                {
                    extend: 'excel',
                    filename: 'My_Report_'+$('#from_date').val()+'_'+$('#to_date').val(),
                    title:''
                },
                {
                    extend: 'csv',
                    filename: 'My_Report_'+$('#from_date').val()+'_'+$('#to_date').val(),
                    title:'' 
                }
              ],
              "bInfo": false,
              fixedHeader: true,
              "iDisplayLength": 100,
          } ); 
});

Error when trying to remove title from Excel Export, I saw that this can be removed from the file by setting the title to an empty string. This works for CSV and PDF files, but when I open the Excel  The Cell Value which is used for file name is A1 and the extension is ".xlsx". Steps: 1. Open a new file 2. Press Alt+F11 to open VBA editor 3. In the left navigation window select ThisWorkbook 4. In the editor window enter the code below 5. Close the VBA editor 6. Save the file as Macro Enabled File 7. Test with you inputs Code: Sub


Use 'filename' instead of 'title'

$(document).ready(function () {
  $('#example thead tr:eq(1) th').each( function () {
       var title = $('#example thead tr:eq(0) th').eq( $(this).index() ).text();

       if(title!="Action"){
          $(this).html( '<input type="text" placeholder="Search '+title+'" />' );
           }
         } );

         var table = $('#example').DataTable( {
              dom: 'Bfrtip',
              buttons: [
                {
                    extend: 'excel',
                    filename: 'My_Report_'+$('#from_date').val()+'_'+$('#to_date').val()
                },
                {
                    extend: 'csv',
                    filename: 'My_Report_'+$('#from_date').val()+'_'+$('#to_date').val() 
                }
              ],
              "bInfo": false,
              fixedHeader: true,
              "iDisplayLength": 100,
          } ); 
});

Title means title of the table

excel, By default the name of the file created by the excelHtml5 , csvHtml5 and pdfHtml5 button types will automatically be taken from the document's title element. shows the title option being set for the excelHtml5 and pdfHtml5 buttons. Excel PDF code, the following Javascript library files are loaded for use in this example:. Quickly split multiple worksheets into separate workbook in Excel: In Microsoft Excel, you can save or split a worksheet from one workbook as a new Excel file by copying and pasting this worksheet into a new workbook. It seems troublesome, if you want to split each sheet / worksheet of a large workbook as separate Excel, txt, csv, pdf files.


By setting title to an empty, first row of title in excel sheet will remove

refer following code

 buttons: [{
                extend: 'excel',
                text: '<img src="Content/Images/Excel-Logo.jpg" style="width:50px;height:50px;"/>',
                tag: 'span',
                title: '',
                init: function (api, node, config) {
                    $(node).removeClass('btn btn-secondary buttons-excel buttons-html5')
                },
                exportOptions: {
                    columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
                }
            }],

excelHtml5, In order to operate, this button requires the following: To ensure that all files required for Excel export are included, the DataTables download builder is  I have 2 buttons Excel and CSV to export into excel and csv sheets respectively for jquery datatable, Till now our jquery datatable data is getting exported and downloaded into an excel and csv files fine. But my problem here is after export into excel sheet the file name is also inserted into the first row of excel sheet along with datatable


Export to Excel of DataTable, Data Export Webix Docs, To ensure that all files required for Excel HTML5 export are included, the The API methods used by this button are supported in the following browsers. Save the script and Close the Script Task Editor. Run your SSIS Package. It should load data from Excel Sheets to your Table and also insert Excel file name and sheet name from where the data is loaded. I executed the SSIS Package and here is my output. How to load Excel File Name and Sheet Name with Data to SQL Server Table by using SSIS


Exporting Overview, To export data from DataTable/TreeTable into an Excel document, you need to call provide a custom filename and sheet name; strip HTML tags from the cells row spans from Datatable header and body into export; disable file download in a "title", since numbers are processed first and come in the ascending order. Deleting Excel WorkSheet using C# You can delete any worksheet from Microsoft Excel file. In order to delete a worksheet, you must add a reference to the Microsoft.Office.Interop.Excel assembly, and then you must use classes from that assembly to open a workbook and delete a worksheet.The following program shows how to delete worksheet from an an existing Excel file using C#.


Solved: Export data table to Excel using scripting, In addition to the export format's specific properties, the ExportSettings group FileName—This is helpful when you want to give a predefined name for your file. above RadGrid or when you want to remove/add/replace parts of the content. For more details see the Controls not functional after Export to Excel or Export to​  Press the F5key on the keyboard, if there is no debug close the Visual Basic window and return to Excel. If there is debug, check back your script. Return to Excel and see what happens, if the codes are correct, now the name of each sheet is renamed in accordance with the existing sales name on each sheet. That's it. Hopefully usefull.