Set password for xlsx file by Python xlsxwirter package - python

I am trying to set password for xlsx file. I use xlsxwriter to package for now to generate the csv file. However, didn't reach any information to set password for the csv file.
I found similar question here. But the openpyxl isn't the package I might gonna to use.
Do anyone know hot to simply set password for xlsx file?
Thanks in advance.

CSV files are plain text - there's no such thing as adding a password.
openpyxl is a package to handle excel files - which aren't csv, so it's not relevant

Related

Obtain textbox value inside shape from Excel in Python

I'm developing a function that allows users to upload .xls or .xlsx files to the server and save data from those files into a database.
I'm using openpyxl and xlrd libraries for reading data from Excel, but for some Excel files which contain text in textbook inside shapes, I'm currently unable to read those values.
I know maybe my question is a duplicate of this: Obtain textbox value from Excel in Python but the solution of the asker of that question is not a general solution.
Does any anyone know how to achieve this?

How can I update workbook links when using pd.read_excel()?

The question is pretty simple, actually.
I'm reading an Excel file using Pandas. When I open it using Office's Excel in my Desktop I'm prompted to Enable Content and then Update Links [that is, update values in those cells importing information from cells in other workbooks and xslx files], so it reads other files in some other folders.
While using pd.read_excel('filename') however that option is not available, and I'm afraid it's importing the data previously contained in the spreadsheet without updating it. Is there a workaround?

How to fix [Errno13] permission denied when trying to read excel file?

I tried the following code to be able to read an excel file from my personal computer.
import xlrd
book = xlrd.open_workbook('C:\\Users\eline\Documents\***\***\Python', 'Example 1.xlsx')
But I am getting the error 'Permission denied'. I am using windows and if I look at the properties of the directory and look at the 'Security' tab I have three groups/users and all three have permissions for all the authorities, except for the last option which is called 'special authorities' (as far as I know I do not need this authority to read the excel file in Python).
I have no idea how to fix this error. Furthermore, I do not have the Excel file open on my computer when running the simulation.
I really hope someone can help me to fix this error.
Sometimes, it is because you try to read the Excel file while it is opened. Close the file in Excel and you are good to go.
book = xlrd.open_workbook('C:\\Users\eline\Documents\***\***\Python', 'Example 1.xlsx')
You cannot give path like this to xlrd. path need to be single string.
If you insist you can use os module
import os
book = xlrd.open_workbook(os.path.join('C:\\Users\eline\Documents\***\***\Python', 'Example 1.xlsx'))
[Errno13] permission denied in your case is happening because you want to read folder like a file which is not allowed.
I ran into this situation also while reading an Excel file into a data frame. To me it appears that it is a Python and/or Excel bug which we should probably not hide by using os.path.join even if that solves the problem. My situation involved an excel spreadsheet that links cells to another CSV file. If this excel file is freshly opened and open when I try to read it in python, it fails.
Python reads it correctly if I do an unnecessary save of the open Excel file.

How do I read/write both xlsx and xls files in Python?

I have a web application (based on Django 1.5) wherein a user uploads a spreadsheet file.
I've been using xlrd for manipulating xls files and looked into openpyxl which claims to support xlsx/xlsm files.
So is there a common way to read/write both xls and xlsx files?
Another option could be to convert the uploaded file to xls and use xlrd. For this I looked into gnumeric and ssconvert, this would be favorable since all my existing code in written using xlrd and I will not have to change the existing codebase.
So should I change the library I use or go with the conversion solution?
Thanks in advance.
xlrd can read both xlsx and xls files, so it's probably simplest to use that. Support for xlsx isn't as extensive as openpyxl but should be sufficient.
There's a risk of losing information in converting xlsx to xls because xlsx files can be much larger.

Can I password protect excel work book with XLRD?

I want to deliver an EXCEL application and I'm finding out whether I can password protect a whole work book with Python and XLRD libray? Does any one around know how I can do this with the XLRD on python?
As the README says, in the "Outside the current scope" section:
Unlikely to be done:
Handling password-protected (encrypted) files.
On top of that, note that xlrd is only for reading data from Excel files, not generating or modifying them (xlwt does that). So, even if it were possible, xlrd wouldn't be the way to do it.

Categories

Resources