473,287 Members | 2,263 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

xlwt (Borders: Type)

20
Hello,

I'm trying to find documentation about the xlwt (py_excelerator). I want to change the border of some cells. But the only types that I found is: double and dashed. How to do a simple line and what is the all other border type name?

"borders: top double, bottom double, left double, right double;"


Thank You

Nicolas




here is my code:

Expand|Select|Wrap|Line Numbers
  1. ## Startup Code Begin
  2. import xlwt
  3. from xlwt import *
  4. import string
  5. import os
  6. from datetime import datetime
  7. import time
  8. from time import gmtime, strftime
  9. current_date = strftime("%b %d %Y   (%H:%M)")
  10. ## Startup Code End
  11.  
  12.  
  13. ## Modules Begin
  14. def _size_col(sheet, col):
  15.     return sheet.col_width(col)
  16.  
  17. def _size_row(sheet, row):
  18.     return sheet.row_height(row)
  19.     ## Modules End
  20.  
  21.  
  22. ## Style variable Begin
  23. tittle_style = xlwt.easyxf('font: height 400, name Arial Black, colour_index blue, bold on; align: wrap on, vert centre, horiz center;'      "borders: top double, bottom double, left double, right double;")
  24. subtittle_left_style = xlwt.easyxf('font: height 240, name Arial, colour_index brown, bold on, italic on; align: wrap on, vert centre, horiz left;'      "borders: top double, bottom double, left double;")
  25. subtittle_right_style = xlwt.easyxf('font: height 240, name Arial, colour_index brown, bold on, italic on; align: wrap on, vert centre, horiz left;'      "borders: top double, bottom double, right double;")
  26. subtittle_top_and_bottom_style = xlwt.easyxf('font: height 240, name Arial, colour_index black, bold off, italic on; align: wrap on, vert centre, horiz left;'      "borders: top double, bottom double;")
  27. blank_style = xlwt.easyxf('font: height 650, name Arial, colour_index brown, bold off; align: wrap on, vert centre, horiz left;'      "borders: top double, bottom double, left double, right double;")
  28. normal_style = xlwt.easyxf('font: height 240, name Arial, colour_index black, bold off; align: wrap on, vert centre, horiz left;'      "borders: top double, bottom double, left double, right double;")
  29. ## Style variable End
  30.  
  31.  
  32. ## Module Add Begin
  33. def print_blank_line(A, B, C, D):
  34.     ws.write_merge(A, B, C, D, "", xlwt.easyxf('font: height 240, name Arial, colour_index black, bold off, italic on; align: wrap on, vert centre, horiz left;'))
  35.     ## Module Add End
  36.  
  37.  
  38. ## Variable Begin
  39. Excel = xlwt.Workbook()
  40. ## Variable End
  41.  
  42.  
  43. ## Sheet Name Begin
  44. ws = Excel.add_sheet('Test Sheet')
  45. ## Sheet Name End
  46.  
  47.  
  48. ## Column Width Determine Begin
  49. for A in range(100):
  50.     ws.col(A).width = 600
  51. ## Column Width Determine Begin
  52.  
  53.  
  54. ## Tittle Picture Begin
  55. ws.write_merge(0, 0, 0, 42, "", xlwt.easyxf('font: height 700, name Arial, colour_index brown, bold off; align: wrap on, vert centre, horiz left;'))
  56. ##ws.insert_bitmap('test.bmp', 0, 0, 60, 5, 1.75, 1)
  57. ## Tittle Picture End
  58.  
  59.  
  60. ## Subtittle Write Begin
  61. # Variable Begin
  62. job_name = "Nicolas_Parametric"
  63. fab_name = "Nicolas_Parametric"
  64. printed_by = "Nic"
  65. printed_date = current_date
  66. # Variable End
  67.  
  68. border_type = ["dashed", "double", ""]
  69.  
  70. ws.write_merge(1, 1, 0, 6, "Job Name:", xlwt.easyxf('font: height 240, name Arial, colour_index black, bold on, italic on; align: wrap on, vert centre, horiz left;'      "borders: top double, bottom double, left double;"))
  71. ws.write_merge(1, 1, 7, 21, job_name, xlwt.easyxf('font: height 240, name Arial, colour_index black, bold off, italic on; align: wrap on, vert centre, horiz left;'      "borders: top double, bottom double;"))
  72. ws.write_merge(2, 2, 0, 6, "Fab Name:", xlwt.easyxf('font: height 240, name Arial, colour_index black, bold on, italic on; align: wrap on, vert centre, horiz left;'      "borders: top double, bottom double, left double;"))
  73. ws.write_merge(2, 2, 7, 21, fab_name, xlwt.easyxf('font: height 240, name Arial, colour_index black, bold off, italic on; align: wrap on, vert centre, horiz left;'      "borders: top double, bottom double;"))
  74.  
  75. ws.write_merge(1, 1, 22, 27, "Printed By:", xlwt.easyxf('font: height 240, name Arial, colour_index black, bold on, italic on; align: wrap on, vert centre, horiz left;'      "borders: top double, bottom double;"))
  76. ws.write_merge(1, 1, 28, 42, printed_by, xlwt.easyxf('font: height 240, name Arial, colour_index black, bold off, italic on; align: wrap on, vert centre, horiz left;'      "borders: top double, bottom double, right double;"))
  77. ws.write_merge(2, 2, 22, 27, "Printed Date:", xlwt.easyxf('font: height 240, name Arial, colour_index black, bold on, italic on; align: wrap on, vert centre, horiz left;'      "borders: top double, bottom double;"))
  78. ws.write_merge(2, 2, 28, 42, printed_date, xlwt.easyxf('font: height 240, name Arial, colour_index black, bold off, italic on; align: wrap on, vert centre, horiz left;'      "borders: top double, bottom double, right double;"))
  79.  
  80. print_blank_line(3, 3, 0, 42)
  81. ws.write_merge(4, 4, 0, 42, "Report Name", xlwt.easyxf('font: height 400, name Arial, colour_index red, bold on, italic on, underline on; align: wrap on, vert centre, horiz center;'))
  82. print_blank_line(5, 5, 0, 42)
  83.  
  84. ws.write_merge(6, 6, 0, 1, "#", xlwt.easyxf('font: height 240, name Arial, colour_index black, bold on, italic on; align: wrap on, vert centre, horiz left;'      "borders: top double, bottom double, left double, right double;"))
  85. ws.write_merge(6, 6, 2, 7, "Piecemark", xlwt.easyxf('font: height 240, name Arial, colour_index black, bold on, italic on; align: wrap on, vert centre, horiz left;'      "borders: top double, bottom double, left dashed, right double;"))
  86. ws.write_merge(6, 6, 8, 10, "Qty", xlwt.easyxf('font: height 240, name Arial, colour_index black, bold on, italic on; align: wrap on, vert centre, horiz left;'      "borders: top double, bottom double, left dashed, right double;"))
  87. ws.write_merge(6, 6, 11, 20, "Size", xlwt.easyxf('font: height 240, name Arial, colour_index black, bold on, italic on; align: wrap on, vert centre, horiz left;'      "borders: top double, bottom double, left dashed, right double;"))
  88. ws.write_merge(6, 6, 21, 34, "Status", xlwt.easyxf('font: height 240, name Arial, colour_index black, bold on, italic on; align: wrap on, vert centre, horiz left;'      "borders: top double, bottom double, left dashed, right double;"))
  89. ws.write_merge(6, 6, 35, 42, "Date", xlwt.easyxf('font: height 240, name Arial, colour_index black, bold on, italic on; align: wrap on, vert centre, horiz left;'      "borders: top double, bottom double, left dashed, right double;"))
  90. ## Subtittle Write End
  91.  
  92.  
  93. normal_font = xlwt.easyxf('font: height 240, name Arial, colour_index black; align: wrap on, vert centre, horiz left;'      "borders: top dashed, bottom dashed, left double, right double;")
  94.  
  95. for A in range(98):
  96.     ws.write_merge(7 + A, 7 + A, 0, 1, "", normal_font)
  97.     ws.write_merge(7 + A, 7 + A, 2, 7, "", normal_font)
  98.     ws.write_merge(7 + A, 7 + A, 8, 10, "", normal_font)
  99.     ws.write_merge(7 + A, 7 + A, 11, 20, "", normal_font)
  100.     ws.write_merge(7 + A, 7 + A, 21, 34, "", normal_font)
  101.     ws.write_merge(7 + A, 7 + A, 35, 42, "", normal_font)
  102.  
  103.  
  104. ## File Save As Begin
  105. Excel.save('Test.xls')
  106. ## File Save As End
  107.  
  108.  
  109. #### Start File Begin
  110. ##os.startfile("C:/Documents and Settings/dev01/Desktop/Test.xls")
  111. #### Start File End
  112.  
Nov 4 '09 #1
2 30691
bvdet
2,851 Expert Mod 2GB
This is what I found in the xlwt source code:
Expand|Select|Wrap|Line Numbers
  1. border_line_map = {
  2.     # Text values for these borders attributes:
  3.     # left, right, top, bottom and diag
  4.     'no_line':  0x00,
  5.     'thin':     0x01,
  6.     'medium':   0x02,
  7.     'dashed':   0x03,
  8.     'dotted':   0x04,
  9.     'thick':    0x05,
  10.     'double':   0x06,
  11.     'hair':     0x07,
  12.     'medium_dashed':                0x08,
  13.     'thin_dash_dotted':             0x09,
  14.     'medium_dash_dotted':           0x0a,
  15.     'thin_dash_dot_dotted':         0x0b,
  16.     'medium_dash_dot_dotted':       0x0c,
  17.     'slanted_medium_dash_dotted':   0x0d,
  18.     }
Nov 4 '09 #2
nicstel
20
Thanks bvdet.

I have tried all the possible border that you sent me and it's all works. I'm learnig to write on excel file with this module because it's easy to use.

Borders type name: thin, medium, dotted etc...

Nicolas
Nov 4 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Hostile17 | last post by:
I've been trying to figure out a good way to make a CSS layout with nice-looking 1-pixel borders around the table cells. The only broadly compatible way to do this I know of is to have * the...
7
by: NeverLift | last post by:
I posted a very long message regarding my experiences with JavaScript, one reply was posted asking I post an example of the problem -- and both are gone! Is there a moderator that removes such...
4
by: Konrad Viltersten | last post by:
As it isnow i have to use a syntax for my tables as: <table class = "some" border> and/or <table class = "some" noborder> Now, what i'd like to do is to make that border-thingy...
1
by: Glen Vermeylen | last post by:
Hi, For a project at school we have to automate the assignment of seats in classrooms to students during the exams. The lady who previously did everything manually kept the layouts of the...
2
satchmo67
by: satchmo67 | last post by:
Howdy, I want to reply to a really old post on this subject. The original poster was battling with the problem of trying to validate a frameset page and use the border attribute. I have been down...
0
by: ineuw | last post by:
I am trying to display form fields with flush borders and eliminate the sunken effect. This works fine for text fields, but only partially for select boxes, or file inputs. IE6 and Firefox both...
0
by: Chanman | last post by:
I've posted this on the python-excel group, but perhaps people here know what to do. How does one change the cell background color using the xlwt module? I've looked at several tutorials but...
5
by: Albert-jan Roskam | last post by:
Hi, I wrote the program below to merge all xls files in a given directory into one multisheet xls file. It uses xlwt and xlrd. The xls files I use for input are generated by Spss. When I open and...
0
by: Albert-jan Roskam | last post by:
Hi John, Thanks! Using a higher xlrd version did the trick! Regarding your other remarks: -yep, input files with multiple sheets don't work yet. I kinda repressed that ;-) Spss outputs only...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.