フィルターのクリア

problem with editing a xlsx file with xlswrite

3 ビュー (過去 30 日間)
banco freno
banco freno 2019 年 5 月 6 日
コメント済み: banco freno 2019 年 5 月 7 日
I created a template xlsx file which contains a table (empty) and an image. My script copies the template file and saves it with a different name, then writes some data in the table of the new xlsx file. The code is
[resultfilename, resultpath]=uiputfile('*.xlsx');
resultsave=fullfile(resultpath,resultfilename);
result = {data_name; a;b;c;d;yaw}; %data_name is a string variable
copyfile('template_par.xlsx', resultsave, 'f');
xlswrite(resultfilename,result,1,'F6:F11');
In the newly created Excel file the table has been filled properly but the image has disappeared! Why does this happen?
  2 件のコメント
dpb
dpb 2019 年 5 月 6 日
Just guessing perhaps the area infringes on part of the image?
Dunno just what xlswrite does in its details or how Excel keeps track of what are used cells on a sheet but all the ML function is advertised to do is to write the specific data passed to it and it apparently did that. Collateral damage isn't addressed...altho one can write data to the cell content of subsections of a sheet -- I'm sure it has to do with something about how the image is saved in a sheet but no idea on how that is done internally; it isn't really the content of a cell or group of cells but metadata of some sort; how is an Excel question.
For debugging I'd suggest to move the image "a long way away" from the target area and see if it is an occlusion issue or if it has something to do with the xlswrite functional code that causes the issue.
If it still goes away, expect you'll have to write your own COM instructions instead of using the builtin ML function.
banco freno
banco freno 2019 年 5 月 7 日
I found an alternative solution. Instead of copying a template Excel file I create one inserting my image in it, see this example
the only difference is that to save the Excel file I did this
invoke(workbook, 'SaveAs', resultsave)
so I can choose name and path of this Excel file via user interface.
To build the table I used xlswrite and it worked fine.
result = {data_name; a;b;c;d;yaw};
caption = {'name','a','b','c','d','yaw'}
xlswrite(resultfilename,result,1,'F6:F11');
xlswrite(resultfilename,caption,1,'E6:E11');

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

回答 (0 件)

カテゴリ

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

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by