在 Excel 中打印 MATLAB 图窗并调整其大小
我在 MATLAB 中有两个图形,其句柄为 hFig1
和 hFig2
。我想将它们打印到 Excel 中的特定单元格(单元格 E3 和 I3),并将它们重新调整为 [2 英寸 x 3 英寸]。
我尝试过使用 .AddPictures
对象处理程序和 print -dmeta
,但我找不到实现所有三个目标的方法。
我同时也在向excel写入数据,并且由于发送的数据行很多,所以我希望有一种不需要通过ActiveXServer不断调用excel的方法。
有没有人有解决此类问题的好方法或资源?
I have two figures in MATLAB with the handles hFig1
and hFig2
. I would like to print them to specific cells in Excel (cells E3 and I3) and reshape them to each be [2in x 3in].
I have tried using the .AddPictures
object handler and using print -dmeta
, but I can't find a way to achieve all three of my objectives.
I am also writing data to excel at the same time and because there is a lot of data lines being sent, I was hoping to have a method that didn't require continually invoking excel with the ActiveXServer.
Does anyone have a good method or resource for this kind of problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以最轻松地将 MATLAB 数字添加到 Excel,如下所示:
我不确定将图像设为 2 英寸 x 3 英寸到底是什么意思。是屏幕上的尺寸吗?以什么分辨率?还是打印时的尺寸?
您可以直接以点为单位指定图像的大小和位置:
但如果您想要以英寸为单位,则需要一种转换为点的方法,具体取决于其显示方式。
您提到您不断使用
actxserver
调用 Excel;每次写入每条数据时都要一遍又一遍地连接吗?您可能不需要这样做 - 更有可能的是,您可以保持单个连接打开并将每条数据写入其中,然后保存文件并关闭连接。Excel 对象模型的一个很好的参考资源是 Microsoft 文档。但这并不容易阅读:)
You can add MATLAB figures to Excel most easily like this:
I'm not sure exactly what you mean by making the images 2in by 3in. Is that the size on screen? At what resolution? Or is it the size when printed?
You can specify the size and position of the image in points directly:
But if you want it in inches you'll need a way of converting to points, depending on the way it's displayed.
You mention that you're continually invoking Excel with
actxserver
; are you connecting over and over again each time you write each piece of data? You probably don't need to do that - more likely you could keep a single connection open and write each piece of data to it, then save the file and close the connection.A good reference resource for the Excel Object Model is the Microsoft documentation. It's not an easy read though :)