I have been trying to export the charts from Excel as an image file (JPG or ING) in Python. I am looking at the WIn32com. Here is what I have till now.
import win32com.client as win32
excel = win32.gencache.EnsureDispatch("Excel.Application")
wb = excel.Workbooks.Open("<WORKSHEET NAME>")
r = wb.Sheets("<SHEET NAME>").Range("A1:J50")
# Here A1:J50 is the area over which cart is
r.CopyPicture()
This is where I am stuck. I need to copy the selected range to a file now. Any help or pointers towards the doc can help me a lot.
I have modelled the above code based on the following VBA script:
Sub Export_Range_Images()
' =========================================
' Code to save selected Excel Range as Image
' =========================================
Dim oRange As Range
Dim oCht As Chart
Dim oImg As Picture
Set oRange = Range("A1:B2")
Set oCht = Charts.Add
oRange.CopyPicture xlScreen, xlPicture
oCht.Paste
oCht.Export FileName:="C:empSavedRange.jpg", Filtername:="JPG"
End Sub
Code Snippet from : http://vbadud.blogspot.com/2010/06/how-to-save-excel-range-as-image-using.html
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…