How to set `rightToLeft: true` to the excel document by default

How to set `rightToLeft: true` to the excel document by default

sadeghbaratisadeghbarati Posts: 14Questions: 4Answers: 0
edited July 22 in Free community support

I have the same question as this discussion topic, which is unanswered

https://datatables.net/forums/discussion/55248/how-can-change-the-default-sheet-right-to-left-option-in-my-data-table-when-i-export-to-excel

When I export Excel files with DataTable Buttons I have reversed column which the user needs to go to the Page Layout tab and manually click on the Sheet Right-to-Left button


var sheet = xlsx.xl.worksheets['sheet1.xml']; // 1. $('sheet', sheet).attr('rightToLeft', 'true'); // 2. $('worksheet', sheet).prepend('<sheetViews><sheetView rightToLeft="1"></sheetView></sheetViews>')

I tested both of these codes I found on the web but it not working,

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,441Questions: 1Answers: 10,459 Site admin

    I think you'll need a right to left file produced by Excel, and then rename it to a zip file and extract it. Then check what XML Excel has created and see if you can replicate that for the downloaded spreadsheet.

    The Buttons Excel exporter is not intended to be used for anything other than trivial spreadsheets I'm afraid.

    Allan

  • sadeghbaratisadeghbarati Posts: 14Questions: 4Answers: 0

    You are right Allan it is intended but I want to set rightToLeft by default

    even though I did the same thing to find XML rightToLeft code, I found those codes above which make Excel file open with XML error

  • sadeghbaratisadeghbarati Posts: 14Questions: 4Answers: 0

    I got it working with this

    var sheet = xlsx.xl.worksheets['sheet1.xml'];
    $('worksheet', sheet).prepend(`<sheetViews><sheetView rightToLeft="1" tabSelected="1" workbookViewId="0"></sheetView></sheetViews>`)
    

    without workbookViewId Excel will open with XML error but when it exists, rightToLeft is working

  • allanallan Posts: 63,441Questions: 1Answers: 10,459 Site admin
    Answer ✓

    Very good - thank you for sharing this with us!

    Allan

Sign In or Register to comment.