openpyxl hides new columns - python

I use openpyxl to read in a xlsx file and later made additions to it before saving it in a new file.
It used to work well on openpyxl 2.1.2 but after installing python on a new computer with the newest version of openpyxl it starts to hide all added columns.
I have tried adding:
ws.column_dimensions['A'].hidden = False
...
ws.column_dimensions['Z'].hidden = False
But that does not change anything.
Any ideas? Having to open up each spreadsheet generated just to unhide and save is kinda annoying.

openpyxl does not hide columns by default. If you think there is a problem then please submit a bug report.

Try to upgrade openpyxl version to 2.3 or later. I have same issue before, upgrade version solved my problem

Related

The ERROR: xlrd.biffh.XLRDError: Excel xlsx file; not supported

Please I'd like to ask you a question about opening an excel file.
Now I'm trying to open it using this program:
data = pd.read_excel(r'C:\Users\Acer\Desktop\OffshoringData.xlsx')
print(data)
The problem is that I found the following error:
**xlrd.biffh.XLRDError: Excel xlsx file; not supported**
What should I do in this case, please??
You need to use a different engine in your pandas.read_excel().
For security reasons xlrd no longer supports .xlsx files, but openpyxl still does.
So you would need to add engine='openpyxl' in your function.
Here's the documentation:
https://pandas.pydata.org/docs/reference/api/pandas.read_excel.html
This error is usually as a result of conflicting versions of the xlrd package and your excel version. Try installing a newer version of xlrd package (v2.0.1) which is able to handle .xlsx files. Seems the version of xlrd you are using is for older versions of excel files.
reference - xlrd python package

Visual Studio Code gives error when using Data Viewer: "Python package 'pandas' is required for viewing data"

I am running a python notebook in VS Code (see image). It runs fine but when I try to inspect a dataframe with the Data Viewer I get:
"Python package 'pandas' is required for viewing data."
The package is installed, otherwise, the code would not work and the data frames would not be present in the variable panel. When I click on "Install" I get: "Error: All data science packages require an interpreter be passed in"
I only have two environments, Anaconda and one created by VS code. I have tried selecting either one and nothing changes, code runs on both and I get the same errors on both.
Any ideas on how to fix this problem?
EDIT: The previous question Viewing data in the VSCode variable explorer requires pandas does not solve my issue. As mentioned above I have selected different environments without fixing it.
EDIT 2: Updating pandas did not fix it either. It was only solved by updating Anaconda, as suggested by Mrinal Roy.
This answer on a similar issue Viewing data in the VSCode variable explorer requires pandas mentioned it was fixed around a year ago.
It seems that the version.release string of pandas I was using includes characters that are not correctly parsed by the extension. They mentioned that it was going to be addressed yesterday in the Insider version. Looking forward to validating.
So, you probably have an older version of Anaconda or VS Code. Otherwise, what version of pandas do you have in both conda environments? VS Code Data Viewer requires pandas package 0.20 or later. Try upgrading it and related packages to the latest and check.

Spyder 4.0.1 dataframe preview [duplicate]

I updated Spyder to 4.0.1 which has a new object explorer, allowing to display arbitrary objects in a tree-like view as well as displaying metadata
Previous versions of Spyder enabled to view Pandas Dataframes in a simple table view when double clicking on the variable in the explorer.
Is there a simple way of accessing this nice old view in Spyder 4.0.1?
(Spyder maintainer here) You need to have Pandas installed in the same Python installation or environment where Spyder is installed. Else Spyder will use the Object explorer to open Dataframes, just as it does with any other kind of Python object.
As per documentation https://www.spyder-ide.org/blog/spyder-variable-explorer/ you can view the dataframe by right clicking on it and selecting the "View with the Object Explorer" option.
Edit: I don't have Spyder 4.0 installed, you can check if this works for you.
Just open up the terminal >> activate the environment that you're working in >> install pandas again. (If you're using conda, install it using conda)
if your like me and just messed up by trying different hotkeys or something just try saving the file and relaunching spyder. (please note this is incase you could see the dataframes in tabular form earlier and it suddenly started displaying it differently.)

Open a workbook in xlwings without making it visible

I am having the same problem as this post, according to the comments of this post this issue was resolved in v0.9.3.
My versions are:
xlwings: v0.11.4
macOS: v10.13.2
python: v3.6.2
Excel for Mac: v15.41
I have attempted the app.books.open(filename) workaround but it makes no difference. Despite being updated past v0.9.3 I'm still unable to open a workbook in headless mode.
Is anyone able to suggest any workarounds or possible bugs?
Thank you.

Import error for openpyxl

I'm very very new to coding and I'm having an issue importing openpyxl into my python program. I imagine the issue is due to where I have it saved on my computer.
I've downloaded other libraries (xlrd, xlwt, xlutils) before and just saved them in my: C:\Python27\ArcGIS10.1\Lib, or C:\Python27\ArcGIS10.1\Lib\site-packages, or C:\Python27\ArcGISx6410.1\Lib, or C:\Python27\ArcGISx6410.1\Lib\site-packages directories and python has been able to "see" them when i import them into a script.
I've done some trolling on the web and it looks like I may be performing the "installation" of openpyxl incorrectly. I downloaded "setuptools-5.7" in order to try to run the setup.py script contained within the openpyxl library, and so far I haven't gotten that to work out.
Since I'm so new to python, I don't really understand some of the other stuff I've been finding about how to correctly install the library, like "pip install" etc.
If anyone has any ideas about how I can install or save or locate the openpyxl library in the easiest fashion (without using other programs that I don't already have), that would be great!
Your import is probably incorrect.
It needs to be.
from openpyxl import workbook

Categories

Resources