%% Write Timetable to Spreadsheet File
% Create a timetable, write it to a spreadsheet file, and then display the contents of the file.
% Define a timetable in the workspace with row times as a datetime vector.

Y = [2014:2018]'; M = ones(5,1); D = ones(5,1);
RowTimes = datetime(Y,M,D); % Create Row Times
TT = timetable(RowTimes,[98;97.5;97.9;98.1;97.9],[120;111;119;117;116],...
               'VariableNames',{'Reading1','Reading2'})

% Write the table to spreadsheet file 'TT.xlsx'. By default, the writetimetable function writes the first worksheet in the file. Use the 'Sheet' name-value pair to specify the worksheet to write to.

writetimetable(TT,'TT.xlsx','Sheet',2)

% Read and display the file contents.

readtimetable('TT.xlsx','Sheet',2) 

% Copyright 2018 The MathWorks, Inc.