How Can I change the range of a excel chart using actxserver?

3 ビュー (過去 30 日間)
Adriano
Adriano 2017 年 5 月 16 日
コメント済み: Adriano 2017 年 5 月 19 日
This is my code:
excel = actxserver('Excel.Application');
excel.Visible = true;
excel.DisplayAlerts = false;
filename13 = 'C:\Dropbox\Idenglobal\Comparacion peers.xlsx';
pee = excel.Workbooks.Open(filename13);
peesheet = pee.Sheets.Item('Shortlist Credit Suisse');
In that sheet there is only a chart whith datas in the range "Q2:W67" . I would like to extend this range to "Q2:W69". How Can I do? Many thanks!!!

採用された回答

Manish Annappa
Manish Annappa 2017 年 5 月 18 日
編集済み: Manish Annappa 2017 年 5 月 18 日
As per the description, you would like to change the data range for an Excel Chart using actxserver in MATLAB. Below is a code snippet that achieves the same.
excel = actxserver('Excel.Application');
excel.Visible = true;
excel.DisplayAlerts = false;
filename13 = 'C:\Dropbox\Idenglobal\Comparacion peers.xlsx';
pee = excel.Workbooks.Open(filename13);
peesheet = pee.Sheets.Item('Sheet1');
pC = peesheet.ChartObjects(1).Chart
pC.SeriesCollection(1).Values = peesheet.Range('W2:W69');
pC.SeriesCollection(1).XValues = peesheet.Range('Q2:Q69');
In the above code snippet Values corresponds to Y axis range of values. Similarly XValues corresponds to X axis range of values. By changing the range to 69, the previous range will be reset.
Also,I am assuming this chart will be the first chart in the Excel sheet selected (peesheet.ChartObjects(1).Chart).
Refer to the link below for more information on Series object properties: https://msdn.microsoft.com/en-us/library/office/ff838988.aspx
  1 件のコメント
Adriano
Adriano 2017 年 5 月 19 日
Many many thanks!! It works perfectly!

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by