<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156684</link>
    <title>MATLAB Central Newsreader - Matlab to Excel issue</title>
    <description>Feed for thread: Matlab to Excel issue</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Mon, 24 Sep 2007 23:43:19 -0400</pubDate>
      <title>Matlab to Excel issue</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156684#393790</link>
      <author>m. k</author>
      <description>I am having this issue in MatLab that I hope I can get help &lt;br&gt;
on.&lt;br&gt;
&lt;br&gt;
Here is my basic M-file program functions:&lt;br&gt;
1. load excel document&lt;br&gt;
2. read specified sheet in excel document&lt;br&gt;
3. save specific [rxc] matrix from excel sheet to a matlab &lt;br&gt;
variable&lt;br&gt;
4. write [rxc] matrix from matlab variable to a specified &lt;br&gt;
region of same excel document&lt;br&gt;
&lt;br&gt;
(if anybody needs further details (i.e. calls used, cmds &lt;br&gt;
used&amp;#8230;) on this process, let me know and I will surely &lt;br&gt;
provide them)&lt;br&gt;
&lt;br&gt;
The issue is this.  When I run my code, the program takes a &lt;br&gt;
while to process everything.  And usually the matrices that &lt;br&gt;
I work with in MatLab are on the order of [384x7] in size.  &lt;br&gt;
My code works, because I have seen the results saved in &lt;br&gt;
MatLab.  However the warning that I always get when the &lt;br&gt;
program is around 2/3 complete is:&lt;br&gt;
&lt;br&gt;
Warning: could not start Excel server for export.&lt;br&gt;
XLSWRITE attempts to file in CSV format.&lt;br&gt;
&lt;br&gt;
&amp;gt; In xlswrite at 157&lt;br&gt;
&amp;gt; In det_update_decision at 141&lt;br&gt;
&lt;br&gt;
(NOTE: 'det_update_decision' is the m-file I wrote, and &lt;br&gt;
line 141 only containes the cmd 'end'.)&lt;br&gt;
&lt;br&gt;
I feel that this is an Excel memory-related issue.  &lt;br&gt;
Everytime I run my program and it stops due to the above &lt;br&gt;
error, I check the task manager and there are several (&amp;gt;30) &lt;br&gt;
instances of EXCEL.EXE*32's running each taking up ~20,000K &lt;br&gt;
of space in Mem Usage.&lt;br&gt;
&lt;br&gt;
Does anybody know what is causing this?  And if so, how to &lt;br&gt;
remedy it?&lt;br&gt;
&lt;br&gt;
One thing that I tried to do was use the following:&lt;br&gt;
&lt;br&gt;
Excel = activexsrv('Excel.Application') to start up an &lt;br&gt;
activexsrv for Excel, and use Excel.Quit at the end of the &lt;br&gt;
code so that I do not have recurring instances of Excel &lt;br&gt;
open in the Task Manager.  Is this the correct way to go &lt;br&gt;
about it?&lt;br&gt;
&lt;br&gt;
Thanks!&lt;br&gt;
m.k. </description>
    </item>
    <item>
      <pubDate>Tue, 25 Sep 2007 00:52:17 -0400</pubDate>
      <title>Re: Matlab to Excel issue</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156684#393796</link>
      <author>Yair Altman</author>
      <description>&amp;gt; The issue is this.  When I run my code, the program takes a &lt;br&gt;
&amp;gt; while to process everything.  And usually the matrices that &lt;br&gt;
&amp;gt; I work with in MatLab are on the order of [384x7] in size.  &lt;br&gt;
&amp;gt; I feel that this is an Excel memory-related issue.  &lt;br&gt;
&lt;br&gt;
xlswrite is very inefficient, in that it does not reuse&lt;br&gt;
existing open XLS server COM connections - it reopens a new&lt;br&gt;
connection with each invocation. This takes a lot of time&lt;br&gt;
and system memory, especially if you run the command in a&lt;br&gt;
loop. I suggest you use xlswrite1 or officedoc, both on the&lt;br&gt;
File Exchange, which reuse open connections. There are a few&lt;br&gt;
other alternatives on the FEX - search around.&lt;br&gt;
&lt;br&gt;
&amp;gt; Everytime I run my program and it stops due to the above &lt;br&gt;
&amp;gt; error, I check the task manager and there are several (&amp;gt;30) &lt;br&gt;
&amp;gt; instances of EXCEL.EXE*32's running each taking up ~20,000K &lt;br&gt;
&amp;gt; of space in Mem Usage.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Does anybody know what is causing this?  And if so, how to &lt;br&gt;
&amp;gt; remedy it?&lt;br&gt;
&lt;br&gt;
xlswrite crashed without bothering to close the open COM&lt;br&gt;
connections... You have no access to these connections and&lt;br&gt;
must delete them via the Task Manager.&lt;br&gt;
&lt;br&gt;
&amp;gt; One thing that I tried to do was use the following:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Excel = activexsrv('Excel.Application') to start up an &lt;br&gt;
&amp;gt; activexsrv for Excel, and use Excel.Quit at the end of the &lt;br&gt;
&amp;gt; code so that I do not have recurring instances of Excel &lt;br&gt;
&amp;gt; open in the Task Manager.  Is this the correct way to go &lt;br&gt;
&amp;gt; about it?&lt;br&gt;
&lt;br&gt;
Yes. You can edit/type xlswrite or xlswrite1 to get started,&lt;br&gt;
or simply use one of the aforementioned FEX submissions.&lt;br&gt;
&lt;br&gt;
Yair Altman&lt;br&gt;
&lt;a href=&quot;http://ymasoftware.com&quot;&gt;http://ymasoftware.com&lt;/a&gt;</description>
    </item>
    <item>
      <pubDate>Tue, 25 Sep 2007 04:19:28 -0400</pubDate>
      <title>Re: Matlab to Excel issue</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156684#393808</link>
      <author>Pete sherer</author>
      <description>try WRITE2EXCEL</description>
    </item>
    <item>
      <pubDate>Tue, 25 Sep 2007 21:12:45 -0400</pubDate>
      <title>Re: Matlab to Excel issue</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156684#393949</link>
      <author>m. k</author>
      <description>&quot;Yair Altman&quot; &amp;lt;altmanyDEL@gmailDEL.comDEL&amp;gt; wrote in message &lt;br&gt;
&amp;lt;fd9m41$68t$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; The issue is this.  When I run my code, the program &lt;br&gt;
takes a &lt;br&gt;
&amp;gt; &amp;gt; while to process everything.  And usually the matrices &lt;br&gt;
that &lt;br&gt;
&amp;gt; &amp;gt; I work with in MatLab are on the order of [384x7] in &lt;br&gt;
size.  &lt;br&gt;
&amp;gt; &amp;gt; I feel that this is an Excel memory-related issue.  &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; xlswrite is very inefficient, in that it does not reuse&lt;br&gt;
&amp;gt; existing open XLS server COM connections - it reopens a &lt;br&gt;
new&lt;br&gt;
&amp;gt; connection with each invocation. This takes a lot of time&lt;br&gt;
&amp;gt; and system memory, especially if you run the command in a&lt;br&gt;
&amp;gt; loop. I suggest you use xlswrite1 or officedoc, both on &lt;br&gt;
the&lt;br&gt;
&amp;gt; File Exchange, which reuse open connections. There are a &lt;br&gt;
few&lt;br&gt;
&amp;gt; other alternatives on the FEX - search around.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Everytime I run my program and it stops due to the &lt;br&gt;
above &lt;br&gt;
&amp;gt; &amp;gt; error, I check the task manager and there are several &lt;br&gt;
(&amp;gt;30) &lt;br&gt;
&amp;gt; &amp;gt; instances of EXCEL.EXE*32's running each taking up &lt;br&gt;
~20,000K &lt;br&gt;
&amp;gt; &amp;gt; of space in Mem Usage.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Does anybody know what is causing this?  And if so, how &lt;br&gt;
to &lt;br&gt;
&amp;gt; &amp;gt; remedy it?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; xlswrite crashed without bothering to close the open COM&lt;br&gt;
&amp;gt; connections... You have no access to these connections and&lt;br&gt;
&amp;gt; must delete them via the Task Manager.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; One thing that I tried to do was use the following:&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Excel = activexsrv('Excel.Application') to start up an &lt;br&gt;
&amp;gt; &amp;gt; activexsrv for Excel, and use Excel.Quit at the end of &lt;br&gt;
the &lt;br&gt;
&amp;gt; &amp;gt; code so that I do not have recurring instances of Excel &lt;br&gt;
&amp;gt; &amp;gt; open in the Task Manager.  Is this the correct way to &lt;br&gt;
go &lt;br&gt;
&amp;gt; &amp;gt; about it?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Yes. You can edit/type xlswrite or xlswrite1 to get &lt;br&gt;
started,&lt;br&gt;
&amp;gt; or simply use one of the aforementioned FEX submissions.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Yair Altman&lt;br&gt;
&amp;gt; &lt;a href=&quot;http://ymasoftware.com&quot;&gt;http://ymasoftware.com&lt;/a&gt;&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
Thanks Yair.  I have found the xlswrite1 on the FEX and &lt;br&gt;
have attempted to use it via the insructions.  However, I &lt;br&gt;
am receiving the following error:&lt;br&gt;
&lt;br&gt;
------------------------------------------------------------&lt;br&gt;
??? Error using ==&amp;gt; xlswrite1&lt;br&gt;
No appropriate method or public field sheets for class &lt;br&gt;
handle.&lt;br&gt;
&lt;br&gt;
Error in ==&amp;gt; m_file_name at 103&lt;br&gt;
xlswrite1('file_name',1,'sheet_name',range);&lt;br&gt;
------------------------------------------------------------&lt;br&gt;
&lt;br&gt;
Does this mean that I am invoking the xlswrite1 function &lt;br&gt;
wrong?&lt;br&gt;
&lt;br&gt;
As it is now, at the beginning of my mfile I include (word &lt;br&gt;
for word):&lt;br&gt;
------------------------------------------------------------&lt;br&gt;
Excel = actxserver ('Excel.Application');&lt;br&gt;
File='C:\M_files\M_file';&lt;br&gt;
&lt;br&gt;
if ~exist(File,'file')&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;ExcelWorkbook = Excel.workbooks.Add;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;ExcelWorkbook.SaveAs(File,1);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;ExcelWorkbook.Close(false);&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
invoke(Excel.Workbooks,'Open',File);&lt;br&gt;
------------------------------------------------------------&lt;br&gt;
&lt;br&gt;
And at the end, word for word:&lt;br&gt;
------------------------------------------------------------&lt;br&gt;
invoke(Excel.ActiveWorkbook,'Save');&lt;br&gt;
Excel.Quit&lt;br&gt;
Excel.delete&lt;br&gt;
clear Excel&lt;br&gt;
------------------------------------------------------------&lt;br&gt;
&lt;br&gt;
In addition, where do I store the M-file xlswrite1?  Do I &lt;br&gt;
copy the syntax and append it at the end of my code (which &lt;br&gt;
I tried but it doesnt seem to work), or do I save it in the &lt;br&gt;
same folder as the M-file that I'm writing?&lt;br&gt;
&lt;br&gt;
Thanks.</description>
    </item>
    <item>
      <pubDate>Wed, 26 Sep 2007 06:48:27 -0400</pubDate>
      <title>Re: Matlab to Excel issue</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156684#393979</link>
      <author>Yair Altman</author>
      <description>&amp;gt; I have found the xlswrite1 on the FEX and &lt;br&gt;
&amp;gt; have attempted to use it via the insructions.  However, I &lt;br&gt;
&amp;gt; am receiving the following error: &amp;lt;...&amp;gt;&lt;br&gt;
&amp;gt; Does this mean that I am invoking the xlswrite1 function &lt;br&gt;
&amp;gt; wrong?&lt;br&gt;
&amp;gt; In addition, where do I store the M-file xlswrite1?  Do I &lt;br&gt;
&amp;gt; copy the syntax and append it at the end of my code (which &lt;br&gt;
&amp;gt; I tried but it doesnt seem to work), or do I save it in the &lt;br&gt;
&amp;gt; same folder as the M-file that I'm writing?&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
I suggest you read the function help documentation and/or&lt;br&gt;
contact the author&lt;br&gt;
&lt;br&gt;
Yair</description>
    </item>
  </channel>
</rss>

