glexey / excel2img Goto Github PK
View Code? Open in Web Editor NEWSave ranges from Excel documents as images
License: Apache License 2.0
Save ranges from Excel documents as images
License: Apache License 2.0
Hi,
Was using excel2img for saving pivot charts in excel to image .png format. My doubt is my pivot table and pivot charts both are on the same sheets. When I execute below statement:
ex.export_img('foo.xlsm', 'customer.png', 'customer_pivot', None)
An image is generated with only pivot table. Pivot chart is not saved as image. So kindly help we with this as I want to know how I can loop over above code to save different charts in my xlsx file.
Thanks in advance.
Regards,
Husain. S.
Can you add support for Linux??
encounter an error when sheet name contains single quotation mark(')
I have xlsx file with one sheet - "Известие-2".
by default its raise error
Failed locating range Известие-2!A1:O38
but when i simple rename sheet to "Известие" - all works
I got this error when converting a sheets
excel2img.export_img("t956.xlsx",'image.png','Sheet1!C3:J26')
Traceback (most recent call last):
File "G:\Install Location\Python\Python38-32\lib\site-packages\excel2img\excel2img.py", line 88, in export_img
rng = excel.workbook.Sheets(page).UsedRange
File "C:\Users\ARI\AppData\Local\Temp\gen_py\3.8\00020813-0000-0000-C000-000000000046x0x1x6\Sheets.py", line 113, in call
ret = self.oleobj.InvokeTypes(0, LCID, 2, (9, 0), ((12, 1),),Index
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147352565), None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "", line 1, in
File "G:\Install Location\Python\Python38-32\lib\site-packages\excel2img\excel2img.py", line 90, in export_img
raise Exception("Failed locating used cell range on page %s"%page)
Exception: Failed locating used cell range on page Sheet1!C3:J26
This is the first time I'm using excel2img and see below error every time I run it
Python version: 3.8.2
Traceback (most recent call last):
File "C:\Users\Admin\Desktop\Python\DailyWhatsAppSummaryAutomation\DailySummary.py", line 37, in
excel2img.export_img("Master.xls", "Master.png", "Sheet1", "A1:B5")
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\excel2img\excel2img.py", line 122, in export_img
im.save(fn_image, fn_image[-3:])
AttributeError: 'NoneType' object has no attribute 'save'
I have 10 sheets in workbook. Converting takes more than 2 minutes. Does it support multithread conversion?
Just wanted to let you know, when installing with pip using python3.5 I had use pip install pypiwin32
to get it installed. I tried pywin32
but it was't available through pip and the version I downloaded from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pywin32 did not help.
[Edit: forgot to say, so far works great with python 3.5.2]
When trying to export a range of cells that contain a chart, the image chart cames with two white borders as shown in the image
The script is simply:
import excel2img
# Save as PNG the range of used cells in test.xlsx on page named "Sheet1"
excel2img.export_img("template.xlsx", "test.png", "Sheet1", "Sheet1!F2:M17")
I even tried to put white background, without borders and make the chart surpass a little the cells, but that two borders came anyway.
Hello the tool works great, but after every saved image, a "beep" sound is played.
Is there any possibility to deactivate that sound?
Patrick
Having difficulty installing the excel2img on win10 running python 3.8-32
did the followings:
1- python3 -m pip install --upgrade pip
2- python3 -m pip install --upgrade Pillow
3- installing excel2img, by invoking "pip install excel2img", getting into this issue :
Collecting pywin32>=223 (from pypiwin32->excel2img)
Could not find a version that satisfies the requirement pywin32>=223 (from pypiwin32->excel2img) (from versions: )
No matching distribution found for pywin32>=223 (from pypiwin32->excel2img)
What could be the issue ? did pip install win32, to ensure pywin32 needed, but seems pywin32 is builtin Python 3.8
Thanks
Matthew
Hi
# python3 excel2img.py
Traceback (most recent call last):
File "excel2img.py", line 1, in <module>
import excel2img
File "/home/ali/git_proj/test/excel2img.py", line 5, in <module>
excel2img.export_img("test.xlsx", "test.png", "Sheet1", None)
AttributeError: module 'excel2img' has no attribute 'export_img'
Traceback (most recent call last):
File "D:\tools\Python310\lib\tkinter_init_.py", line 1921, in call
return self.func(*args)
File "E:\work\study\pythonWorkspace\excel2image\app.py", line 43, in do_convert
convertExcelToImg.convert_excel_to_image(excel_files, range_names)
File "E:\work\study\pythonWorkspace\excel2image\convertExcelToImg.py", line 67, in convert_excel_to_image
excel2img.export_img(excel_files[i], img_save + image_name + ".jpg", sheet_name, range_names[i])
File "E:\work\study\pythonWorkspace\excel2image\venv\lib\site-packages\excel2img\excel2img.py", line 122, in export_img
im.save(fn_image, fn_image[-3:])
File "E:\work\study\pythonWorkspace\excel2image\venv\lib\site-packages\PIL\Image.py", line 2418, in save
save_handler = SAVE[format.upper()]
KeyError: 'JPG'
Good afternoon, I use this library to process the excel file and send it to the telegram chat. If you run a script with a telegram bot (a script is run from it to create an image), everything works correctly, but if the telegram bot is running in the background, then an error occurs.
Failed to open C:\Users\admin\Desktop\Work\Parser\Telegram_AUTO\Rating\Листы ожидания (отмененные записи КР) 2024-03-25_12.06.xlsx
Строка кода:
excel2img.export_img(save_path, photo_screan1, "Свод Взрослые", None)
Known issue with copy picture apparently.
I am currently working on a Python script that saves screenshots from an Excel file using the excel2image module.
My code is pretty easy:
import excel2img excel2img.export_img(Workpath + "/" + "CB_TEMP.xlsx", "alarm_BB1.png", "Deckblatt", "A2:C20")
Unfortunately I always get the following error message:
`Unfortunately I always get the following error message:
AttributeError Traceback (most recent call last)
in
----> 1 excel2img.export_img(Workpath + "/" + "CB_TEMP.xlsx", "alarm_BB1.png", "Deckblatt", "A2:C20")
~\anaconda3\lib\site-packages\excel2img\excel2img.py in export_img(fn_excel, fn_image, page, _range)
111
112 # See http://stackoverflow.com/a/42465354/1924207
--> 113 for shape in rng.parent.Shapes: pass
114
115 xlScreen, xlPrinter = 1, 2
~\anaconda3\lib\site-packages\win32com\client_init_.py in getattr(self, attr)
471 args=self.prop_map_get.get(attr)
472 if args is None:
--> 473 raise AttributeError("'%s' object has no attribute '%s'" % (repr(self), attr))
474 return self.ApplyTypes(*args)
475
AttributeError: '<win32com.gen_py.Microsoft Excel 16.0 Object Library.Range instance at 0x2460934736048>' object has no attribute 'parent'`
I have already tried several workarounds but I can't get it to work. Sometimes it works like magic, but mostly only after a reboot and deleting the data in C:/Users/patrick/AppData/Temp/gen_py.
I have a feeling something is clashing in the code with the win32com module I use in a function before to convert an XLSB file to an XLSX file:
def ConvertExcel(excel_filepath, Workpath): excel = win32com.client.gencache.EnsureDispatch('Excel.Application') xlsb_doc = excel.Workbooks.Open(os.path.abspath(excel_filepath)) excel_sheets = os.path.abspath(Workpath) + "\\CB_TEMP.xlsx" xlsb_doc.SaveAs(excel_sheets, 51) xlsb_doc.Close() excel.Quit() del excel return excel_sheets
Kind regards,
Patrick
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.