Questions tagged [openpyxl]

Openpyxl is a Python library for reading and writing Excel 2010 xlsx/xlsm/xltx/xltm files.

Openpyxl is a Python library to read/write Excel 2010 xlsx, xlsm, xltx, and xltm files.

It was born from lack of an existing library to read/write natively from Python the Office Open XML format.

All kudos to the PHPExcel team as openpyxl was initially based on PHPExcel.

Features:

  1. Tables
  2. Data validation
  3. Charts

About security:

By default Openpyxl does not guard against quadratic blowup or billion laughs XML attacks. To guard against these attacks, install defusedxml.

Project documentation can be found at openpyxl - A Python library to read/write Excel 2010 xlsx/xlsm files.

5440 questions
1
vote
0 answers

openpyxl - get formula and value at the same time?

Is there any way to get both the cell formula and the cell value in the same load of the file in openpyxl? Currently I have had to do the following: wb_data_only = load_workbook(filename=file, data_only=True, read_only=True) wb_formulas =…
Anubhav
  • 545
  • 3
  • 14
1
vote
1 answer

openpyxl: cells do not evaluate

I have this simple python script: from openpyxl import Workbook book = Workbook() sheet = book.active sheet["A1"]=3 sheet["A2"]=4 sheet["A3"]="=SUM(A1:A2)" book.save("k_test.xlsx") When I open the excel sheet A3 is empty (not calculated).…
ger.s.brett
  • 3,267
  • 2
  • 24
  • 30
1
vote
2 answers

BeautifulSoup, Requests, Dataframe Saving to Excel arrays error

I am a novice at Python and helping out on a school project. Any help is much appreciated. THANKS. I get an error when it gets to the year 2004 and 2003. And it is caused by the result_list list. The error is "ValueError: arrays must all be same…
1
vote
2 answers

Python: pass list to another list but list is blank

I am using python 3.7 with openpyxl. I am attempting to parse data from a worksheet to a list. In this function Originally I was pulling info directly from one spreadsheet into a list and then using openpyxl to paste into another worksheet, however…
oldstudent
  • 25
  • 6
1
vote
1 answer

how to set width of a column in excel to max length of a cell value using openpyxl?

########################## #working with xlsx files # ########################## import openpyxl from openpyxl.styles import Font, PatternFill, Border, Side, Alignment import os import datetime my_cellstatus_headders = ['Server Name','Cell…
kaushik km
  • 39
  • 8
1
vote
3 answers

Copy Python list variable into existing xlsx excel file

I'm new to Python, so please excuse my ignorance. I have tried several different bits of code using openpyxl and pandas, however, can't get anything to work. What I need is to copy the text of an existing list-variable in Python (which is an array…
Retsied
  • 79
  • 8
1
vote
1 answer

How to add a list of data into an excel column using openpyxl?

I'm new to using openpyxl, and I have a list of data I want to add to a specific column/row in excel. I know how to add a value to a specific cell using sheet.append, but this only allows you to change 1 cell to a specific value. Let's say this is…
Conweezy
  • 105
  • 5
  • 15
1
vote
1 answer

Open, edit and save an excel

I want to open an excel file and edit the file. After the edit I want to save the file. Please see below for my current progress. Unfortunately I get an error. I don't know why. Could you please tell me the error and help me to fix it ? Thank you in…
LiaRoller
  • 13
  • 3
1
vote
0 answers

Can't get cell's color.index (openpyxl)

I have xlsx file with some values and I am trying to get the color.index from each cell in this document. The problem is: If cell's color is picked from Styles menu in Excel (for example: 'Bad', 'Good' etc..) the color.index value is 'C6EFCE' which…
unreax
  • 11
  • 3
1
vote
1 answer

How can I automate my code using openpyxl and Pandas?

I have a couple of issues automating my data regarding openpyxl and pandas which is related to the length of the Dataframe DF. The first one is regarding cells. I want to automate each row in which if it only prints the border in the number of rows…
mos
  • 121
  • 1
  • 2
  • 11
1
vote
0 answers

How can I get rid of the "0"s in Python Openpyxl

I have a piece of code and it reads out the cell value of a cell in excel using openpyxl and I want to put those values in an array so I can use the specific value I want. How ever when I put my value in an array it behaves strangely. This is the…
KillerKingTR
  • 9
  • 1
  • 3
1
vote
0 answers

Fastest way to read a large excel file into databricks

So I have been having some issues reading large excel files into databricks using pyspark and pandas. Spark seems to be really fast at csv and txt but not excel i.e df2=pd.read_excel(excel_file, sheetname=sheets,skiprows = skip_rows).astype(str) df…
Tiger_Stripes
  • 485
  • 5
  • 17
1
vote
1 answer

how to load workbook using tempfile using openpyxl

In my flask web app, I am writing data from excel to a temporary file which I then parse in memory. This method works fine with xlrd but it does not with openpyxl. Here is how I am writing to a temporary file which I then parse with xlrd. …
Boosted_d16
  • 13,340
  • 35
  • 98
  • 158
1
vote
2 answers

openpyxl skip row if it contains data

My program is overwriting the first row everytime but i want it to skip every row that has data in it and go to the next row and so on until it finds a completely empty row and then add data there. The data gets added to the correct column but not…
1
vote
1 answer

Rename Excel Tabs

I am trying to rename tabs in an excel spreadsheet however it for one of the tabs it produces this name every time: '# of Behavioral Health Reps (5)1' Not sure why. There is only 1 of these matching tabs in each file. It also does not do it to any…
Tinkinc
  • 449
  • 2
  • 8
  • 21
1 2 3
99
100