xlswrite text with multiple empty cells inbetween

5 次查看(过去 30 天)
I have ratio data for multiple markets and would like to write them to excel, as the sequence of ratios stays the same I just write the Header2 multiple times. For the top row however there should be, in this case, four empty cells inbetween the market titles. I have another case where I need 20 empty cells inbetween each title. Is there a shorter way to do this?
Ratios = [PB, PE, EVEBITDA, PFCF, ROE];
RatiosD = [PB, PE, EVEBITDA, PFCF, ROE];
RatiosE = [PB, PE, EVEBITDA, PFCF, ROE];
Header1 = {'All,'','','','' 'Developed','','','','' 'Emerging'};
Header2 = {'PB', 'PE', 'EVEBITDA', 'PFCF', 'ROE'};
xlswrite('Ratios.xlsx', [Header1], 'Ratios', A1);
xlswrite('Ratios.xlsx', [Header2, Header2, Header2], 'Ratios', A2);
xlswrite('Ratios.xlsx', [Ratios, RatiosD, RatiosE], 'Ratios', A3);

采纳的回答

Steven Yeh
Steven Yeh 2018-6-22
编辑:Steven Yeh 2018-6-22
There are many ways to do this, one of them is to create padding cells:
a = cell(1,20);
Header1 = {'All',a{:}, 'Developed','','','','' 'Emerging'}
Or you could expand the cells by indexing:
Header1{1} = 'All'
Header1{21} = 'Developed'
Header1{41} = 'Emerging'

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by