how to give range in xlsread using edit text field in app designer?

i was to read a coloumn from xlsx file which is simple to implement as following
columnB = xlsread(myExample.xlsx,'B:B'); % this works
but i m designing a app in appdesigner, i want to give option to user to input desired column name, i tryed this through
% lets suppose my text edit field is named as app.Columneditfield
columnB = xlsread(myExample.xlsx,'app.Columneditfield.Value:app.Columneditfield.Value');
% this gives error not a valid range
% because when '' is used to define range it does not pick >>app.Columneditfield.Value<<
% kindly guide

 Accepted Answer

Assuming app.Columneditfield.Value is already a char, you can simply create the range like this:
Range=[app.Columneditfield.Value ':' app.Columneditfield.Value];
columnB = xlsread('myExample.xlsx',Range);

11 Comments

Thanks i will update you soon after trying the guidelines.
after weekend i m again on code, i think i m making some mistake in defining app.Columneditfield.Value as a char
when i simple use the below code as u guided
Range=[app.Columneditfield.Value ':' app.Columneditfield.Value];
columnB = xlsread('myExample.xlsx',Range);
it gives error "a quoted character vector is unterminated" and highligh text after :
can u little eloborate further that how may i define app.Columneditfield.Value as a char
i also tried following
char = app.Columneditfield.Value
char(app.Columneditfield.Value)
coloumn = 'app.Columneditfield.Value'
What class is app.Columneditfield.Value? I don't immediately see how this code can result in this error.
Dear Rik i may not be able to properly answer your question that which class is app.Columneditfield.Value... one app.UIAxes i put an "EditField Text" icon and write xlread read code in callback... to simple the scenerio i can share a proper working file after few hours which inlcude the code in appdesigner also some screen shot to illustrate the issue.
You can put this line in your code to easily check:
uialert(app.UIFigure,sprintf('class name is %s',class(app.Columneditfield.Value)),'')
appreciate ur guidence, this line also giving a error in code before execution
uialert(app.UIFigure,sprintf('class name is %s',class(app.Columneditfield.Value)),'')
>> Invalid syntax at 'class'. A '(' might be missing a closing')'
The actual error must be somewhere else, because this line of code is correct. Check the rest of the code for mismatched parentheses and other syntax errors.
yes ur assumption about error is possible, i will review the whole code and will update hopefully tommorow.
i have attached a demo app fie to illustrate... Kindly guide further... class name is char
You forgot to leave in the spaces:
%You wrote:
Range = [app.ColumnEditField.Value':'app.ColumnEditField.Value];
%You should have written:
Range = [app.ColumnEditField.Value ':' app.ColumnEditField.Value];
i really made a silly mistake.. appreciate ur patience... Now it works fine according to my requirement.

Sign in to comment.

More Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products

Release

R2019a

Asked:

on 7 Jan 2022

Commented:

on 12 Jan 2022

Community Treasure Hunt

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

Start Hunting!