How to place text in a single excel cell?
59 次查看(过去 30 天)
显示 更早的评论
I'm running a series of analyses and exporting information to an Excel file to make it easier to summary, do additional analyses, share with collaborators, etc, and I have run into an issue that is probably very simple (so my aplogies if I have missed an obvious solution).
When I export the data to excel, I would like to export text to multiple cells. For example, if I were adding the value "Connecticut" to five cells in a single columns. The goal is to produce something like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/205280/image.png)
I am using something similar to the following:
label = 'Connecticut';
label = repmat(label,5,1);
xlswrite(fid,label,sheet1,'A1');
which produces this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/205281/image.png)
so the script is importing the individual values (characters) into individual cells, rather than the entire row. Is there a simple way to change this?
Thanks,
Robert
0 个评论
采纳的回答
Walter Roberson
2019-2-21
label = repmat( {label}, 5, 1)
3 个评论
Walter Roberson
2019-2-21
T = 'hello';
label = repmat({T}, 5, 1);
%these next two can only work on MS Windows with Excel installed
xlswrite('testxx.xlsx', label)
xlswrite('testxc.csv', label)
%these will work on any release since tables were introduced
TT = array2table(label);
writetable( TT, 'testtx.xlsx', 'writevariablenames', false)
writetable( TT, 'testtc.csv', 'writevariablenames', false)
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!