xlwt

How can I edit Excel Workbooks using XLRD or openpyxl while preserving charts?

我与影子孤独终老i 提交于 2019-11-30 15:57:46
问题 I have a workbook that has some sheets in it. One of the sheets has charts in it. I need to use xlrd or openpyxl to edit another sheet, but, whenever I save the workbook, the charts are gone. Any workaround to this? Is there another python package that preserves charts and formatting? 回答1: This is currently not possible with either but I hope to have it in openpyxl 2.x. Patches / pull requests always welcome! ;-) 来源: https://stackoverflow.com/questions/19323049/how-can-i-edit-excel-workbooks

How can I edit Excel Workbooks using XLRD or openpyxl while preserving charts?

大城市里の小女人 提交于 2019-11-30 15:39:19
I have a workbook that has some sheets in it. One of the sheets has charts in it. I need to use xlrd or openpyxl to edit another sheet, but, whenever I save the workbook, the charts are gone. Any workaround to this? Is there another python package that preserves charts and formatting? This is currently not possible with either but I hope to have it in openpyxl 2.x. Patches / pull requests always welcome! ;-) 来源: https://stackoverflow.com/questions/19323049/how-can-i-edit-excel-workbooks-using-xlrd-or-openpyxl-while-preserving-charts

python读写Excel

≯℡__Kan透↙ 提交于 2019-11-29 21:41:27
最近小编在处理各种.xlsx表格的数据处理和计算的工作,目前python用于操作表格的模块有很多,功能各有千秋。本文主要讲的是xlwt用于写,xlrt用于读。 表格写入 简单的写入功能可用 xlwt 模块,写入功能的难点在于写入合并的单元格。 单元格的下标都是从0开始 。 xlwt官方API: https://xlwt.readthedocs.io/en/latest/api.html 安装: pip install xlwt 新建workbook: wk=xlwt.Workbook() 新建sheet: sheet1 = wk.add_sheet("数据", cell_overwrite_ok=True) 写入普通单元格:写入第3行,第2列 sheet1.write(2 , 1, "liebao") # 参数一:行下标 # 参数二:列下标 # 参数三:写入的内容 写入合并的单元格: # 列合并:写入第2行,第2~5列 sheet1.write_merge(1, 1, 1, 4, "列合并") # 行合并:写入第1~3行,第3列 sheet1.write_merge(0, 2, 2, 2, "行合并") # 参数一:开始的行下标 # 参数二:结束的行下标(包含) # 参数三:开始的列下标 # 参数四:结束的列下标(包含) # 参数五:写入的内容 保存至表格文件 wk.save

xlwt set style making error: More than 4094 XFs (styles)

佐手、 提交于 2019-11-29 18:25:35
问题 I use Xlwt for writing an excel file. it's cells has some style (color, alignment ,borders , ... ) when i use XFStyle and set borders and other attr of style, in some cases it make error: More than 4094 XFs (styles) why? what should i do with this error? thanks 回答1: I read and trace functions and methods that calls during execution. i find solution: wb = xlwt.Workbook(style_compression=2) use : style_compression=2 its work! 回答2: Upon encountering the same problem in the LOOP I have extracted

Writing multi-line strings to cells using xlwt module

给你一囗甜甜゛ 提交于 2019-11-29 16:48:18
问题 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 advance. 回答1: I found the answer in the python-excel Google Group. Using sheet.write() with the optional style argument, enabling word wrap for the cell, does the trick. Here is a minimum working example: import xlwt book = xlwt.Workbook() sheet = book

Converting multiple tab-delimited .txt files into multiple .xls files

牧云@^-^@ 提交于 2019-11-29 11:31:09
I am a newbie to python and I am trying to do what the title above says with the code displayed below. It runs up to the point where I ask to save the xls output. Any help would be very much appreciated. import glob import csv import xlwt for filename in glob.glob("C:\xxxx\*.txt"): wb = xlwt.Workbook() sheet = wb.add_sheet('sheet 1') newName = filename spamReader = csv.reader(open(filename, 'rb'), delimiter=';',quotechar='"') for rowx, row in enumerate(spamReader): for colx, value in enumerate(row): sheet.write(rowx, colx, value) wb.save(newName + ".xls") print "Done" Traceback (most recent

does xlwt support xlsx Format

拜拜、爱过 提交于 2019-11-29 01:21:22
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://pypi.python.org/pypi/xlwt But did not find that it support xlsx file or Should I use https://pypi

How to write a cell with multiple columns in xlwt?

試著忘記壹切 提交于 2019-11-28 20:26:41
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, 1) sheet.write(1, 1, 2) But it end up like: -------------------- | Long Cell | | -------------------- | 1 | 2 | -------------------- As far as I can tell, this isn't documented - you have to read the source code to find it. There are two methods on the Worksheet class to do this, write_merge and merge . merge takes existing cells and merges them, while write_merge

python xlutils : formatting_info=True not yet implemented

。_饼干妹妹 提交于 2019-11-28 09:07:41
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 open_workbook from xlutils.copy import copy import xlrd style = XFStyle() rb = open_workbook('file_master.xlsx', formatting_info=True) wb = copy(rb.get_sheet(0)) new_book = Workbook() w_sheet = wb.get_sheet(0) w_sheet.write(6,6) wb.save('new_file_master.xls') Error: raise NotImplementedError("formatting_info=True not yet implemented") NotImplementedError:

python xlwt set custom background colour of a cell

痞子三分冷 提交于 2019-11-28 07:25:15
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 there a palette of possible colors, because light blue is not working :) thank you darklow If you are not using easyxf() and instead are building XFStyle object step by step, here is another way of using user friendly color names: import xlwt style = xlwt.XFStyle() pattern = xlwt.Pattern() pattern.pattern = xlwt.Pattern.SOLID_PATTERN pattern.pattern