How to convert excel data to text file using file handling or any suitable method in editor window only?
Show older comments
Hello sir, we are going to make project on result analysis. But its showing str2num and uicontrol error plz help soon. We have attached matlab code also we want to convert our panel output of static window into text file. we have coded for excel file of pushbutton named as text converter but it displays it in excel file and we want it in text file. so kindly plz help us.
Answers (1)
Geoff Hayes
on 2 Oct 2016
Shlok - your code includes the lines
class={text65,text66,text67,text68,text69,'total',text97;
text78,text70,text74,text82,text86,text93,text98;
text79,text71,text75,text83,text87,text92,text99;
text80,text72,text76,text84,text88,text94,text100;
text81,text73,text77,text85,text89,text95,text101}
xlswrite('ajk.xlsx',class);
where the text* variables are the numeric elements taken from your GUI controls. Since class is a cell array (due to the 'total' string), then you could refer to Export Cell Array to Text File to write the cell data to the text file. You may need to call fprintf twice since you have two different formats (one row of the cell array that has numeric and character data, and the remaining rows which have numeric data only).
3 Comments
Geoff Hayes
on 2 Oct 2016
Edited: Geoff Hayes
on 2 Oct 2016
Shlok Kamble's answer moved here
We are not getting you plz explain briefly thank you.
There is excel file which we have created and we want to convert it into txt file plz help.
Geoff Hayes
on 2 Oct 2016
Shlok - your code, with the initialization of class as a cell array writes the cell array data to the Excel file using xlswrite. Rather than using xlswrite, to write this cell array to a text file instead, see the link that I have provided which describes how to export a cell array (like your class variable) to a text file (which is what you want). Try it out and if you cannot get this to work, post the code that attempts to do this and describe the behaviour. Briefly, you will want to do
fid = fopen('myTextFile.txt','wt');
if fid > 0
% use fprintf to write the class data to file
fclose(fid);
end
You will need to fill in the fprintf code.
dpb
on 2 Oct 2016
Moved OP's comment from Answer--dpb
Its fine now thank you. But that pushbutton error occurs when we run programme. Pushbutton:Total Tag:pushbutton22
Categories
Find more on Spreadsheets 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!