MATLAB: Converting txt to xlsx

text file

Hi I am trying to convert a textfile to xlsx. file
My textfile holds this information:
StudentName: James
School: University of Blah
Year: 2020
Grade: 3
Pin: 40
And I want to convert this to xlsx. file
*check the attached screenshot file*

Best Answer

This will convert the full text file to .xlsx:
yourFileName = readcell('yourFileName.txt')
writecell(yourFileName,'yourFileName.xlsx')
If you only want to save the second column, like in your screenshot, use this:
yourFileName = readcell('yourFileName.txt')
writecell(yourFileName(:,2),'yourFileName.xlsx')
Related Question