append (a row) to the end of an excel sheet

조회 수: 43 (최근 30일)
Moh. Saadat
Moh. Saadat 2020년 4월 5일
편집: Marcel 2022년 11월 30일
Hi,
I would like to know if there is any way to simply append to the next available row in an existing excel sheet. I know I can do the append with the writematrix function by specifying the 'Range' property.
writematrix(matrix_to_add, filename, 'Range', 'A1:D20'); %% this adds the matrix_to_add variable in the specified block
However, I do not wish to explicitly specify the range. The rows being added are quite long: 1000 elements. Hence, specifying range will be inconvenient. Thus, the solution I am looking for will simply add the row to the 51st row in the excel sheet if there are already 50 rows in the sheet.
Thanks!
  댓글 수: 3
Brian Bean
Brian Bean 2021년 11월 20일
Is there a way to do the same thing, without altering the column width or any previous rows. When I have merged cells in row 1, use writemateix, row 1 cells becomes unmerged. Thanks!
Walter Roberson
Walter Roberson 2021년 11월 21일
If I recall correctly, with new enough versions of MATLAB, if you use writecell() then it will not change the format of existing cells.

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

답변 (2개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 11월 21일
This is how you can get it:
FName = 'DATA.xlsx';
for ii=1:5
writematrix(magic(3), FN, 'WriteMode','append')
end

Marcel
Marcel 2022년 11월 18일
편집: Marcel 2022년 11월 30일
This is how im appending text to a xls file. cellstr("Test") would be your data
writecell(cellstr("Test"), "file.xls", 'WriteMode','append');

카테고리

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