Add company logo to excel export
Add company logo to excel export
csaba911
Posts: 17Questions: 4Answers: 0
in DataTables
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
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
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..
live.datatables.net/gawofiku/2/edit
not much progress
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
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
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 withtoArray()
which you might be able to pass into the library.Kevin
Thanks colin and kthorngren
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.