Write cells to individual excel sheets

1 回表示 (過去 30 日間)
Richard Rees
Richard Rees 2021 年 11 月 4 日
編集済み: Dave B 2021 年 11 月 5 日
Hi, I'm having problems writting individual cells to individual sheets in excel. It states an invalid data range. I need to add the cell IDs above the orginal data.
Attached is the code for xlswrite.
Thanks
Load('Sample_data.mat');
Fnane = 'PD.xlsx';
%add cell ID above PD data for each cell.
for n = 1:numel(Sheet_names)
PD_adpt{n}(2,:) = PD_adpt{n}(1,:);
PD_adpt{n}(1,:) = Cell_ID;
end
for ii = 1:numel(PD_adpt)
xlswrite(Fnane,PD_adpt{ii},'sheet',sheet_names(ii))
end
  3 件のコメント
Richard Rees
Richard Rees 2021 年 11 月 5 日
Hey, I get worksheeet could not be activated
Richard Rees
Richard Rees 2021 年 11 月 5 日
I just had a tinker again. If I use writecell it will work.
Thanks both for your replies
for ii = 1:numel(PD_adpt)
writecell(PD_adpt{ii},Fname,'Sheet',Sheet_names(ii))
end

サインインしてコメントする。

回答 (1 件)

Dave B
Dave B 2021 年 11 月 4 日
編集済み: Dave B 2021 年 11 月 5 日
I think with xlswrite you specify just the sheet, no need to use the keyword 'sheet'
xlswrite(Fnane, PD_adpt{ii}, sheet_names(ii))
But in general you might have a better time if you use writematrix/writecell/writetable instead of xlswrite

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by