xlswrite from cell and strcat error 0x800A03EC

2 ビュー (過去 30 日間)
Dave
Dave 2018 年 4 月 14 日
コメント済み: Walter Roberson 2018 年 4 月 14 日
GreetingsI have a variable
A={'H$1';'H$2';'H$3'} %a 4x1 cell
% I need to generate an xlsx file with
=(YesH$1No) in cell A1
=(YesH$2No) in cell A2
=(YesH$2No) in cell A3
% I can xlswrite AA elements to excel wo problem
for ii=1:3
AA(1,ii)=A(ii)
BB{1,ii}=strcat('=(Yes',AA{ii},'No)')
end
xlswrite('fileA.xls', AA)
xlswrite('fileB.xls', BB)
% for BB because of the equal and parenthesis it outputs an error
Error using xlswrite (line 219)
Error: Object returned error code: 0x800A03EC

採用された回答

Walter Roberson
Walter Roberson 2018 年 4 月 14 日
Try
writetable(cell2table(BB),'fileB.xls', 'WriteVariableNames', false)
Note that this would be for the case where you want the cells to contain those literal strings, not for the case where you are trying to write macros at those locations. For that task of writing macros, what I find is https://stackoverflow.com/questions/48190180/can-matlab-write-a-macro-in-an-excel-file-via-activex
  3 件のコメント
Dave
Dave 2018 年 4 月 14 日
編集済み: Dave 2018 年 4 月 14 日
In my code above, if I remove the equal sign in the strcat it writes ok.
'(Yes' works
'=(Yes' gives error
Walter Roberson
Walter Roberson 2018 年 4 月 14 日
Hack workaround: disable / uninstall Excel for the moment. That would cause writetable() to use internal routines to do the writing instead of talking to Excel.
Or, Hack Workaround: edit writeXLSFile.m and change
book = createWorkbook(filename, ext, true);
to
book = createWorkbook(filename, ext, false);

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by