How to export data to csv,pdf from Database like postgresql?

How to export data to csv,pdf from Database like postgresql?

suryaparthipansuryaparthipan Posts: 1Questions: 1Answers: 0

i export option in the datatables take data from the UI i want to take the datas from the postgres database to export to pdf,csv etc.

Answers

  • rf1234rf1234 Posts: 2,808Questions: 85Answers: 406
    edited December 2018

    Sounds like you want to do this at the back end from the database. That's not something that Data Tables supports unless you send all your data to the front end first.

    I personally use PHP Spreadsheet in combination with mpdf to export data to xlsx and pdf at the back end from an SQL database. Just google it and you should find something.

    Exporting data at the back end has numerous advantages: You can do all kinds of things including the integration of logos, complex Excel charts, buttons etc. PHP Spreadsheet generates the XML that Excel expects and it has a printer that also prints pdfs based on plugins like TCPDF, mpdf and dompdf.

    I also use Data Tables in this context: If you look at the upload examples of Data Tables and how this is being done with the file table etc I do the same at the back end: Save the file with PHP Spreadsheet, insert web and server paths into the file table with my own SQL, and subsequently display download links in a data table so that the user can download the generated files straight away. The user can also upload her own files, and the links will be displayed jointly with the generated files.

    I attached an example workbook generated with PHP Spreadsheet and a screenshot of how this integrates with data tables at the front end.

    In column "Report / Documentation" you can see the download link to the generated report. Using Editor you can also upload additional proprietary documents and they will be displayed in that column, too.

This discussion has been closed.