how to give range in xlsread using edit text field in app designer?
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
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
Rik
on 7 Jan 2022
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
taimour sadiq
on 7 Jan 2022
Thanks i will update you soon after trying the guidelines.
taimour sadiq
on 10 Jan 2022
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'
Rik
on 10 Jan 2022
What class is app.Columneditfield.Value? I don't immediately see how this code can result in this error.
taimour sadiq
on 10 Jan 2022
Edited: taimour sadiq
on 10 Jan 2022
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.
Rik
on 10 Jan 2022
You can put this line in your code to easily check:
uialert(app.UIFigure,sprintf('class name is %s',class(app.Columneditfield.Value)),'')
taimour sadiq
on 11 Jan 2022
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')'
Rik
on 11 Jan 2022
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.
taimour sadiq
on 11 Jan 2022
yes ur assumption about error is possible, i will review the whole code and will update hopefully tommorow.
taimour sadiq
on 12 Jan 2022

i have attached a demo app fie to illustrate... Kindly guide further... class name is char
Rik
on 12 Jan 2022
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];
taimour sadiq
on 12 Jan 2022
i really made a silly mistake.. appreciate ur patience... Now it works fine according to my requirement.
More Answers (0)
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Tags
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)