I have an .xlsx file I generate using xlsxwriter in a python script (version 2.7). I am trying to find a way to convert a worksheet in the file to a PDF format. I have not found a module that suits my needs yet.. simple, lightweight, and is able to be installed using pip.
Any suggestions, let's hear them! Thanks to all!
Try using a comdination of openpyxl and PDFwriter as shown in this example this example
Related
I want to generate a pdf report to a specific student showing all of his grades in a determined period of time. I have very little experience with python and have no idea where to start.
Thks!
you need to use the library:pyxlsb to read the excel file,
and the library: PyFPDF to generate pdf files
there is many libraries not only these
after installing these libraries with pip:
pip install fpdf
pip install pyxlsb
but you need to write script to extract the data from the excel file, and also for generating the pdf file
and you can apply the same script for other student with the data excel format
greetings
I want to modify a string in a xlsx file using xlrd and xlutils.
There were solutions, one from stackoverflow and other from YouTube for xls files.
However, these solution works only for xls format. I tried using these for xlsx format but that corrupts the file.
Are there solutions when using the xlsx file?
Or should I use other packages to solve this?
-Best Regards
xlutils relies on xlrd (to read files) and xlwt (to write files) packages as stated here.
xlwt can only write .xls formatted files.
For reading .xlsx formatted files one should use openpyxl or XLRD.
For writing to .xlsx formatted files one should use openpyxl or xlsxwritter.
Alternatively, if you will be running the code on a machine that has Microsoft Excel installed, you might want to try xlwings.
Gotcha: According to jmcnamara xlrd and xlsxwritter formats are different object types, thus, despite the fact that both can be used on .xlsx files, one would need to write a translator to be able to write a xlrd formatted file using xlsxwritter.
I have searched into google and found some contradiction. Does xlwt support xlsx file (MS office 2007). I heard that xlwt 0.7.4 support xlsx file. Does anyone tried xlsx file writing operation with xlwt 0.7.4
The purpose of this question is,I do not have permission to install library if I need to install I need to provide more detail info. I need to write xlsx file in python.So if anyone has done similar thing it will help to provide better inforamtion
I have looked into this wiki page. https://pypi.python.org/pypi/xlwt But did not find that it support xlsx file
or Should I use https://pypi.python.org/pypi/openpyxl for writing xlsx File
openpyxl is guaranteed to write xlsx files. From a cursory read through some of the xlwt code and docs/examples, I don't think xlwt supports xlsx. If openpyxl does what you need it to do, why look elsewhere?
Edit: with xlwt version 0.7.4 I attempted to save a file as sample.xlsx. Upon attempting to open it I got a not valid error message, so no .xlsx files for now.
The xlwt module doesn't support the xlsx format. The xlsx file format is completely different from the xls format supported by xlwt.
As an alternative have a look at XlsxWriter which is a Python module for creating xlsx files.
It supports a lot of Excel features. Have a look at the documentation or start with the examples.
2021 update: xlrd has reached End of Life (due to security concerns in the xls format).
You can use openpyxl for reading and writing data.
You may also use xlsxwriter for writing, if you’re writing huge files and write performance is critical. See: https://openpyxl.readthedocs.io/en/stable/performance.html
2019 update: xlwt doesn't support xlsx Format.
XlsxWriter is 100% compatible with xlsx, well-maintained and has a good reputation.
For reading xlsx files, you can use xlrd.
You can also use Pandas if you've read+write requirements and want to create graphs and charts. (Pandas internally uses XlsxWriter modules to write the files).
P.S. - The last x in xlsx stands for XML. xlsx is a zipped Open XML file.
Use xlsx wherever possible. xls is the old (proprietary) format, which doesn't have some advanced features like conditional formatting or freezing col/rows etc.
Is there any existing Python library that can validate data in Excel format? Or what kind of keyword should I use to search such an open source project? Thanks.
[Disclosure: I'm the author of xlrd]
xlrd allows you to extract data from XLS files. XLSX support is in alpha testing; e-mail me if you need it. You get told precisely what is in each cell (Excel cell type and value). It runs on Python 2.1 to 2.7 on any platform. You don't need Windows. You don't need Excel to be installed on your machine. Start with the tutorial found here.
I`m not sure what are you looking for, but there are three libraries that, in combination, can read and write excel files:
xlrd
xlwt
xlutils
They read and save binary excel archives both in windows and linux. There are functions for formatting data and styles.
If you want to check if some data column is in a given format you can do it with these libs (basically with xlrd).
how do i insert few row in an existing excel file using python? the excel file maybe be of any excel version. On windows that could have been possible by using win32com.client...but i need to make the changes in the linux environment. how can i do it?
you can use pyExcelerator. the package comes with example demos to write excel files
I'm looking into this myself and found https://bitbucket.org/ericgazoni/openpyxl/wiki/Home .
It is a new library that allows editing xlsx files.