Skip to content

Commit

Permalink
Excel format: New RTL option
Browse files Browse the repository at this point in the history
  • Loading branch information
hhurz committed Oct 23, 2017
1 parent a335fa4 commit da06803
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 55 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ csvSeparator: ','
csvUseBOM: true
displayTableName: false
escape: false
excelRTL: false
excelstyles: []
excelFileFormat: 'xlshtml'
fileName: 'tableExport'
Expand Down
19 changes: 14 additions & 5 deletions tableExport.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
displayTableName: false,
escape: false,
excelFileFormat: 'xlshtml', // xmlss = XML Spreadsheet 2003 file format (XMLSS), xlshtml = Excel 2000 html format
excelRTL: false, // true = Set Excel option 'DisplayRightToLeft'
excelstyles: [], // e.g. ['border-bottom', 'border-top', 'border-left', 'border-right']
fileName: 'tableExport',
htmlContent: false,
Expand Down Expand Up @@ -519,10 +520,16 @@
typeof defaults.worksheetName[j] !== 'undefined' ? defaults.worksheetName[j] :
'Table ' + (j + 1);

xmlssDocFile += '<Worksheet ss:Name="' + ssName + '">' +
docDatas[j] +
'<WorksheetOptions/> ' +
'</Worksheet>';
xmlssDocFile += '<Worksheet ss:Name="' + ssName + '" ss:RightToLeft="' + (defaults.excelRTL ? '1' : '0') + '">' +
docDatas[j];
if (defaults.excelRTL) {
xmlssDocFile += '<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"> ' +
'<DisplayRightToLeft/> ' +
'</WorksheetOptions> ';
}
else
xmlssDocFile += '<WorksheetOptions/> ';
xmlssDocFile += '</Worksheet>';
}

xmlssDocFile += '</Workbook>';
Expand Down Expand Up @@ -665,7 +672,7 @@
var docFile = '<html xmlns:o="urn:schemas-microsoft-com:office:office" ' + MSDocSchema + ' xmlns="http://www.w3.org/TR/REC-html40">';
docFile += '<meta http-equiv="content-type" content="application/vnd.ms-' + MSDocType + '; charset=UTF-8">';
docFile += "<head>";
if ( MSDocType === 'excel' ) {
if (MSDocType === 'excel') {
docFile += "<!--[if gte mso 9]>";
docFile += "<xml>";
docFile += "<x:ExcelWorkbook>";
Expand All @@ -676,6 +683,8 @@
docFile += "</x:Name>";
docFile += "<x:WorksheetOptions>";
docFile += "<x:DisplayGridlines/>";
if (defaults.excelRTL)
docFile += "<x:DisplayRightToLeft/>";
docFile += "</x:WorksheetOptions>";
docFile += "</x:ExcelWorksheet>";
docFile += "</x:ExcelWorksheets>";
Expand Down
Loading

0 comments on commit da06803

Please sign in to comment.