How to export excel file headers & its contents

Hi Team
I have created POP-UP in Matlab GUI where it reads& Displays list of headers which are in Excel file, Next, How do i can read the entire contents(columns) of Selected Header in GUI ?
Can any Please help

Answers (1)

ES
ES on 23 Dec 2013
Edited: ES on 23 Dec 2013
using the column Number, read the contents using xlsread
columnB = xlsread(filename,'B:B')
and display it in either a edit box or in an uitable using set
set(handles.uitable1,'data',columnB );
or
set(handles.edit1,'string',columnB );

2 Comments

I dont want to define column number, Based on appropriate Header selection its contents should be loaded
You need not define the column number. Based on selection you can do it.
ColumnValue=get(handles.popup1,'value');
ColumnChar=getExcelColChar(ColumnValue);
columnData = xlsread(filename,['''',ColumnChar,':',ColumnChar,''''])
where getExcelColChar could be something like this...
function character=getExcelColChar(number)
% This Module gives the Column String of Excel Column for the corresponding
% Column Number. For eg, Excel Column 1 is A, Column 27 is AA, Column 256
% is IV.
if (number<=26)
Temp=uint8('A')+number-1;
character=char(Temp);
else
Temp=uint8('A');
number=number-26;
while(number>26)
Temp=Temp+1;
number=number-26;
end
character=[char(Temp) char(number+64)];
end

Sign in to comment.

Asked:

on 23 Dec 2013

Commented:

ES
on 23 Dec 2013

Community Treasure Hunt

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

Start Hunting!