xls export problem
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello Blower
am 18 Feb. 2011
Beantwortet: Chidiebere Brendan Obiechefu
am 29 Jul. 2019
>> xls_1
xls_1 =
857_386.xls
>> xlswrite(xls_1,a) ??? Error using ==> xlswrite at 213 Invoke Error, Dispatch Exception: Source: Microsoft Office Excel Description: ???????????????????:
??????????????? ??????????? ??????????????: < > ? [ ] : ? *? ????????????? 218 ????? Help File: C:\Program Files\Microsoft Office\OFFICE11\1028\xlmain11.chm Help Context ID: 0
0 Kommentare
Akzeptierte Antwort
Matt Tearle
am 27 Feb. 2011
OK, your problem is the special characters in the string. You can't have slashes and line breaks in a filename.
When you do xlswrite('xls_1',a); the filename is the literal string 'xls_1', which is why it writes to xls_1.xls. You need the filename stored in the char variable xls_1, so:
xlswrite(xls_1,a);
However, to do that, xls_1 has to be a valid filename string. This works:
xls_1 = sprintf('%i_%i.xls',x,y)
If you're ok with underscores in places of slashes in the dates, this also works:
xls_1 = sprintf('%i_%i_%s_%s.xls',...
x,y,regexprep(start_day,'/','_'),regexprep(end_day,'/','_'));
0 Kommentare
Weitere Antworten (5)
Jan
am 20 Feb. 2011
I do not see the problem.
a = rand(5);
xls_1 = '857_386.xls';
xlswrite(xls_1, a);
=> The file 857_386.xls is created. Did you use "xlswrite xls_1 a" without parenthesis?!
2 Kommentare
Matt Tearle
am 20 Feb. 2011
Dare I ask... When you say you set xls_1 = 857_386.xls, you do mean xls_1 = '857_386.xls', right?
2 Kommentare
Cagri Ozcaglar
am 4 Mär. 2011
File name may be too long. Try to shorten the absolute path of the file by shortening folder names.
0 Kommentare
Chidiebere Brendan Obiechefu
am 29 Jul. 2019
I had same problem. What solved mine was writing the excel file to a desktop location. I don't know if it was because I was trying to save on onedrive (which is what I use normally), or that the file path is too long.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!