error in loading data from a sheet in .xlsx format
35 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Othman Alkandri
el 5 de Abr. de 2023
Comentada: Othman Alkandri
el 5 de Abr. de 2023
I am loading data from sheet one using load button callback as shown below
function ExcelDataLoadButtonPushed(app, event)
%this code taken from the flowwing ref
%https://www.mathworks.com/matlabcentral/answers/1889727-how-to-let-the-user-input-an-excel-file-i-e-csv-file-and-array-in-matlp-app-designer
% knot it's better to have excel files without labe stight data
% the excel file should be in csv
%everytime you need to update you need to clcik on the file
%button
% Have user select Excel file to load
[app.filename, app.folder] = uigetfile('*.xlsx*');
if isequal(app.filename,0)
msgbox('Please input an Excel file')
else
%app.filename = fullfile('Mechanical Propulsion System Data.xlsx');
% Read the Excel data
app.System_data = readtable(fullfile(app.folder,app.filename),"Sheet","1");
%app.System_data = readtable(app.filename,"Sheet","1");
%sotring the data from the master file in the variables
% Ship Specification
app.LBP = app.System_data{1,3};
app.Los = app.System_data{2,3};
app.Lwl = app.System_data{3,3};
app.TF = app.System_data{4,3};
app.TA = app.System_data{5,3};
app.V_breadth= app.System_data{6,3};
app.V_Draft= app.System_data{7,3};
app.N_thruster = app.System_data{8,3};
app.Nrudd = app.System_data{9,3};
app.NBoss = app.System_data{10,3};
app.NBrac = app.System_data{11,3};
app.AT = app.System_data{12,3};
app.CB = app.System_data{13,3};
end
end
the error i have is
Error using readtable
Sheet name '1' does not exist or is not supported. To check if the sheet is supported, specify the sheet by its worksheet index.
Error in Ferry_test_system_main/ExcelDataLoadButtonPushed (line 695)
app.System_data = readtable(fullfile(app.folder,app.filename),"Sheet","1");
Error in matlab.apps.AppBase>@(source,event)executeCallback(appdesigner.internal.service.AppManagementService.instance(),app,callback,requiresEventData,event) (line 63)
newCallback = @(source, event)executeCallback(appdesigner.internal.service.AppManagementService.instance(), ...
Error while evaluating Button PrivateButtonPushedFcn.
I attachd the xlsx file. I do have the sheet but matlab is still give me error. could you help me with the error please.
0 comentarios
Respuesta aceptada
Stephen23
el 5 de Abr. de 2023
" I do have the sheet but matlab is still give me error."
No, as the error message correctly states, there is NO sheet in that XLSX named "1". These are the sheetnames:
fnm = 'Mechanical Propulsion System Data.xlsx';
sheetnames(fnm)
If you want to access the first sheet, then specify that as a numeric (just as the documentation shows):
tbl = readtable(fnm,"Sheet",1)
Más respuestas (1)
Walter Roberson
el 5 de Abr. de 2023
you do not have a sheet named "1", you have a sheet named "Mechanical Propulsion System". That sheet is index 1, not named "1". If you want index 1 pass in numeric 1 instead of "1"
Ver también
Categorías
Más información sobre Whos en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!