필터 지우기
필터 지우기

Excel - Clearing Sheet Content

조회 수: 20 (최근 30일)
Thulasi Durai Durai Samy
Thulasi Durai Durai Samy 2012년 6월 28일
Hello I have created fle name 'MAT.XLS'
I need to clear the content of 'sheet1' in MAT.XLS fle through matlab, I used ActiveXSERVER command
Excel = actxserver('Excel.Application');
Workbook = Excel.Workbooks.Open(strcat(pwd,'\MAT.xls'));
% Make the application invisible
set(Excel, 'Visible', 0);
% Make excel not display alerts
set(Excel,'DisplayAlerts',0);
% Get a handle to Excel's Workbooks
Workbooks = Excel.Workbooks;
Sheets = Excel.ActiveWorkBook.Sheets;
[type, sheet_names] = xlsfinfo(strcat(pwd,'\MAT.xls'));
current_sheet = get(Sheets, 'Item', 1);
invoke (current_sheet, 'Activate');
How do I clear the contents of the sheet1
Can somebody help me.

채택된 답변

Image Analyst
Image Analyst 2012년 6월 28일
Here's a snippet of code I used to clear the comments.
thisSheet = Excel.ActiveSheet;
% Get a reference to the cell at this row in column A.
cellReference = sprintf('%s%d', columnLetterCode, startingRow);
theCell = thisSheet.Range(cellReference);
% You need to clear any existing comment or else the AddComment method will throw an exception.
theCell.ClearComments();
I imagine it would be
theCell.Clear();
or something similar. Give it a try.
  댓글 수: 1
Thulasi Durai Durai Samy
Thulasi Durai Durai Samy 2012년 6월 29일
Hi Thanks for your comments, it works I have one more query, I need to append sheets to existing excel file, but using following it addes to the first. Say for example if their are three sheets namely "Sheet 1, Sheet 2 Sheet 3' the newly added Sheet 4 is coming in front of first sheet. But I want to append at the last, any possible way to do this
ExcelWorkbook = Excel.workbooks.Add;
%For New Work Sheet
ExcelWorkbook.Sheets.Add();
Thanks in advance

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

추가 답변 (0개)

카테고리

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