I am having this issue in MatLab that I hope I can get help
on.
Here is my basic M-file program functions:
1. load excel document
2. read specified sheet in excel document
3. save specific [rxc] matrix from excel sheet to a matlab
variable
4. write [rxc] matrix from matlab variable to a specified
region of same excel document
(if anybody needs further details (i.e. calls used, cmds
used…) on this process, let me know and I will surely
provide them)
The issue is this. When I run my code, the program takes a
while to process everything. And usually the matrices that
I work with in MatLab are on the order of [384x7] in size.
My code works, because I have seen the results saved in
MatLab. However the warning that I always get when the
program is around 2/3 complete is:
Warning: could not start Excel server for export.
XLSWRITE attempts to file in CSV format.
> In xlswrite at 157
> In det_update_decision at 141
(NOTE: 'det_update_decision' is the m-file I wrote, and
line 141 only containes the cmd 'end'.)
I feel that this is an Excel memory-related issue.
Everytime I run my program and it stops due to the above
error, I check the task manager and there are several (>30)
instances of EXCEL.EXE*32's running each taking up ~20,000K
of space in Mem Usage.
Does anybody know what is causing this? And if so, how to
remedy it?
One thing that I tried to do was use the following:
Excel = activexsrv('Excel.Application') to start up an
activexsrv for Excel, and use Excel.Quit at the end of the
code so that I do not have recurring instances of Excel
open in the Task Manager. Is this the correct way to go
about it?
> The issue is this. When I run my code, the program takes a
> while to process everything. And usually the matrices that
> I work with in MatLab are on the order of [384x7] in size.
> I feel that this is an Excel memory-related issue.
xlswrite is very inefficient, in that it does not reuse
existing open XLS server COM connections - it reopens a new
connection with each invocation. This takes a lot of time
and system memory, especially if you run the command in a
loop. I suggest you use xlswrite1 or officedoc, both on the
File Exchange, which reuse open connections. There are a few
other alternatives on the FEX - search around.
> Everytime I run my program and it stops due to the above
> error, I check the task manager and there are several (>30)
> instances of EXCEL.EXE*32's running each taking up ~20,000K
> of space in Mem Usage.
>
> Does anybody know what is causing this? And if so, how to
> remedy it?
xlswrite crashed without bothering to close the open COM
connections... You have no access to these connections and
must delete them via the Task Manager.
> One thing that I tried to do was use the following:
>
> Excel = activexsrv('Excel.Application') to start up an
> activexsrv for Excel, and use Excel.Quit at the end of the
> code so that I do not have recurring instances of Excel
> open in the Task Manager. Is this the correct way to go
> about it?
Yes. You can edit/type xlswrite or xlswrite1 to get started,
or simply use one of the aforementioned FEX submissions.
"Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message
<fd9m41$68t$1@fred.mathworks.com>...
> > The issue is this. When I run my code, the program
takes a
> > while to process everything. And usually the matrices
that
> > I work with in MatLab are on the order of [384x7] in
size.
> > I feel that this is an Excel memory-related issue.
>
> xlswrite is very inefficient, in that it does not reuse
> existing open XLS server COM connections - it reopens a
new
> connection with each invocation. This takes a lot of time
> and system memory, especially if you run the command in a
> loop. I suggest you use xlswrite1 or officedoc, both on
the
> File Exchange, which reuse open connections. There are a
few
> other alternatives on the FEX - search around.
>
> > Everytime I run my program and it stops due to the
above
> > error, I check the task manager and there are several
(>30)
> > instances of EXCEL.EXE*32's running each taking up
~20,000K
> > of space in Mem Usage.
> >
> > Does anybody know what is causing this? And if so, how
to
> > remedy it?
>
> xlswrite crashed without bothering to close the open COM
> connections... You have no access to these connections and
> must delete them via the Task Manager.
>
> > One thing that I tried to do was use the following:
> >
> > Excel = activexsrv('Excel.Application') to start up an
> > activexsrv for Excel, and use Excel.Quit at the end of
the
> > code so that I do not have recurring instances of Excel
> > open in the Task Manager. Is this the correct way to
go
> > about it?
>
> Yes. You can edit/type xlswrite or xlswrite1 to get
started,
> or simply use one of the aforementioned FEX submissions.
>
> Yair Altman
> http://ymasoftware.com
>
Thanks Yair. I have found the xlswrite1 on the FEX and
have attempted to use it via the insructions. However, I
am receiving the following error:
------------------------------------------------------------
??? Error using ==> xlswrite1
No appropriate method or public field sheets for class
handle.
Error in ==> m_file_name at 103
xlswrite1('file_name',1,'sheet_name',range);
------------------------------------------------------------
Does this mean that I am invoking the xlswrite1 function
wrong?
As it is now, at the beginning of my mfile I include (word
for word):
------------------------------------------------------------
Excel = actxserver ('Excel.Application');
File='C:\M_files\M_file';
if ~exist(File,'file')
ExcelWorkbook = Excel.workbooks.Add;
ExcelWorkbook.SaveAs(File,1);
ExcelWorkbook.Close(false);
end
And at the end, word for word:
------------------------------------------------------------
invoke(Excel.ActiveWorkbook,'Save');
Excel.Quit
Excel.delete
clear Excel
------------------------------------------------------------
In addition, where do I store the M-file xlswrite1? Do I
copy the syntax and append it at the end of my code (which
I tried but it doesnt seem to work), or do I save it in the
same folder as the M-file that I'm writing?
> I have found the xlswrite1 on the FEX and
> have attempted to use it via the insructions. However, I
> am receiving the following error: <...>
> Does this mean that I am invoking the xlswrite1 function
> wrong?
> In addition, where do I store the M-file xlswrite1? Do I
> copy the syntax and append it at the end of my code (which
> I tried but it doesnt seem to work), or do I save it in the
> same folder as the M-file that I'm writing?
I suggest you read the function help documentation and/or
contact the author
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.