how to reverse excel/pdf columns order to rtl?
how to reverse excel/pdf columns order to rtl?
mostafashaban
Posts: 11Questions: 2Answers: 0
i'm trying to export data in excel or pdf , it's already rtl on the page but when i export it ,columns reverse order to ltr.
i tried to use this option in the button object but didn't work:
exportOptions: {
columns: ':not(.select-checkbox)',
modifier: { order: 'current' },
order: 'asc',
}
exportOptions: {
columns: ':not(.select-checkbox)',
modifier: { order: 'index' },
order: 'desc',
}
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
This thread should help, it's asking the same thing.
Cheers,
Colin
thanks for the answer, i already have arabic font, but the words are reversed.
by taking a look i found that pdfmake doesn't support rtl, and i didn't get the idea of convert checkbox example.
so any other recommendation?
Did you read that thread? There's a recommendation in my last comment.
Colin
yes, i read it but i didn't get where to put the reverse function in my code, only i can put orthogonal: "myExport" to exportOptions .
here is the pdf button code
{
extend: 'pdfHtml5',
text: 'PDF',
customize: function (doc) {
doc.defaultStyle =
{
font: 'Cairo'
};
},
titleAttr: 'Generate PDF',
className: 'btn-outline-danger btn-sm ',
exportOptions: {
columns: ':not(.select-checkbox)',
modifier: { order: 'index' }
},
}
my table dir="rtl", but pdf doesn't read this, is there any property to change columns order?
This here is an implementation of my last comment in that thread - it's flipping the strings. You'll need to do something like that.
Colin
it's working , thank you so much you are a great person thanks for your patient.
just on more thing i want to do, i want to reverse all table's columns order in the pdf .. is that possible in the same way?
Yep, change
columnDefs.targets
to be_all
,Colin
sorry, maybe i couldn't explain the problem well, what i want is reverse columns sorting, so if i have name / age / office, i want it to be office / age / name..
also in the implementation above the function doesn't effects the table head cells.
also changing columnDefs.targets to be _all , gives unexpected output , it reverse html elements also
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
live.datatables.net/himufifu/1/edit
here i give body element dir="rtl" , but when i export it to pdf table columns reverse back to ltr
Unfortunately the pdf export does not currently consider rtl text. I'm not even sure if pdfmake supports rtf - I'm not seeing it in their documentation. It would need to be added in that library before we can offer any support for it I'm afraid.
Allan
in defaultStyle object is there direction property to set it rtl
Can you give me the link to that in the pdfmake docs please?
Allan
thanks @allan for respond , this part of my code to export arabic font in pdf, maybe it will help someone else:
this worked for me, but the header of table words not reversed
also is there a way to reverse the columns mean that last column in table rendered in first an so on, those together reversing in doc content and table columns will solve RTL problem and finally reverse in doc title
See my reply in your other thread.
Colin
columns: [ "the index of the column that you want to export in reverse" ]
columns: [0,1,2,3 ]
put them like this
columns: [3,2,1,0 ]