Import selected row data of selected sheet in a Google sheet to MATLAB Appdesigner and populate a table (UITable)
26 views (last 30 days)
Show older comments
I have a google spreadsheet which has four different tabs. How do i import data from each of the tabs(lets say from range A1 to A100) separately to four tables in MATLAB App Designer? I am using MATLAB 2020b.
0 Comments
Answers (1)
Sandeep Mishra
on 22 Jun 2023
Hello Toufique,
I understand that you are trying to import data from a google spreadsheet and want to display data into 4 different tables.
First, you need to search for the ID in the google spreadsheet url, like below
Url = https://docs.google.com/spreadsheets/d/<spread_sheet_id>/edit#gid=0
You can implement the webread function like the below example and update the app's table based on the sheet's data.
% Google spreadhsheet ID
ID = "<spread_sheet_id>";
% Spreadsheet Sheet Name
Sheet1Name = "Sheet1";
Sheet2Name = "Sheet2";
Sheet3Name = "Sheet3";
Sheet4Name = "Sheet4";
% Fetching Sheet1 Data
Sheet1Url = sprintf('https://docs.google.com/spreadsheets/d/%s/gviz/tq?tqx=out:csv&sheet=%s',...
ID, Sheet1Name);
table1Data = webread(Sheet1Url);
% Fetching Sheet2 Data
Sheet2Url = sprintf('https://docs.google.com/spreadsheets/d/%s/gviz/tq?tqx=out:csv&sheet=%s',...
ID, Sheet2Name);
table2Data = webread(Sheet2Url);
% Fetching Sheet3 Data
Sheet3Url = sprintf('https://docs.google.com/spreadsheets/d/%s/gviz/tq?tqx=out:csv&sheet=%s',...
ID, Sheet3Name);
table3Data = webread(Sheet3Url);
% Fetching Sheet4 Data
Sheet4Url = sprintf('https://docs.google.com/spreadsheets/d/%s/gviz/tq?tqx=out:csv&sheet=%s',...
ID, Sheet4Name);
table4Data = webread(Sheet4Url);
% Setting Table data to App Designer
app.Table1.Data = table1Data;
app.Table2.Data = table2Data;
app.Table3.Data = table3Data;
app.Table4.Data = table4Data;
You can refer to the documentation below to learn more about webread.
0 Comments
See Also
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!