Rank: 1125 based on 126 downloads (last 30 days) and 1 file submitted
photo

Matt Swartz

E-mail

Personal Profile:

 

Watch this Author's files

 

Files Posted by Matt Swartz
Updated   File Tags Downloads
(last 30 days)
Comments Rating
21 Mar 2006 xlswrite1 increases speed of xlswrite function when used in loops or multiple times. Author: Matt Swartz data import, data export, xlswrite increased sp... 126 52
  • 4.86486
4.9 | 39 ratings
Comments and Ratings on Matt Swartz's Files View all
Updated File Comment by Comments Rating
11 Sep 2014 xlswrite1 increases speed of xlswrite function when used in loops or multiple times. Author: Matt Swartz kyle

Hello, I am encountering a problem with this function when writing an array with a large number of columns. The data gets written, but the Excel range to write to is incorrect, so it ends up writing a whole bunch of columns with #N/A.

I've dug into the xlswrite1 function and it appears the problem is in the function dec2base27(d). For my example below, the end column should be DGB, but it creates it as GGB. I don't see this problem with smaller data sets however.

My example:
Excel = actxserver('Excel.Application');
% Show window (optional).
Excel.Visible = 0;
% Open file located in the current folder.
Workbook = Excel.Workbooks.Open('TEST.xlsx');

data = ones(50,2887);
xlswrite1('TEST.xlsx',data,'Sheet1','B1');

Workbook.Save;
Excel.Quit;
Excel.release;

Thank you very much!

15 Aug 2014 xlswrite1 increases speed of xlswrite function when used in loops or multiple times. Author: Matt Swartz Claire

To follow up on the error I saw before... I added a try - catch block. In case invoke fails, try again. This solved my problem posted below.

try
invoke(Excel.Workbooks,'Open',fileNameFull);
catch
Excel.Quit;
Excel.delete;
clear Excel;
Excel = actxserver('Excel.Application');
invoke(Excel.Workbooks,'Open',fileNameFull);
end

29 Jul 2014 xlswrite1 increases speed of xlswrite function when used in loops or multiple times. Author: Matt Swartz Claire

Error using Interface.000208DB_0000_0000_C000_000000000046/Open
Invoke Error, Dispatch Exception:
Source: Microsoft Excel
Description: Open method of Workbooks class failed
Help File: xlmain11.chm
Help Context ID: 0

This is the error I message I received.

23 Jul 2014 xlswrite1 increases speed of xlswrite function when used in loops or multiple times. Author: Matt Swartz Irene

Hello, I have a little problem running this function.
I opened the activex server and all, specifing an existing .xls file, and also changed the second line of the script with 'caller', but still is giving me an error.

The error I got is:

Error using xlswrite1 (line 143)
Error: Object returned error code: 0x800A03EC

Error in xlswrite1 (line 143)
error('MATLAB:xlswrite:SelectDataRange',lasterr);

The error seems to be in the range I specify, but I call it as I used to do with xlswrite, so having something like 'A1:B1'.

I'm working on windows 7, matlab 2012b and excel 2007 (italian version, thus the sheet is originally named as 'Foglio1' instead of 'Sheet1', but I also have manually changed it in the xls file).
Thank you very much in advance.

23 Jul 2014 xlswrite1 increases speed of xlswrite function when used in loops or multiple times. Author: Matt Swartz Sheldon

ActiveX is not available on Mac OS. So this solution is Windows only. If you are doing a lot of xls writing on a Mac, I'd suggest using csvwrite, which is much quicker than xlswrite, and then just opening the csv in Excel.

A csv file, is a text document, with each column separated by a comma and each row on a new line. It can be opened in Excel, and quite easily saved as an excel file.

Contact us