Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: xlswrite to Excel 2007 problem
Date: Fri, 5 Sep 2008 17:46:03 +0000 (UTC)
Organization: Sandia National Labs
Lines: 15
Message-ID: <g9rr8r$j6e$1@fred.mathworks.com>
References: <g9p9j3$a8b$1@fred.mathworks.com> <3194495.1220562582966.JavaMail.jakarta@nitrogen.mathforum.org> <g9pp3u$md5$1@fred.mathworks.com> <g9q30q$20c$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1220636763 19662 172.30.248.37 (5 Sep 2008 17:46:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 5 Sep 2008 17:46:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1316302
Xref: news.mathworks.com comp.soft-sys.matlab:488837



Thanks, but xlswrite does initialize the workbook, worksheet and other tasks necessary to write to Excel. 

I have determined that regardless of what DefaultSaveFormat is set to, the result of running xlswrite is a file in the .xlsx format. Thus far, the only solution is to go back, open the new file with Excel 2007 and using Save As to make the file into a .xls by selecting 97-2003 format. 

In Excel 2007 I have gone to Excel Options>>Save>>Save files in this format: and select Excel 97-2003 Workbook (.xls) prior to running xlswrite; this doesn't work either. The funny thing is that if I open Excel 2007, make a workbook and save it (with the Excel save option selected above), it opens just fine in 2003.  

It seems as if xlswrite uses the default save format of the latest version of Excel (.xlsx), regardless of what I set DefaultSaveFormat to be with MATLAB. 

My next guess is to open and save a 'template', empty, workbook in Excel 2003 and modify xlswrite to go open this template.xls file, add my data, then save with a new file name.  I have some PPT functions that do this and they work just fine regardless of the version of Office. 

Anyway, this has been driving me crazy, so I wanted to provide an update for anyone else that might encounter version issues with Excel. 

The ridiculous part is that if Excel 2003 and 2007 had different progid names to pass to the actxserver(progid) function, this whole issue could be avoided.  Unfortunately, both 2003 and 2007 have the progid 'Excel' and I haven't found a way to change that.

M LENZ