xlsxwriter

Odoo image in excel

邮差的信 提交于 2020-01-06 07:11:07
问题 I'm creating an excel file with xlsxwriter and need to place my company logo into these excel file.. I've been trying with insert_image but not success. I suppose that is something like parse partner.image into a buffer... but im stuck.. Pleace your help. this is my code. @api.multi def report_print(self): output=io.BytesIO() book=xlsxwriter.Workbook(output) sheet1=book.add_worksheet("PCA") sheet1.write('A1','PCA') #======================================================================= #

Rewriting some functions for xlsxwriter box borders from Python 2 to Python 3

本小妞迷上赌 提交于 2020-01-06 03:21:46
问题 I am having some problem getting xlsxwriter to create box borders around a number of cells when creating a Excel sheet. After some searching I found a thread here where there was a example on how to do this in Python 2. The link to the thread is: python XlsxWriter set border around multiple cells The answer I am trying to use is the one given by aubaub. I am using Python 3 and is trying to get this to work but I am having some problems with it. The first thing I did was changing xrange to

Write strings/text and pandas dataframe to excel

て烟熏妆下的殇ゞ 提交于 2020-01-01 09:45:11
问题 I'd like to save some text and a dataframe to an excel file like that: Thus, I've got the following variables: text1 = "some text here" text2 = "other text here" df = pd.DataFrame({"a": [1,2,3,4,5], "b": [6,7,8,9,10], "c": [11,12,13,14,15]}) As I've figured out there is the possibility to use the xlsxwriter to do this which means that I basically have to iterate over the whole dataframe to write each entry to a different cell in the excel workbook. This is quite cumbersome. So, I thought

Write strings/text and pandas dataframe to excel

左心房为你撑大大i 提交于 2020-01-01 09:45:10
问题 I'd like to save some text and a dataframe to an excel file like that: Thus, I've got the following variables: text1 = "some text here" text2 = "other text here" df = pd.DataFrame({"a": [1,2,3,4,5], "b": [6,7,8,9,10], "c": [11,12,13,14,15]}) As I've figured out there is the possibility to use the xlsxwriter to do this which means that I basically have to iterate over the whole dataframe to write each entry to a different cell in the excel workbook. This is quite cumbersome. So, I thought

Writing pandas/matplotlib image directly into XLSX file

馋奶兔 提交于 2019-12-30 17:58:12
问题 I am generating plots in pandas/matplotlib and wish to write them to an XLSX file. I am not looking to create native Excel charts; I am merely writing the plots as non-interactive images. I am using the XlsxWriter library/engine. The closest solution I have found is the answer to this SO question, which suggests using the XlsxWriter.write_image() method. However, this method appears to take a filename as its input. I am trying to programmatically pass the direct output from a pandas

如何使用 Python 合并多个格式一致的 Excel 文件?

旧街凉风 提交于 2019-12-30 14:14:18
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 最近在工作中遇到这样一个问题,每天都要处理如下一批 Excel 表格:每个表格的都只有一个 sheet,表格的前两行为表格标题及表头,表格的最后一行是相关人员签字。最终目标是将每个表格的内容合并到一个 Excel 表格中,使之成为一张表格。每天复制粘贴这一类操作占用了绝大部分时间。表格样式如下: 需求分析 根据描述,最终需求应该是这样的:在这一批表格中选取任意一个表格的前两行作为新表格的标题与表头,将这两行内容以嵌套列表的形式插入一个名为 data 空列表中。取每张表格的第3至倒数第二行,剔除空白行的内容。并将所有表格的内容以子列表的方式依次插入 data 列表中。任取一表格的最后一行以子列表的方式插入 data 列表中。最后将 data 列表的内容写入一个新的 Excel 表格中。 查阅资料 通过几分钟的上网查询,得出以下结论: - 3.1 通过 xlrd 和 xlsxwriter 模块即可解决次需求; 3.2 之所以使用 xlrd 和 xlsxwriter 是因为: xlrd擅长读取 Excel 文件,不适合写入,用 xlsxwriter 来进行大规模写入 Excel 表格不会出现报错。 编码 一切以解决当前问题为向导,说干就干。 coding ... ... 阅读原文获取编码: https:/

DateTime issues in django xlsxwriter

青春壹個敷衍的年華 提交于 2019-12-30 10:34:46
问题 I am trying to create an export to excel functionality in my django view as follows: def export_myreport(request, sd, ed): from xlsxwriter.workbook import Workbook import cStringIO as StringIO from django.utils.encoding import smart_str # create a workbook in memory output = StringIO.StringIO() wb = Workbook(output) bg = wb.add_format({'bg_color': '#9CB640', 'font_color': 'black'}) bg2 = wb.add_format({'bg_color': '#FFFFFF', 'font_color': 'black'}) ws = wb.add_worksheet('My Report') row_num =

Apply styles while exporting to 'xlsx' in pandas with XlsxWriter

夙愿已清 提交于 2019-12-30 03:06:50
问题 I use the .to_excel method of pandas to write a DataFrame as an Excel workbook. This works nice even for multi-index DataFrames as index cells become merged. When using the pure XlsxWriter I can apply formats to cells what also works nice. However I couldn't find a way to do the same with the pandas method. Just passing a dict with column names and styles would be most intuitive. Is there any way to do so? 回答1: Is there any way to do so Currently no. There isn't a formatting mechanism like

Is it possible to read data from an Excel sheet in Python using Xlsxwriter? If so how?

纵饮孤独 提交于 2019-12-28 20:33:11
问题 I'm doing the following calculation. worksheet.write_formula('E5', '=({} - A2)'.format(number)) I want to print the value in E5 on the console. Can you help me to do it? Is it possible to do it with Xlsxwriter or should I use a different library to the same? 回答1: It is not possible to read data from an Excel file using XlsxWriter. There are some alternatives listed in the documentation. 回答2: Not answering this specific question, just a suggestion - simply try pandas and read data from excel.

Apply format to a cell after being written in XlsxWriter

北战南征 提交于 2019-12-28 13:41:09
问题 I work on python using XlsxWriter and I've been trying to solve this problem with no success: My app must create an Xlsx file in which data is shown in a table-like structure. That table has some empty cells. I'd like to set borders to some cells to make a grid for the table so I use: format6 = excelbook.add_format() format6.set_left(1) for y in range(24): excel.write(y+5, 1, None, format6) in order to have border applied to those cells. Then, I write data on the table. Since the table layout