how to write xls file

Hi i want to write xls file using the below code i am able to write numeric data.i want to write header also.please guide how to proceed
data=get(handles.uitable1,'data');
checkbox1State = get(handles.af1, 'Value');
checkbox2State = get(handles.af2, 'Value');
checkbox3State = get(handles.af3, 'Value');
if checkbox1State
header={'first'}
p=data(start_pt:end_pt,1);
xlswrite('af1.xls',p,1,'A2');
end
if checkbox2State
header={'second'}
p=data(start_pt:end_pt,2);
xlswrite('af1.xls',p,1,'B2')
end
if checkbox3State
header={'third'}
p=data(start_pt:end_pt,3);
xlswrite('af1.xls',p,1,'C2')
end

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 4 日
編集済み: Azzi Abdelmalek 2013 年 3 月 4 日

0 投票

x=[1;2;3]; % first column
y=[10;20;30] ;% second column
header={'x','y'}
M=[header ; num2cell([x y])]
xlswrite('filname.xls',M)

5 件のコメント

rafi abdul
rafi abdul 2013 年 3 月 5 日
Hi i have 3 checkboxes as per ur code i have assigned each coloumn and header to checkbox.my requirement is when i push a pushbutton it should search for checkboxes which are checked and write xls file.when i check allcheck boxes it is writing excelfile but if i uncheck second checkbox and push the button it is showing middlecolumn as blank and it writes first and third coloumn i dont want any blank column which ever is checked it should be written eithout anygaps in middle.how to proceed
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 5 日
Are your columns the same size?
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 5 日
編集済み: Azzi Abdelmalek 2013 年 3 月 5 日
If yes, you can use
test=0;
p123=[];
if checkbox1State
header={'first'}
p=data(start_pt:end_pt,1);
p123=[p123 p]
test=1
end
if checkbox2State
header={'second'}
p=data(start_pt:end_pt,2);
p123=[p123 p]
test=1
end
if checkbox3State
header={'third'}
p=data(start_pt:end_pt,3);
p123=[p123 p]
end
if test==1
xlswrite('af1.xls',p123,'A2');
end
rafi abdul
rafi abdul 2013 年 3 月 6 日
thanks it is working
rafi abdul
rafi abdul 2013 年 3 月 8 日
hi aziz i am trying to write xls file using above code but am able to write upto 50000 rows only.i have 130000 rows how to proceed.

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

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by