这就是我需要做的事情:
我有#1和#2工作,但我坚持#3。
我为#3尝试的东西要么把它放在一个单独的新工作表中(即使我指定活动工作表)或将它放在正确的工作表中,但我不知何地丢失了图表的句柄而无法分配ChartType
没有收到错误。
答案 0 :(得分:0)
下面是Mathworks支持团队提供的代码(下面提供的链接),用于在Excel工作表中插入MATLAB图形。您可能需要将工作表更新为预期的工作表。
switch (step.intValue) {
case 1: //call step2; break;
case 2: //call step3; break;
case 3: //call step4; break;
case 4: //call step5; break;
...
case x: // finish, remove kvo on step
}
Link上面的回复:
H K.Berg的函数% Create sample image from figure
img = 'figure1.png';
plot(1:10);
print('-dpng', img);
% Get handle to Excel COM Server
Excel = actxserver('Excel.Application');
% Set it to visible
set(Excel,'Visible',1);
% Add a Workbook
Workbooks = Excel.Workbooks;
Workbook = invoke(Workbooks, 'Add');
% Get a handle to Sheets and select Sheet 1
Sheets = Excel.ActiveWorkBook.Sheets;
Sheet1 = get(Sheets, 'Item', 1);
Sheet1.Activate;
% Alternative 1 BEGIN.
% Get a handle to Shapes for Sheet 1
Shapes = Sheet1.Shapes;
% Add image
Shapes.AddPicture([pwd '\' img] ,0,1,400,18,300,235);
% Alternative 1 END.
% Alternative 2 BEGIN.
% Add image
Sheet1.invoke('Pictures').Insert([pwd '\' img]);
% Alternative 2 END.
% Save the workbook and Close Excel
invoke(Workbook, 'SaveAs', [pwd '\myfile.xls']);
invoke(Excel, 'Quit');
% In the above code (Alternative 1), Excel's Shapes.AddPicture Method is used to insert a figure in the Excel Sheet - Mathworks.
- 将一个或多个图像传输到新的或现有的xlsx文件中)可以来自MATLAB Central的downloaded