我們可以將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. 將Excel圖表轉換爲VB.Net中的圖像
- 2. 將jqplot圖表轉換爲圖像
- 3. Excel圖像轉換
- 4. 將圖像轉換爲灰度圖像
- 5. 將圖像URL轉換爲圖像Android
- 6. 將PIL圖像轉換爲VIPS圖像
- 7. 將圖像轉換爲色度圖像
- 8. 將.png圖像轉換爲.gif圖像
- 9. 將圖像轉換爲流
- 10. 將varbinary轉換爲圖像
- 11. 將圖像轉換爲DrawingImage
- 12. 將圖像轉換爲ushort?[]
- 13. 將BufferedInputStream轉換爲圖像
- 14. 將Swf轉換爲圖像
- 15. 將UITextView轉換爲圖像
- 16. 將Blob轉換爲圖像
- 17. 將Android.Graphics.Bitmap轉換爲圖像
- 18. 將ListBoxItem轉換爲圖像
- 19. 將HTML轉換爲圖像
- 20. 將圖像轉換爲Base64String
- 21. 將HtmlElement轉換爲圖像?
- 22. 將圖像轉換爲JSON
- 23. 將PDF轉換爲圖像
- 24. 將ppt轉換爲圖像
- 25. 將xls轉換爲圖像
- 26. 將netcdf轉換爲圖像
- 27. 將JPanel轉換爲圖像
- 28. 將gridview轉換爲圖像
- 29. 將圖像列表轉換爲電影
- 30. 將HTML錶轉換爲圖像文件
只是爲別人所希望創建一個圖像註釋。如果您使用的是Excel 2010,則可能必須在將圖表導出爲圖像之前激活圖表oChart.Activate。 – nickfinity 2012-08-01 19:59:11
您不應該激活圖表。 Export方法與圖表一起使用,而不是圖表對象(這是人們發現他們需要激活圖表以使某些工作起作用時的常見問題)。 – 2015-07-18 15:35:20