Add company logo to excel export

Add company logo to excel export

csaba911csaba911 Posts: 17Questions: 4Answers: 0

Wanted to insert company logo (img) above the header with custom text pulled from table row1 cell 1&2
2nd day searching for a working example where I could source some code what usable, found a few but either not working and no fix provided or its too old and closed thread.
I don't have a test case, not sure where to start, see no point to provide gibberish as example.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,141Questions: 26Answers: 4,735

    See Allan's second response in this thread. Its not simple config option. It will take investing the Office Open XML docs to learn how to format the cell. See the execlHTML5 docs for more details about customizing the Excel export.

    Kevin

  • csaba911csaba911 Posts: 17Questions: 4Answers: 0

    hmm, not much for jumpstart, Allan already stated "isn't something I've attempted myself and I suspect it would be relatively complicated", this is why looking for a simple working example..

  • csaba911csaba911 Posts: 17Questions: 4Answers: 0
  • csaba911csaba911 Posts: 17Questions: 4Answers: 0

    No matter what I do, nothing but the rows and cell being exported, getting pretty frustrated with it
    http://live.datatables.net/gawofiku/3/edit

  • colincolin Posts: 15,112Questions: 1Answers: 2,583
    edited March 2022

    Try this SO thread, there seems to be a working example there. Bear in mind Allan said it would be relatively complicated, so it's not going to be a simple thing!!

    Colin

  • kthorngrenkthorngren Posts: 20,141Questions: 26Answers: 4,735
    Answer ✓

    This tutorial isn't specific to Datatables but it will show the types of things that need to happen to place an image in an Excel Speadsheet:
    http://www.ericwhite.com/blog/precisely-placing-images-in-an-open-xml-spreadsheet/

    The complexity of this process is probably why you haven't found any Datatables examples.

    You might be better off finding a different JS library that provides the capability to insert images. You can use a Custom Button like this example then get the row data using rows().data() along with toArray() which you might be able to pass into the library.

    Kevin

  • csaba911csaba911 Posts: 17Questions: 4Answers: 0

    Thanks colin and kthorngren

  • csaba911csaba911 Posts: 17Questions: 4Answers: 0

    Final result satisfactory, ended up using XlsxWriter and generate actual Excel file in django class with plenty of customization (adding excel formula), still used datatables to display it in the browser but added button with JS to call url what return excel file as attachment. Luckily context['rows'] contain the whole table so don't need to generate (168second) table again.

Sign In or Register to comment.