How to import specific sections of Excel file and print output
Show older comments
I'm trying to create a GUI that will ask the user for a folder path and do some calculations based on it.
The output should look like
Day TotalTemp(C) TotalCost
---------------------------
Day1 103 203
Day2 93 352
Day3 95 278
I'm not sure about several things, and this is the code I have written so far.
myFolder='C:\Users\Training 1'; %path to excel files placeholder
filePattern = fullfile(myFolder,'i', '*.xlsx');
theFiles = dir(filePattern);
for k=1: length(theFiles)
baseFileName= theFiles(k).name;
fullFileName=fullfile(myFolder, baseFileName);
data1{k} =xlsread(theFiles(k), 'Sheet1','F10:');
totaltemp{k}= sum(data1{k});
data2{k} =xlsread(theFiles(k), 'Sheet2','A9:');
totalcost{k}= sum(data2{k});
end
1. How to extract the "Day#" portion from the file names (EX: Training 1_Day1_East.xslx) and put it in a column.
2. How to only grab data from specific cell sheets (EX:Calculate the sum of Sheet2 F10 to end of row 10).
3. How to print the output to look like the example above.
Accepted Answer
More Answers (0)
Categories
Find more on Data Import from MATLAB 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!