about write data to the first sheet of excel

조회 수: 3 (최근 30일)
wenchao zhang
wenchao zhang 2024년 7월 1일
댓글: wenchao zhang 2024년 7월 1일
hello, i want wrtie specific data to several sheet of the excel, and i have named each sheet, but i find may new target sheet will added after sheet1, how i can replace sheet1

채택된 답변

Abhishek Kumar Singh
Abhishek Kumar Singh 2024년 7월 1일
I suppose you want to write some data to a specific sheet, here's a sample code you can refer to, which also doesn't creates or adds any new sheet:
% Create a sample table
data = table([1; 2; 3], [4; 5; 6], 'VariableNames', {'Column1', 'Column2'});
% Write the table to a specific sheet in an Excel file
filename = 'testBook.xlsx';
sheet = 'mySheet';
writetable(data, filename, 'Sheet', sheet);
This is what I got:
Hope it helps!
  댓글 수: 2
wenchao zhang
wenchao zhang 2024년 7월 1일
actually, i have write data to the excel sheet successfully,my question is the data is writed to the sencond sheet,the default sheet1 is still exist,i want my data direcltly write to the first sheet with specific names
wenchao zhang
wenchao zhang 2024년 7월 1일
any way, in your case it seems ok,not sure why i will failed

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by