필터 지우기
필터 지우기

Delete excel row using matlab

조회 수: 2 (최근 30일)
Nagham Kabbara
Nagham Kabbara 2015년 11월 12일
댓글: Nagham Kabbara 2015년 11월 16일
hi, i am trying to delete one row from a specific excel sheet (i want to delete the whole row i don't want to clear the values)
Excel = actxserver('Excel.Application');
Workbook = Excel.Workbooks.Open(filepath);
sheet1=Excel.Worksheets.get('Item',mysheet);
sheet1.Rows.Item(nbrow).Delete
Workbook.Save;
Workbook.Close;
delete(Excel);
but when i look into the excel the row isn't deleted!! am i missing something here??

답변 (1개)

Image Analyst
Image Analyst 2015년 11월 12일
Make Excel visible:
Excel.Visible = true;
Then set a breakpoint on the .delete line and check by looking in Excel itself if the row is deleted when you stop on the delete line.
Or try it this way:
rangeReference = sprintf('A%d..Q200', rowNumber); % Whatever range you want....
Excel.Range(rangeReference).Select;
worksheets.Item(2).Range(rangeReference).Delete;
Excel.Range('A1').Select; % Set current cell to A1
  댓글 수: 1
Nagham Kabbara
Nagham Kabbara 2015년 11월 16일
my method still didn't work (i don't know why honestly), so i had to use the function you suggested and it worked. thanks!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by