Matlab Script won't write to Excel past column Z?
Show older comments
Hey guys, so I have a simple script that is part of a much larger program in MatLab. The simple script simply writes certain output to an Excel file:
function writevar(x,k,filename)
col = char(64+k);
N = size(x,1);
Rg = sprintf([col '1:' col '%i' ],N);
xlswrite(filename,x,Rg);
end
I'm writing over 100 individual things however the script gives an error and won't write past column Z. I'm using the script via the following:
writevar({randA{counter}},counter,filename);
If anyone could point out how to modify the script or my use of it to continue writing to Excel past the Z column that would be much appreciated!
Thanks.
Accepted Answer
More Answers (1)
Steven Lord
on 4 Jul 2016
1 vote
The column after Z is AA. You need to modify your code that defines col to handle this. Or just omit the range and let xlswrite write starting at the upper-left corner and go as far as it needs to go.
3 Comments
Haissam Adil
on 4 Jul 2016
wirat chiangkul
on 9 Aug 2021
Hi,
is anyone find out how the solution is. i have a problem on this too. i'd like to generate data more than 26 column like AA, AB, AC and so on can anyone help?
Regards,
Walter Roberson
on 9 Aug 2021
I posted links to two File Exchange contributions that accept a numeric column number and return a lettered column name.
Categories
Find more on Spreadsheets in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!