merged.py 767 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env python
  2. # -*- coding: windows-1251 -*-
  3. # Copyright (C) 2005 Kiseliov Roman
  4. from xlwt import *
  5. fnt = Font()
  6. fnt.name = 'Arial'
  7. fnt.colour_index = 4
  8. fnt.bold = True
  9. borders = Borders()
  10. borders.left = 6
  11. borders.right = 6
  12. borders.top = 6
  13. borders.bottom = 6
  14. al = Alignment()
  15. al.horz = Alignment.HORZ_CENTER
  16. al.vert = Alignment.VERT_CENTER
  17. style = XFStyle()
  18. style.font = fnt
  19. style.borders = borders
  20. style.alignment = al
  21. wb = Workbook()
  22. ws0 = wb.add_sheet('sheet0')
  23. ws1 = wb.add_sheet('sheet1')
  24. ws2 = wb.add_sheet('sheet2')
  25. for i in range(0, 0x200, 2):
  26. ws0.write_merge(i, i+1, 1, 5, 'test %d' % i, style)
  27. ws1.write_merge(i, i, 1, 7, 'test %d' % i, style)
  28. ws2.write_merge(i, i+1, 1, 7 + (i%10), 'test %d' % i, style)
  29. wb.save('merged.xls')