xlwt

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

我与影子孤独终老i 提交于 2019-11-28 05:22:29
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 this please? alecxe Here are some options to choose from: xlwt (writing xls files) xlrd (reading xls/xlsx files) openpyxl (reading/writing xlsx files) xlsxwriter (writing xlsx files) If you need to copy only data (without formatting information), you can just use any combination of these tools for reading/writing. If you have an xls file, you should

python: creating excel workbook and dumping csv files as worksheets

别来无恙 提交于 2019-11-28 04:34:25
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 there any alternatives/suggestions/modules? Many Thanks. [Edit] Here is my solution: (anyone has much leaner, much pythonic solution? do comment. thx) import glob import csv import xlwt import os wb = xlwt.Workbook() for filename in glob.glob("c:/xxx/*.csv"): (f_path, f_name) = os.path.split(filename) (f_short_name, f_extension) = os.path.splitext(f

The ability to apply multiple formats to cell with xlwt / openpyxl

廉价感情. 提交于 2019-11-28 00:51:39
问题 I plan to use one of 2 libraries below to output excel file in python: xlwt ( http://www.python-excel.org/ ) openpyxl ( http://packages.python.org/openpyxl/ ) I tried the first one, most of things seem to be fine but one issue, unfortunately it may not support the ability to apply multiple formats to cell. (see http://groups.google.com/group/python-excel/browse_thread/thread/11c24606d9b2914d) Is it true? If yes, does anybody know how to solve it? E.g it cannot make some words bold, others

How to change background color of excel cell with python xlwt library?

。_饼干妹妹 提交于 2019-11-28 00:48:08
I use xlwt Python library to write data in excel workbook. And now I have some problems with adding background color to excel cell. For example I have next color in RGB(10,20,30), what is the easiest way to do this? Is there any way to set this color to cell? I found only this post which similar with my problem. Pooria Kaviani In this example, I have shown how to set background color for cells, you can run it for result: from xlwt import Workbook import xlwt book = Workbook() sheet1 = book.add_sheet('Sheet 1') for i in range(0, 100): st = xlwt.easyxf('pattern: pattern solid;') st.pattern

does xlwt support xlsx Format

一曲冷凌霜 提交于 2019-11-27 15:50:40
问题 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 have permission to install library if I need to install I need to provide more detail info. I need to write xlsx file in python.So if anyone has done similar thing it will help to provide better inforamtion I have looked into this wiki page. https

django excel xlwt

跟風遠走 提交于 2019-11-27 10:44:58
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 library? I've also found this snippet but it doesn't do what I need. All I want is a way to get the stream from the xlwt object to the response object (without writing to a temporary file) neat package! i didn't know about this According to the doc, the save(filename_or_stream) method takes either a filename to save on, or a file-like stream to write

writing a QTableWidget to a .csv or .xls

无人久伴 提交于 2019-11-27 09:20:56
Is it possible to write the contents of a QTableWidget to a csv? I found a question about writing to an .xls using xlwt, but can't seem to get it to work using my code. def saveFile(self): filename = unicode(QtGui.QFileDialog.getSaveFileName(self, 'Save File', '', ".xls(*.xls)")) wbk = xlwt.Workbook() self.sheet = wbk.add_sheet("sheet") self.write() wbk.save(filename) def write(self): for col in range (self.coordinates.columnCount()): for row in range(self.coordinates.rowCount()): text=str(self.coordinates.item(row,col).text()) self.sheet.write(row,col,text) I get the following error: File "C:

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

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 09:18:20
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 save it. Couldn't find an easy way in xlrd or xlwt or xlutils to do this. Am I missing something? Solution 1 A Python-only solution using the openpyxl package. Only data values will be copied. import openpyxl as xl path1 = 'C:\\Users\\Xukrao\\Desktop\\workbook1.xlsx' path2 = 'C:\\Users\\Xukrao\\Desktop\\workbook2.xlsx' wb1 = xl.load_workbook

python: creating excel workbook and dumping csv files as worksheets

岁酱吖の 提交于 2019-11-27 05:25:00
问题 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 there any alternatives/suggestions/modules? Many Thanks. [Edit] Here is my solution: (anyone has much leaner, much pythonic solution? do comment. thx) import glob import csv import xlwt import os wb = xlwt.Workbook() for filename in glob.glob("c:/xxx/*

Insert row into Excel spreadsheet using openpyxl in Python

自闭症网瘾萝莉.ら 提交于 2019-11-27 05:16:46
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 first row of actual data, so after the header. My understanding is that the append function is suitable for adding content to the end of the file. Reading the documentation for both openpyxl and xlrd (and xlwt), I can't find any clear cut ways of doing this, beyond looping through the content manually and inserting into a new sheet (after inserting