我们可以将Excel图表转换为图像并将其保存为图像文件吗?将Excel图表转换为图像
0
A
回答
1
This article介绍了如何使用VBA将Excel图表导出为图像。
0
我不得不在我的一个项目中做出类似的事情。它将图表从应用程序转换为运行实时数据的仪表板。 我的解决方案最终被通过ODBC连接到应用程序的数据库和逆向工程一步用VBA
步骤的图表(报告)的生成:
1. do an automatic refresh of data by setting a refresh interval in the Excel Data Query
2. extract the information from the Excel worksheet with VBA
3. generate Pivot Tables and Pivot Charts upon the information extracted with VBA
4. convert the Pivot Charts or Range of Cells(=Tables) to Images and Paste them above the Chart Objects in the Excel Worksheets
5. cut area(s) from the Worksheets (that contained the chart or tables) by giving dimensions and save these as images
6. read the images saved at the previous stage via a webpage (depending on its additional content either static-.html or dynamic
.aspx)
7. set a refreshment time in the webpage source, and there is the dashboard
正如你可以在上面看到,我做不是将图表转换为图像,而是将包含图表的图表区域转换为图像。
这是VBA代码,可以帮助你:
Sub Pivot_Chart_And_Table_of_Auftragsart_To_Image()
'the code for selecting successively the areas of Pivot Table and Pivot Chart and save them as image file types .jpg to a defined directory path
'below you set the Range(=Area in the Worksheet) you want to export to file
Dim rgExp As Range
Set rgExp = Range("A1:E5")
''' Copy range as picture onto Clipboard
rgExp.CopyPicture Appearance:=xlScreen, Format:=xlBitmap
''' Create an empty chart with exact size of range copied
With ActiveSheet.ChartObjects.Add(Left:=rgExp.Left, Top:=rgExp.Top, _
Width:=rgExp.Width, Height:=rgExp.Height)
.Name = "nameOfTheObjectHerewithGenerated"
.Border.LineStyle = xlNone 'this removes the border line of the temporary Chart Object
.Activate
End With
''' Paste into chart area, export to file
ActiveChart.Paste
ActiveSheet.ChartObjects("nameOfTheObjectHerewithGenerated").Chart.Export "C:\whateverDirectoryYouWish\nameOfImage.jpg"
相关问题
- 1. 将jqplot图表转换为图像
- 2. 将.png图像转换为.gif图像
- 3. 将图像转换为灰度图像
- 4. 将PIL图像转换为VIPS图像
- 5. 将PDF转换为图像
- 6. 将varbinary转换为图像
- 7. 将HTML转换为图像
- 8. 将图像转换为JSON
- 9. 将Blob转换为图像
- 10. 将Android.Graphics.Bitmap转换为图像
- 11. 将HtmlElement转换为图像?
- 12. 将JPanel转换为图像
- 13. 将netcdf转换为图像
- 14. 将Swf转换为图像
- 15. 将图像转换为DrawingImage
- 16. 将ListBoxItem转换为图像
- 17. 将图像转换为流
- 18. 将HTML表转换为图像文件
- 19. 将图像转换为图形在c#
- 20. 将位图转换为图像
- 21. 将图像转换为位图
- 22. Django将url转换为图像/视图
- 23. 将字节转换为位图图像
- 24. 将位图转换为javascript图像
- 25. 将PictureBox图像转换为位图
- 26. 如何将位图转换为图像
- 27. 将闪存图转换为图像/ pdf
- 28. 如何将图像转换为图标?
- 29. 如何将图像转换为图像的ASCII表示形式?
- 30. 将图像列表转换为图像数组
只是为别人所希望创建一个图像注释。如果您使用的是Excel 2010,则可能必须在将图表导出为图像之前激活图表oChart.Activate。 – nickfinity 2012-08-01 19:59:11
您不应该激活图表。 Export方法与图表一起使用,而不是图表对象(这是人们发现他们需要激活图表以使某些工作起作用时的常见问题)。 – 2015-07-18 15:35:20