xlswrite question on long strings (0x800A03EC)

2 Ansichten (letzte 30 Tage)
Philippe
Philippe am 17 Jun. 2011
Hi, I am having trouble with xlswrite using long strings. Here is the problem:
1>> smallstring='qwerty';
2>> bigstring=strcat(repmat('qwerty',1,200));
3>> length(bigstring) ans = 1200
4>> xlswrite('test.xls',{smallstring},'Sheet1','A1');
5>> xlswrite('test.xls',{bigstring},'Sheet1','A1'); % this is ok!
6>> xlswrite('test.xls',{smallstring,smallstring},'Sheet1','A1');
7>> xlswrite('test.xls',{smallstring,bigstring},'Sheet1','A1');
??? Error using ==> xlswrite at 211 Error: Object returned error code: 0x800A03EC
that xlswrite cannot write to excel strings longer than 1024 characters due to an excel (2003) limitation. This explains line 7, but line 5 works...why? Thanks
Philippe

Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 17 Jun. 2011
I had the same problem with MS office 2003. I even submitted a bug report to Microsoft but didn't really get response. I think the actual threshold is 911 or 912 characters. Do a search you'll find plenty of similar complaints. What I found out was that this limitation did not apply when writing to the Excel file one cell at a time. So what I did was first try to write the data to the whole sheet, if error happens, then write the data one cell at a time. It's really a pain at the butt if you have a big sheet of data but only a few of them exceed the character limit. Microsoft really should fix the problem.

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by