473,836 Members | 1,522 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xlwt (Borders: Type)

20 New Member

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


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
  13. ## Modules Begin
  14. def _size_col(sheet, col):
  15.     return sheet.col_width(col)
  17. def _size_row(sheet, row):
  18.     return sheet.row_height(row)
  19.     ## Modules End
  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
  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
  38. ## Variable Begin
  39. Excel = xlwt.Workbook()
  40. ## Variable End
  43. ## Sheet Name Begin
  44. ws = Excel.add_sheet('Test Sheet')
  45. ## Sheet Name End
  48. ## Column Width Determine Begin
  49. for A in range(100):
  50.     ws.col(A).width = 600
  51. ## Column Width Determine Begin
  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
  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
  68. border_type = ["dashed", "double", ""]
  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;"))
  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;"))
  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)
  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
  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;")
  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)
  104. ## File Save As Begin
  105. Excel.save('Test.xls')
  106. ## File Save As End
  109. #### Start File Begin
  110. ##os.startfile("C:/Documents and Settings/dev01/Desktop/Test.xls")
  111. #### Start File End
Nov 4 '09 #1
2 30979
2,851 Recognized Expert Moderator Specialist
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
20 New Member
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...

Nov 4 '09 #3

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

Similar topics

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 border of the table set to zero * the cellspacing of the table set to one * the background color set to black * the table cell background color set to white
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 stuff? In any case, here is the issue in brief: I want to keep the page invisible while my onload script decides how to format it, setting colors, downloads images, etc. The style "visibility:hidden" in the body tag almost does it -- except...
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 appear/desappear using javascript. Is it solvable that way? I tried to rely on CSS but i didn't find any good info on this matter...
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 classrooms in an excel-document: 1 sheet per classroom, and she marked the cells which represent the seats with a border. The problem however is that she sometimes merged cells together to get a better layout.
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 this very path some time ago and can answer! Fact is you can't use the border attribute and also validate as a frameset, but you can work around it to achieve the outcome of validating your page and also killing the frame borders. A site I...
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 display this problem but with different form objects. Any help is greatly appreciated. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/transitional.dtd"> <html> <head> <style type="text/css"> .flat
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 none show how to change the background color. I've tried the following: badBG = xlwt.Pattern() badBG.SOLID_PATTERN = 0x34 badBG.NO_PATTERN = 0x34
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 re-save the files in Excel, the program works, but when I use the xls files as they were created by Spss, the program returns an error message (see below). Some details: Python 2.4, xlwt version 0.7.0, xlrd version 0.5.2, Win NT. Any ideas? ...
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 single-sheet xls files, but I agree it's nicer if the programs works in other cases too. -and no, I don't intend to use data fields. Wouldn't it be easier to convert those to string values if I ever came across them? Thanks again! Albert-Jan
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.