フィルターのクリア

How do you set the dimensions of an excel plot using activex from MATLAB?

6 ビュー (過去 30 日間)
Scott
Scott 2012 年 4 月 25 日
編集済み: Walter Roberson 2021 年 5 月 29 日
I have constructed a xyscatter plot in excel using activex from matlab code but cant figure out how to dimension it. Here is the code that I have:
Workbooks = Excel.Workbooks;
Workbook = Workbooks.Add;
Sheets = Excel.ActiveWorkBook.Sheets;
sheet1 = get(Sheets, 'Item', 1);
Activesheet = Excel.Activesheet;
Range = 'A1:B10';
Data(:,1) = 1:10';
Data(:,2) = Data(:,1).^2;
ActivesheetRange = get(Activesheet,'Range',Range);
set(ActivesheetRange, 'Value', Data);
Chart = invoke(Workbook.Charts,'Add');
Excel.ActiveChart.ChartType = 'xlXYScatterLinesNoMarkers';
invoke(Chart, 'SetSourceData', ActivesheetRange);
Chart.Location('xlLocationAsObject', 'Sheet1');

採用された回答

Scott
Scott 2012 年 4 月 26 日
I found what works:
Excel.ActiveChart.Parent.Top = 50;
Excel.ActiveChart.Parent.Left = 500;
Excel.ActiveChart.Parent.Width = 600;
Excel.ActiveChart.Parent.Height = 300;
Thanks for your help.

その他の回答 (1 件)

Richard de Garis
Richard de Garis 2012 年 4 月 26 日
I'm going from memory here but for sizing, you might try:
Chart.ChartArea.Height = 100; % units are points, I think
Chart.ChartArea.Width = 100;
For positioning from the top left-hand corner of Cell A1, you might try:
Chart.ChartArea.Top = 100;
Chart.ChartArea.Left = 100;
If these don't work, it maybe because your Chart object is an Excel ChartObject that is the container for an Excel Chart object. I know, it's terribly confusing, but basically it means instead of using:
Chart.
in the above, you need to use:
Chart.Chart.
  1 件のコメント
Scott
Scott 2012 年 4 月 26 日
I tried both but i get the following error:
Error: Object returned error code: 0x800A01A8
Error in junk1 (line 28)
Chart1.ChartArea.Height = 100;
I tried with both your suggestions and I get the same thing.
Any other suggestions or do you have an example? Thanks

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeActiveX についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by