Column values appear as Object object in the excel after export

Column values appear as Object object in the excel after export

Learn2excelLearn2excel Posts: 33Questions: 5Answers: 1

Hello All,

I am new to development. I am using the below piece of code for export to excel from datatable. The export works fine for all the other columns except the last i.e. the 6th column where the values appear as [object Object] in the exported file. Can someone let me know what additional piece of function or code is needed here so that only the required property from the column is exported so that the value is displayed correctly. Also, i would like to see the column header and values aligned to the left for this column as well as the 5th column.

buttons: [
{
extend: 'excelHtml5',
text: '<i class="btn_excel"></i> <span class=btn_text_align>Export to Excel</span>',
className: 'btn-sm btn_size',
titleAttr: 'Export to Excel',
exportOptions: { columns: [1, 2, 3, 4, 5, 6], orthogonal: null},
},

Thank you in advance.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin
    Answer ✓

    orthogonal: null

    is the issue. That is instructing the software to use the whole data object for the row as the data source, hence why you are getting [object Object].

    Remove that and I'd expect it to work.

    If it doesn't please link to a page showing the issue so I can take a look into it.

    Thanks,
    Allan

  • Learn2excelLearn2excel Posts: 33Questions: 5Answers: 1

    Hi Allan,

    Thank you for your suggestion.

    Yes, it worked. :)

Sign In or Register to comment.