Save Screenshot as matlab figure

4 views (last 30 days)
Divya
Divya on 19 Jan 2017
Commented: Walter Roberson on 19 Jan 2017
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 Comments
Image Analyst
Image Analyst on 19 Jan 2017
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
Walter Roberson on 19 Jan 2017
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.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 19 Jan 2017
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 :( )

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!