필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Table data direct to Excel, not via file

조회 수: 2 (최근 30일)
Marc Elpel
Marc Elpel 2020년 4월 22일
마감: MATLAB Answer Bot 2021년 8월 20일
I would like to put a context menu on a UI Table to Open the data/send direct to Excel. I can do this via a temporary file, but would like to know if it is possible to send the data direct to remove the need to save/open the data via a file?
My current code (which works) is:
data = [{'Cat', 1, 2, 3};{'Dog', 4, 5, 6};{'Chicken', 7, 8, 9}]
T = cell2table(data)
writetable(T,'temp.csv')
winopen('temp.csv')
What I was looking for was something of the form:
data = [{'Cat', 1, 2, 3};{'Dog', 4, 5, 6};{'Chicken', 7, 8, 9}]
system('Excel',data)
Aside from the fact this does not work, system commands appear to leave an open command window when complete. I was able to get just the system(Excel) part to work, but had to look up the full path of the Excel executable (surprised it was not in the system path def). This left the command window open, and does not solve the original problem of calling with with data.
Final Q: What is the right form for just launching the app (Excel, Word, etc) without data? Is there a better way than the system() command?

답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 4월 22일
Why not directly
writetable(T,'temp.xlsx')
instead of exporting it to a csv.
  댓글 수: 3
Ameer Hamza
Ameer Hamza 2020년 4월 22일
I don't have a window platform, but does the function winopen() not work on MS Excel?
Marc Elpel
Marc Elpel 2020년 4월 22일
Winopen() does nto work opening Excel (might be because it is not in the system path).
Regardless, that would not solve the issue unless I could do winopen('Excel' [data]), which does not appear to be valid syntax.

이 질문은 마감되었습니다.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by