Read the last row of excel spreadsheet using actxserver
조회 수: 8 (최근 30일)
이전 댓글 표시
Hi all,
I have the following issue.
I use actxserver in order to link an Excel spreadsheet with Matlab and create graphs automatically. Below is the script that i am using
%% Link to Excel spreadsheet
% Start Excel and open Workbook
excel = actxserver('Excel.Application');
wb = excel.Workbooks.Open('C:\Users\ilimin\Desktop\test2.xlsx'); % Copy in the '' the location of the spreadsheet
% Makes the created sheet visible
excel.Visible = true;
%% Speed Graph
% Creates a blank chart in another Sheet
chart1 = wb.Charts.Add;
% Set the range of the data and the source ('Name of the Sheet')
chart1.SetSourceData(wb.Worksheets.Item('Sheet1').Range('$A$2:$A$112, $O$2:$O$112298'));
So far it works great but I would like to ask if there is any way of detecting the last row of the Excel spreadsheet without do it manually, and after this use it in the last command (char1.SetSourceData).
Thank you very much
Ilias
답변 (1개)
Fangjun Jiang
2022년 9월 22일
I hope this debug message gives you a clue.
K>> Workbook.Sheets.Item(1).UsedRange.Address
ans =
'$A$1:$AY$83'
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!