Reading an Excel workbook in GUI
이전 댓글 표시
Hi all,
I am trying to develop a GUI application that reads variables and values. Basically that Excel sheet is Console Output of my Java application. My problem is that I'm not able to read the file which is generated by the java code.
I am able to read the same excel sheet if I save it in a different folder with the same name and format.
If i use this code
[~, txt] = xlsread('E:\test.xls','history','A10'); %where (K4) cell is wanted text
Cell_Type = txt{1};
set(handles.text2,'string',Cell_Type);
I am getting the following error
>> GUI
Error using xlsread (line 247)
File E:\test.xls not in Microsoft Excel Format.
Error in GUI>pushbutton1_Callback (line 83)
[~, txt] = xlsread('E:\test.xls','history','A10'); %where (K4) cell is wanted text
Error in gui_mainfcn (line 96) feval(varargin{:});
Error in GUI (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)GUI('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
I need some help to solve this.
Thanks!
댓글 수: 9
Adam
2016년 12월 16일
Well, the error says the file is not in Excel format. I'm not sure what help you expect with that error?
José-Luis
2016년 12월 16일
Does the file even open in Excel?
Karthick Thirumurthy
2016년 12월 16일
José-Luis
2016년 12월 16일
Have you tried copying the file to the folder your script resides and getting rid of the path when you call xlsread ?
Karthick Thirumurthy
2016년 12월 16일
Karthick Thirumurthy
2016년 12월 17일
Jan
2016년 12월 17일
What about using csvread instead? Sounds too trivial to post this as an answer...
Karthick Thirumurthy
2016년 12월 17일
Image Analyst
2016년 12월 17일
Did you see my answer below???
답변 (1개)
Image Analyst
2016년 12월 17일
0 개 추천
I think you meant export to a csv file rather than import. Yes, you can use csvread() as long as it's all numbers, or importdata() or readtable() if it has headers. If you still would rather have an Excel workbook, then attach the .xls file that your java code made with the paper clip icon.
Maybe you should save it in .xlsx format instead.
What is the folder name that you used when you were able to save it and read it back in properly? I don't really see why the folder name should matter as long as the entire filename is less than 218 characters, which is the maximum file name length that Excel can handle. And of course 'E:\test.xls' is much less than 218.
댓글 수: 3
Karthick Thirumurthy
2016년 12월 17일
Image Analyst
2016년 12월 17일
OK, this is not a csv file that MATLAB can read. It's a horribly complicated mess with a mish mash mixture of numbers and text all over the place. I think we're better off using Excel. Please attach the workbook.
Karthick Thirumurthy
2016년 12월 17일
카테고리
도움말 센터 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!