4

How can set the sheet layout ( right-to-left ) by using xlwt ?

i am using xlwt for writing an excel sheet, but my data is right to left and i want to set sheet layout right to left ( same as microsoft excel's Page layout tab)

happy Sun
  • 579
  • 8
  • 15

2 Answers2

4
import xlwt
wb = xlwt.Workbook()
for shx in 0, 1:
    ws = wb.add_sheet("S%d" % shx)
    # Excel 2003: Tools > Options > International > View current sheet right-to-left
    # Excel 2007: Page Layout > Sheet Right-to-Left
    ws.cols_right_to_left = shx
    ws.write(0, 0, "qwerty")
wb.save("colsR2L.xls")
John Machin
  • 81,303
  • 11
  • 141
  • 189
1

By default, a sheet right-to-left is false, to set it true:

import xlwt
wbk = xlwt.Workbook()
sheet = wbk.add_sheet("sheet", cell_overwrite_ok=True)
sheet.cols_right_to_left = True
wbk.save("testRTL.xls")