Code covered by the BSD License  

Highlights from
xlswrite2007

4.0

4.0 | 1 rating Rate this file 17 Downloads (last 30 days) File Size: 5.19 KB File ID: #25288

xlswrite2007

by Travis

 

11 Sep 2009

This greatly speeds up xlswrite when you are using it multiple times.

| Watch this File

File Information
Description

%This code increases the speed of the xlswrite and works with Excel 2007
%function when used in loops or multiple times. The problem with the original function
%is that it opens and closes the Excel server every time the function is used.
%To increase the speed I have just edited the original function by removing the
%server open and close function from the xlswrite function and moved them outside
%of the function. To use this first run the following code which opens the activex
%server and checks to see if the file already exists (creates if it doesnt):
 
% Excel = actxserver('Excel.Application');
% File = 'C:\Folder\File'; %Make sure you put the whole path
% if ~exist(File,'file')
% ExcelWorkbook = Excel.workbooks.Add;
% ExcelWorkbook.SaveAs(File)
% ExcelWorkbook.Close(false);
% end
% ExcelWorkbook = Excel.workbooks.Open(File);
 
%Then run the new xlswrite2007 function as many times as needed
%or in a loop (for example xlswrite2007(File,data,location).
%Then run the following code to close the activex server:
 
% ExcelWorkbook.Save
% ExcelWorkbook.Close(false) % Close Excel workbook.
% Excel.Quit;
% delete(Excel);

% This is a modern version of xlswrite1 posted by Matt Swartz in 2006, and
% as such most of these comments are copied from his original post

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
xlswrite1

MATLAB release MATLAB 7.7 (R2008b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
25 Oct 2011 Ngai-Hang

I had to change the line Excel=evalin('base','Excel');
to
Excel = evalin('caller', 'Excel');
to get it to work on my machine.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
xlswrite Travis 11 Sep 2009 14:59:08
excel 2007 Travis 11 Sep 2009 14:59:09
xlswrite DÉBORA 27 Dec 2011 16:24:59

Contact us at files@mathworks.com