Basic initialization
The HTML5 export buttons plug-in for Buttons provides four export buttons: copyHtml5- copy to clipboard; csvHtml5- save to CSV file; excelHtml5- save to XLSX file (requires JSZip); pdfHtml5- save to PDF file (requires PDFMake). This example demonstrates these four button types with their default options. Please note that these button types may also use a Flash fallback for older browsers (IE9-).
PDF with image
The pdfHtml5button will generate a document description object which you then have the option to customise through the button's customizeoption. This parameter should be given as a function and is given a single parameter - the object that the button as created with the table already populated. That object can then be modified - please refer to the PDFMaker documentationfor full details of how the PDF can be customised.
Column selectors
All of the data export buttons have a exportOptionsoption which can be used to specify information about what data should be exported and how. In this example the copy button will export column index 0 and all visible columns, the Excel button will export only the visible columns and the PDF button will export column indexes 0, 1, 2 and 5 only. Column visibility controls are also included so you can change the columns easily.
Tab separated values
The copyHtml5and csvHtml5buttons have the option to specify the character that separates the values between fields. By default this is a tabcharacter for the copybutton, but the CommaSeparated Values button uses a comma. In this example the exported file is a tab separated values file. The file extension has also been set to reflect this, although that is optional as most spreadsheet applications will read TSV files without issue.