Path: news.mathworks.com!not-for-mail
From: "Dan Haeg" <haegd@msoe.edu>
Newsgroups: comp.soft-sys.matlab
Subject: Re: xlswrite to Excel 2007 problem
Date: Thu, 6 Nov 2008 22:02:02 +0000 (UTC)
Organization: Milwaukee School of Engineering
Lines: 48
Message-ID: <gevpgq$9sq$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> <g9rr8r$j6e$1@fred.mathworks.com> <ga27kp$e4l$1@fred.mathworks.com>
Reply-To: "Dan Haeg" <haegd@msoe.edu>
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 1226008922 10138 172.30.248.37 (6 Nov 2008 22:02:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 6 Nov 2008 22:02:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 475291
Xref: news.mathworks.com comp.soft-sys.matlab:499393


"Michael Lenz" <mclenz@sandia.gov> wrote in message <ga27kp$e4l$1@fred.mathworks.com>...
> Final note:
> 
> I finally had to resort to a small modification to xlswrite.  I opened a blank workbook with Excel 2003, then saved it as "XLTemplateFile.xls".  The modification to xlswrite now opens this template file, then sets up the workbook, and saves the .xls template using the input file name - just like xlswrite.  Here is the small mod I made, just as an FYI (starts at line 207 in xlswrite):
> 
> try
>     bCreated = false;
>  %   if ~exist(file,'file')
>  %       % Create new workbook.  
>  %       bCreated = true;
>         %This is in place because in the presence of a Google Desktop
>         %Search installation, calling Add, and then SaveAs after adding data,
>         %to create a new Excel file, will leave an Excel process hanging.  
>         %This workaround prevents it from happening, by creating a blank file,
>         %and saving it.  It can then be opened with Open.
>  %       ExcelWorkbook = Excel.workbooks.Add;
>  %       ExcelWorkbook.SaveAs(file)
>  %       ExcelWorkbook.Close(false);
>  %   end
>     
>     %Open file
>     ExcelWorkbook = Excel.workbooks.Open(XLTemplateFile);
>     ExcelWorkbook = Excel.workbooks.Add;
>     ExcelWorkbook.SaveAs(file)
>     bCreated = true;
>     ExcelWorkbook.Close(false);
>     ExcelWorkbook = Excel.workbooks.Open(file);
> 
> Anyway, just wanted to pass that along in the event that anyone else runs into the same issue that I did.
> 
> Thanks to everyone that posted suggestions on this thread.
> 
> M Lenz

I had a simmilar problem with xlswrite. This seems to work outside of xlswrite:
ExcelWorkbook.SaveAs(file,39)

39 saves it to excel95 format
-4143 saves it to excel's default format, which i used to convert csv files to xls silently

here is a list of possible values I found:
http://www.pcreview.co.uk/forums/thread-3042211.php

explained poorly here:
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.xlfileformat(VS.80).aspx

Dan