Search code examples
pythonexcelxlwt

right to left excel page layout in python xlwt


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)


Solution

  • 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")