Write and retrieve text box values to/from excel file

5 ビュー (過去 30 日間)
ahmed obaid
ahmed obaid 2016 年 3 月 14 日
コメント済み: Geoff Hayes 2020 年 11 月 3 日
Dear users ,
i would like to store the values of two text box in GUI the first text box1 values are number ( i.e. 1 , 2 , 3 , 4 , ..etc) and the second text box2 values are string like ( i.e. wilyam staling , john park , ..etc ) the value of number 1 of text box 1 correspond to text values name of wilyam staling and so on ..
my question .. i need when i inter number 1 in first text box for example and press (botton) then name wilyam staling will appear in second text box .. thanks for help
  2 件のコメント
Geoff Hayes
Geoff Hayes 2016 年 3 月 14 日
ahdmed - how are you managing the list of names? Do you have a cell array that you populate when the GUI launches?
ahmed obaid
ahmed obaid 2016 年 3 月 14 日
Sir , x= values of text box 1 value , y= text box 2 value , xlwrite ( Exl file , cellA , 'x value ' , ' cell B ' , 'y value '); A = A+1 , B = B+1 , then ..
after i inter some value after clear text box 1 for example if i inter 1 , then command will read the values of A columns when value match inter number then values of B will appear in text box2

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

採用された回答

Geoff Hayes
Geoff Hayes 2016 年 3 月 14 日
Ahmed - can you post some of your code? It seems as if you are using your GUI to write and read from an Excel spreadsheet. If that is the case and you know how to write to the file, then is it the reading from file that is causing a problem? Suppose the user has entered a number into the edit1 text control and pressed a button whose callback is
function pushbutton1_Callback(hObject, eventdata, handles)
% read from the Excel file
[~,~,rawData] = xlsread(handles.excelFileName);
% get the value from edit1
id = str2num(char(get(handles.edit1,'String')));
% get the index of id in the first column of rawData
rowIndex = find(rawData(:,1) == id);
if ~isempty(rowIndex)
% get the name
userName = rawData(rowIndex,2);
% set the name
set(handles.edit2,'String',userName);
end
The above is untested, but I think that you can use it for your purposes. I've made some assumptions concerning the names of your controls, the name of the Excel file (presumably stored as a string within the handles structure), and the fact that the data is stored as two columns.

その他の回答 (1 件)

Md Iqbal
Md Iqbal 2020 年 10 月 30 日
Errer using ==>fecal Error<a Error in ==>guidefunc at 15
  1 件のコメント
Geoff Hayes
Geoff Hayes 2020 年 11 月 3 日
Please remove this as an "answer" and post as either a comment (to the above) or as a new question.

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

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by