Questions tagged [xlwt]

Library to create spreadsheet files compatible with MS Excel 97/2000/XP/2003 XLS files, on any platform.

xlwt is a Python library for modifying and generating spreadsheet files that are compatible with Excel 97/2000/XP/2003, OpenOffice.org Calc, and Gnumeric.

xlwt does not (yet) support Excel 2007 (.xlsx, .xlsm) writing.

xlwt has full support for Unicode. Excel spreadsheets can be generated on any platform without needing Excel or a COM server. The only requirement is Python 2.3 or higher. xlwt is a fork of pyExcelerator.

http://pypi.python.org/pypi/xlwt

640 questions
66
votes
5 answers

writing to existing workbook using xlwt

I am unable to find examples where xlwt is used to write into existing files. I have a existing xls file that I need to write to. When I use xlrd to read the file, I cant seem to figure out how to transform the "Book" type returned into a…
Raj N
  • 955
  • 1
  • 9
  • 10
57
votes
2 answers

Preserving styles using python's xlrd,xlwt, and xlutils.copy

I'm using xlrd, xlutils.copy, and xlwt to open up a template file, copy it, fill it with new values, and save it. However, there doesn't seem to be any easy way to preserve the formatting of the cells; it always gets blown away and set to blank. Is…
YGA
  • 9,546
  • 15
  • 47
  • 50
35
votes
6 answers

django excel xlwt

On a django site, I want to generate an excel file based on some data in the database. I'm thinking of using xlwt, but it only has a method to save the data to a file. How can get the file to the HttpResponse object? Or maybe do you know a better…
Adrian Mester
  • 2,523
  • 1
  • 19
  • 23
34
votes
2 answers

Edit existing excel workbooks and sheets with xlrd and xlwt

In the documentation for xlrd and xlwt I have learned the following: How to read from existing work-books/sheets: from xlrd import open_workbook wb = open_workbook("ex.xls") s = wb.sheet_by_index(0) print s.cell(0,0).value #Prints contents of cell…
Jack Pettersson
  • 1,606
  • 4
  • 17
  • 28
32
votes
6 answers

Python xlwt - accessing existing cell content, auto-adjust column width

I am trying to create an Excel workbook where I can auto-set, or auto-adjust the widths of the columns before saving the workbook. I have been reading the Python-Excel tutorial in hopes of finding some functions in xlwt that emulate xlrd ones (such…
nooblar
  • 399
  • 1
  • 5
  • 12
31
votes
1 answer

Using Python, write an Excel file with columns copied from another Excel file

I have an Excel file containing a varying number of columns, I would like to loop through certain columns (from their header row value) of that file using Python, then write (copy) those columns to another Excel file. Any examples on how I can do…
salamey
  • 3,633
  • 10
  • 38
  • 71
27
votes
1 answer

How to write a cell with multiple columns in xlwt?

I'd like to write a table like this: ---------------- | Long Cell | ---------------- | 1 | 2 | ---------------- How to write the cell Long Cell? Thanks. I've tried to do it like this: sheet.write(0, 0, 'Long Cell') sheet.write(1, 0,…
Bin Wang
  • 2,697
  • 2
  • 24
  • 34
26
votes
3 answers

does xlwt support xlsx Format

I have searched into google and found some contradiction. Does xlwt support xlsx file (MS office 2007). I heard that xlwt 0.7.4 support xlsx file. Does anyone tried xlsx file writing operation with xlwt 0.7.4 The purpose of this question is,I do not…
user765443
  • 1,856
  • 7
  • 31
  • 56
24
votes
5 answers

python xlwt set custom background colour of a cell

I am using python 2.7 and xlwt module for excel export I would like to set backgroung colour of a cell i know i can use style1 = xlwt.easyxf('pattern: pattern solid, fore_colour red;') but I would like to set custom color smth. like #8a8eef or is…
Yebach
  • 1,661
  • 8
  • 31
  • 58
23
votes
3 answers

Writing multi-line strings to cells using xlwt module

Python: Is there a way to write multi-line strings into an excel cell with just the xlwt module? (I saw answers suggesting use of openpyxl module) The sheet.write() method ignores the \n escape sequence. So, just xlwt, is it possible? Thanks in…
user2782845
  • 235
  • 1
  • 2
  • 5
21
votes
5 answers

How to copy over an Excel sheet to another workbook in Python

I have a string with a sourcefile path and another string with a destfile path, both pointing to Excel workbooks. I want to take the first sheet of the sourcefile and copy it as a new tab to the destfile (doesn't matter where in the destfile), then…
KaliMa
  • 1,970
  • 6
  • 26
  • 51
21
votes
1 answer

python xlutils : formatting_info=True not yet implemented

I've got simple code to copy files with xlutils, xlrd, xlwt (downloaded new libraries from python-excel.org) with not loosing formatting. I've got an error as below: from xlwt.Workbook import * from xlwt.Style import * from xlrd import…
user1891854
  • 211
  • 1
  • 2
  • 4
19
votes
4 answers

Python XLWT attempt to overwrite cell workaround

Using the python module xlwt, writing to the same cell twice throws an error: Message File Name Line Position Traceback S:\******** write C:\Python26\lib\site-packages\xlwt\Worksheet.py 1003 …
PPTim
  • 1,346
  • 6
  • 18
  • 33
19
votes
12 answers

Insert row into Excel spreadsheet using openpyxl in Python

I'm looking for the best approach for inserting a row into a spreadsheet using openpyxl. Effectively, I have a spreadsheet (Excel 2007) which has a header row, followed by (at most) a few thousand rows of data. I'm looking to insert the row as the…
Nick
  • 2,285
  • 2
  • 14
  • 26
18
votes
6 answers

python: creating excel workbook and dumping csv files as worksheets

I have few csv files which I would like to dump as new worksheets in a excel workbook(xls/xlsx). How do I achieve this? Googled and found 'pyXLwriter' but it seems the project was stopped. While Im trying out 'pyXLwriter' would like to know are…
siva
  • 2,105
  • 4
  • 20
  • 37
1
2 3
42 43