openpyxl

Openpyxl: unexpected fail with CellIsRule function

試著忘記壹切 提交于 2019-12-24 20:32:23
问题 I am opening an Excel file and applying some conditional formatting: from openpyxl import * from openpyxl.formatting.rule import CellIsRule os.chdir(r'C:\Users\myfolder') wb= load_workbook('myfile.xlsx') ws = wb.active #Conditional formatting ws.conditional_formatting.add('S3:S89', formatting.CellIsRule(operator='equal', formula=['1'], font='#FF0000')) #Red This was done based on this answer. However, I get this error: AttributeError Traceback (most recent call last) <ipython-input-190

Putting multiple matplotlib graphs into Excel using Python 3

為{幸葍}努か 提交于 2019-12-24 19:38:52
问题 I am trying to create some graphs based on a dataframe I have in Python 3 called back and export them into Excel. I have been using some of the code from the below response response, but when I use it for more than one graph it gives me some weird results: Can I insert matplotlib graphs into Excel programmatically? My code is: import pandas as pd import matplotlib.pyplot as plt import matplotlib.dates as mdates import openpyxl filepath = 'C:\Filepath\Template.xlsx' writer = pd.ExcelWriter

Python Changing Chart Legend Colors - Openpyxl

前提是你 提交于 2019-12-24 17:12:05
问题 Is it possible to change the color associated with the legend of a chart created in Openpyxl? I have created a relatively simple chart using my data but would like to force the colors it uses to create each piece. Here's the snippet of my code related to the chart: chart = PieChart() data = Reference(worksheet, min_col=2, min_row=4, max_row=7, max_col=2) categories = Reference(worksheet, min_col=1, min_row=4, max_row=7, max_col=1) chart.add_data(data) chart.set_categories(categories)

Is it Possible to use OpenPyXl to create Excel Slicer objects for Charts/Pivot Charts?

笑着哭i 提交于 2019-12-24 13:24:26
问题 I'm currently using xlsx writer and openpyxl to create and edit worksheets. I have constructed dataframes which store relative statistics, and after publishing them to an excel sheet I'd like to include some basic user interaction features. Specifically, I was wondering if it is possible to create Excel Slicer objects and pair them with some line/bar/etc charts using OpenPyXl (or anopther api) so that subsets of the population can be visualized. 来源: https://stackoverflow.com/questions

Evaluating an Index Match with Openpyxl and Xlwings; formula returns, not value

↘锁芯ラ 提交于 2019-12-24 12:50:49
问题 I have referred to the following links but still cannot get my code to work Python openpyxl data_only=True returning None Refresh Excel External Data with Python Using Python's Openpyxl for an index match I am tackling my project in small pieces as I am new to python and coding. Ultimately I hope to populate a cell with a random number then use an index match to evaluate a list of text and numbers to identify the text string which corresponds to the random number. So if Item 4 in the

Pyinstaller Maximum Recursion Depth Exceded

自作多情 提交于 2019-12-24 10:15:06
问题 I am trying to create an executable from python 3.6.4 using pyinstaller 3.3.1. The packages I am using are Pandas and openpyxl. When I try to create the bundle I receive this error. $ RecursionError: maximum recursion depth exceeded in comparison I have tried increasing my recursion limit and most of the steps described in How to Report Bugs and the error is still the same. I also got the same error when I tried bundling import openpyxl print("Hello World") so I think the problem has to do

Format column as percentage in Openpyxl Python

假装没事ソ 提交于 2019-12-24 06:38:52
问题 I just want to make certain columns into percentages using Openpyxl for Python. I can't figure out how to change the formatting of the cells to another type? I've consulted this page: http://openpyxl.readthedocs.io/en/default/styles.html But if I try doing: ws['A:A'].style = percent I get ValueError: Style percent exists already. I'm sure I'm making some stupid mistake, but I can't figure out what it is. I've seen other threads about people wanting to change formats to currencies, which uses

Adjusting cells width and height in excel in mm/cm through python script

大兔子大兔子 提交于 2019-12-24 03:38:13
问题 I tried to look for it but couldn't find one. Is there a possibility to adjust the width,height of cells in excel in mm or cm dimensions using openpyxl or xlwt modules? if yes then can someone point me to the commands for scripting? thanks a lot. 回答1: With Openpyxl To set column width: #setting width of column B to 12.25 sheet.column_dimensions['B'].width = float(12.25) To set Row height: #setting height of row 3 to 33.75 sheet.row_dimensions[3].height = float(33.75) Hiding Columns and Rows

Excel worksheet to Numpy array

时光总嘲笑我的痴心妄想 提交于 2019-12-24 03:07:40
问题 I'm trying to do an unbelievably simple thing: load parts of an Excel worksheet into a Numpy array. I've found a kludge that works, but it is embarrassingly unpythonic: say my worksheet was loaded as "ws", the code: A = np.zeros((37,3)) for i in range(2,39): for j in range(1,4): A[i-2,j-1]= ws.cell(row = i, column = j).value loads the contents of "ws" into array A. There MUST be a more elegant way to do this. For instance, csvread allows to do this much more naturally, and while I could well

how to check if a cell is empty in openpyxl python

倾然丶 夕夏残阳落幕 提交于 2019-12-24 02:55:08
问题 I'm making a conditional statement in openpyxl Python to check if a cell is empty. Here's my code: newlist = [] looprow = 1 print ("Highest col",readex.get_highest_column()) getnewhighcolumn = readex.get_highest_column() for i in range(0, lengthofdict): prevsymbol = readex.cell(row = looprow,column=getnewhighcolumn).value if prevsymbol == "None": pass else: newstocks.append(prevsymbol) looprow += 1 #print (prevsymbol) print(newlist) I tried if prevsymbol == "": and if prevsymbol == null: to