Save Screenshot as matlab figure
3 次查看(过去 30 天)
显示 更早的评论
I have excel data. I used below code to capture the screenshot of the excel data.
fileName = 'D:\MATLAB\sample_mat\Temporary_based\jump.xlsx';
h.App = actxserver( 'Excel.Application' );
h.myBook = h.App.Workbooks.Open(fileName); % File name must include path
data = h.myBook.Sheets.Item(1).Range('D7:H14').CopyPicture % Copy from Sheet1
h.App.Quit
Now I want the screenshot to be saved as figure in matlab automatically.
Can anyone help
2 个评论
Image Analyst
2017-1-19
What screenshot? Where did you take a screenshot with that code? And what does "want the screenshot to be saved as figure in matlab automatically." mean? I have no idea. Do you want to have an axes control on a figure in MATLAB and read the screenshot image from disk and display it as an image in the axes control? I'm not sure.
And what does "automatically" mean? Is there another way, like "manual", that you'd like to avoid? Please describe the difference between "automatically" and otherwise.
Please try to use more precise language about what you want done.
Walter Roberson
2017-1-19
I wondered about "What screenshot" too. But then I noticed the CopyPicture which does produce a picture of the data table at the Excel level.
回答(1 个)
Walter Roberson
2017-1-19
I worry that the default format for CopyPicture, xlPicture, might give you back a wmf or mix object. wmf it might be possible to deal with, but I do not know how you would deal with a mix object. I would suggest you specifically ask for xlBitmap instead of letting it default: that would give you a .png, .jpg or .gif result, which would be easier to handle.
As the returned value is not said to be any kind of bitmap directly, I speculate that you might be able to write the returned data to a file as binary, and then imread() from the file.
Unfortunately I do not have Excel available to test with (the cost is too high for virtual machine use :( )
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!