Export Image in Printing

Export Image in Printing

chael711chael711 Posts: 15Questions: 7Answers: 0

Image cant be exported in Excel and CSV?
Is this possible?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin

    Buttons will strip HTML from the export by default. You can stop it doing that using the stripHtml option of the buttons.exportData() method (which for the print button you can control using the exportOptions parameter).

    Allan

  • chael711chael711 Posts: 15Questions: 7Answers: 0

    Printing using print button works fine , but when i export to csv or excel, images are missing

  • F12MagicF12Magic Posts: 109Questions: 0Answers: 28
    Answer ✓

    CSV will never support images because it's a plain text file. Unless you mean you want the url to your image as text in the csv. With the standard excel export it isn't possible either to display the image. It would require major customizations.

    In case you would like the links( html ) in the exported files, use something like below to initialize your datatable:

    $('#myTable').DataTable(
        buttons: [
            {
                extend: 'csvHtml5',
                text: 'CSV',
                exportOptions: {
                    stripHtml: false
                }
            },
            {
                extend: 'excelHtml5',
                text: 'Excel',
                exportOptions: {
                    stripHtml: false
                }
            }
        ]
    );
    
  • chael711chael711 Posts: 15Questions: 7Answers: 0

    Is there any possible way to do this? export in excel?

  • F12MagicF12Magic Posts: 109Questions: 0Answers: 28

    I haven't tried it yet myself. But it should be possible. But would require a lot of googling. :/

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin

    Yes, it would indeed be possible since the file being created is a true xlsx file. However, it isn't something I've attempted myself and I suspect it would be relatively complicated. The first set would be to read through the Open Spreadsheet specification to understand how images should be embedded into such a file. You could also create an XLSX file and inspect its raw XML and file structure to understand how Excel itself does it.

    Allan

  • DeFKnoLDeFKnoL Posts: 4Questions: 1Answers: 0

    I think that what would be really great is if the export algorithm encountered an image, that it would use the ALT attribute for the image tag.

This discussion has been closed.