merged1.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #!/usr/bin/env python
  2. # -*- coding: windows-1251 -*-
  3. # Copyright (C) 2005 Kiseliov Roman
  4. from xlwt import *
  5. wb = Workbook()
  6. ws0 = wb.add_sheet('sheet0')
  7. fnt1 = Font()
  8. fnt1.name = 'Verdana'
  9. fnt1.bold = True
  10. fnt1.height = 18*0x14
  11. pat1 = Pattern()
  12. pat1.pattern = Pattern.SOLID_PATTERN
  13. pat1.pattern_fore_colour = 0x16
  14. brd1 = Borders()
  15. brd1.left = 0x06
  16. brd1.right = 0x06
  17. brd1.top = 0x06
  18. brd1.bottom = 0x06
  19. fnt2 = Font()
  20. fnt2.name = 'Verdana'
  21. fnt2.bold = True
  22. fnt2.height = 14*0x14
  23. brd2 = Borders()
  24. brd2.left = 0x01
  25. brd2.right = 0x01
  26. brd2.top = 0x01
  27. brd2.bottom = 0x01
  28. pat2 = Pattern()
  29. pat2.pattern = Pattern.SOLID_PATTERN
  30. pat2.pattern_fore_colour = 0x01F
  31. fnt3 = Font()
  32. fnt3.name = 'Verdana'
  33. fnt3.bold = True
  34. fnt3.italic = True
  35. fnt3.height = 12*0x14
  36. brd3 = Borders()
  37. brd3.left = 0x07
  38. brd3.right = 0x07
  39. brd3.top = 0x07
  40. brd3.bottom = 0x07
  41. fnt4 = Font()
  42. al1 = Alignment()
  43. al1.horz = Alignment.HORZ_CENTER
  44. al1.vert = Alignment.VERT_CENTER
  45. al2 = Alignment()
  46. al2.horz = Alignment.HORZ_RIGHT
  47. al2.vert = Alignment.VERT_CENTER
  48. al3 = Alignment()
  49. al3.horz = Alignment.HORZ_LEFT
  50. al3.vert = Alignment.VERT_CENTER
  51. style1 = XFStyle()
  52. style1.font = fnt1
  53. style1.alignment = al1
  54. style1.pattern = pat1
  55. style1.borders = brd1
  56. style2 = XFStyle()
  57. style2.font = fnt2
  58. style2.alignment = al1
  59. style2.pattern = pat2
  60. style2.borders = brd2
  61. style3 = XFStyle()
  62. style3.font = fnt3
  63. style3.alignment = al1
  64. style3.pattern = pat2
  65. style3.borders = brd3
  66. price_style = XFStyle()
  67. price_style.font = fnt4
  68. price_style.alignment = al2
  69. price_style.borders = brd3
  70. price_style.num_format_str = '_(#,##0.00_) "money"'
  71. ware_style = XFStyle()
  72. ware_style.font = fnt4
  73. ware_style.alignment = al3
  74. ware_style.borders = brd3
  75. ws0.merge(3, 3, 1, 5, style1)
  76. ws0.merge(4, 10, 1, 6, style2)
  77. ws0.merge(14, 16, 1, 7, style3)
  78. ws0.col(1).width = 0x0d00
  79. wb.save('merged1.xls')