Thread Subject: problem with xlswrite1

Subject: problem with xlswrite1

From: Isaac

Date: 2 Nov, 2009 12:24:02

Message: 1 of 3

i tried to use xlswrite1 instead of xlswrite and, as i call it from some functions of mine and not from the command line, i changed, as suggested, the first line in

Excel = evalin('caller', 'Excel');

but it gives me the following error:

??? Undefined function or variable 'Excel'.

how can i fix it? :)

thanks

Subject: problem with xlswrite1

From: ImageAnalyst

Date: 2 Nov, 2009 14:02:24

Message: 2 of 3

Are you sure you have Excel installed?
If so, here is the code I use to startup excel, use xlswrite1(), and
shutdown Excel:

%----- Open Excel for writing.
Excel = actxserver('Excel.Application');
if ~exist(excelFileName, 'file')
ExcelWorkbook = Excel.workbooks.Add;
ExcelWorkbook.SaveAs(excelFileName, 1);
ExcelWorkbook.Close(false);
end
Excel.Visible = true; % Make Excel visible.
% Open up workbook.
invoke(Excel.Workbooks, 'Open', excelFileName);
% Save the reference to this workbook so that we can later activate
it, in case we open multiple workbooks.
%wbNumber1 = Excel.ActiveWorkbook;

% Do the actual writing of the data to the open worksheet.
xlswrite1(excelFileName, dataArray, 'MySheetname', 'C3');

invoke(Excel.ActiveWorkbook,'Save'); % Save to disk.

% Shut down Excel.
Excel.Quit
Excel.delete
clear Excel; % Remove variable from workspace.
Good luck,
ImageAnalyst

Subject: problem with xlswrite1

From: Isaac

Date: 3 Nov, 2009 10:18:03

Message: 3 of 3

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <dd23afb5-e324-4eb4-bbf8-e9f72ab20b30@m38g2000yqd.googlegroups.com>...
> Are you sure you have Excel installed?
> If so, here is the code I use to startup excel, use xlswrite1(), and
> shutdown Excel:
>
> %----- Open Excel for writing.
> Excel = actxserver('Excel.Application');
> if ~exist(excelFileName, 'file')
> ExcelWorkbook = Excel.workbooks.Add;
> ExcelWorkbook.SaveAs(excelFileName, 1);
> ExcelWorkbook.Close(false);
> end
> Excel.Visible = true; % Make Excel visible.
> % Open up workbook.
> invoke(Excel.Workbooks, 'Open', excelFileName);
> % Save the reference to this workbook so that we can later activate
> it, in case we open multiple workbooks.
> %wbNumber1 = Excel.ActiveWorkbook;
>
> % Do the actual writing of the data to the open worksheet.
> xlswrite1(excelFileName, dataArray, 'MySheetname', 'C3');
>
> invoke(Excel.ActiveWorkbook,'Save'); % Save to disk.
>
> % Shut down Excel.
> Excel.Quit
> Excel.delete
> clear Excel; % Remove variable from workspace.
> Good luck,
> ImageAnalyst

hi Image :)
yes i have excel installed...
but also the instruction Excel = actxserver('Excel.Application'); gives me error :(((

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com