can i use col numbers in writecell

8 ビュー (過去 30 日間)
Robert Jones
Robert Jones 2022 年 7 月 15 日
コメント済み: Robert Jones 2022 年 7 月 15 日
Hello,
I am trying to use sheet names and column numbers when I use write cell.
I have this code. Last two lines do not work
In line 2 I have a working example for readcell. I assumed writecell would accept the same formats.
Am I missing something?
Thanks
xlx='AntGodMain_20220708_0641_Sancho_Panza_Fully_Opt_XY_Old_Lenovo_test.xlsx';
xfolder=readcell(xlx,'Sheet','MAIN','Range',[6,2,6,3]); % WORKS
zubu=cellstr('mytext');
writecell(zubu,xlx); % WORKS
writecell(zubu,xlx,'Sheet','COST_FUNCTION','Range','K21:K21'); % WORKS
writecell(zubu,xlx,'Sheet','COST_FUNCTION','Range',[23,11,23,11]); % DOES NOT WORK
writecell(zubu,xlx,'Sheet',2,'Range',[22,11,22,11]); % DOES NOT WORK

採用された回答

Voss
Voss 2022 年 7 月 15 日
According to the documentation, writecell accepts 'Range' arguments of the following forms:
  • 'Corner1', where Corner1 specifies the first cell of the region to write. The writing function writes the data starting at this cell. Example: 'Range','D2'
  • 'Corner1:Corner2', where Corner1 and Corner2 are two opposing corners that define the region to write. For example, 'D2:H4' represents the 3-by-5 rectangular region between the two corners D2 and H4 on the worksheet. The 'Range' name-value pair argument is not case sensitive, and uses Excel A1 reference style (see Excel help). Example: 'Range','D2:H4'
Whereas readcell accepts those forms and others, including [r1 c1 r2 c2].
References: writecell, readcell
  3 件のコメント
Voss
Voss 2022 年 7 月 15 日
Sorry, I wasn't clear.
writecell does not accept Range arguments of the form [r1 c1 r2 c2] (or [r1,c1,r2,c2], which is equivalent). Use one of the two accepted forms listed above.
Robert Jones
Robert Jones 2022 年 7 月 15 日
oh, ok
thank you

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import and Analysis についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by