No BSD License  

Highlights from
xlswritespec

5.0

5.0 | 5 ratings Rate this file 14 Downloads (last 30 days) File Size: 16.2 KB File ID: #8345
image thumbnail

xlswritespec

by Chandramouli Chandrasekaran

 

23 Aug 2005 (Updated 23 Aug 2005)

Allows you to format your output when you export to Excel.

| Watch this File

File Information
Description

The script performs the same function as xlswrite with the added functionality of formatting the data at the particular location written into, so for example if you want to write headers in blue and numbers in gold, you can do this. The example below illustrates how you can write 400 random numbers into a file using the modified script and the original script from MATLAB 7.0, I hope the formatted one looks cleaner to you

Data = rand(20,20)
params.Bold = 'false';
params.FontSize = 10;
params.FontName = 'Verdana';
params.ColorIndex = 14;
params.NumberFormat = '0.000';
xlswritespec('Exemplar.xls',Data,'Example',['B2'],params)
xlswrite('Exemplar.xls',Data,'Example',['B26'])

Hope the script is useful, I am not responsible for any hair loss, money, gray hair or other good / bad things which happen. The script is extremely useful for me and I thought I should try to share it. Oh I would like to acknowledge xlswrite for the basic structure, I just hacked in a few more lines, I cannot be bothered looking up the file ID.

MATLAB release MATLAB 7.0.1 (R14SP1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (9)
23 Aug 2005 Garner Izru

For me, it's useful. Thanks!

14 Dec 2005 Flemming Møller

Excellent! Very usefull and defently must have for xlswrite users!

08 Feb 2006 Clemens Otte

If you use it, you should check whether the Excel process is really terminated after calling xlswritespec.

There seems to be a general problem with the COM interface that the Excel process is NOT terminated. As each call of xlswritespec starts a new process, but does not remove it, you may run into problems.
BTW: The original code of Matlab's xlswrite has the same problem.

24 Nov 2006 Unai Cornes

It does not work for me.... the data is sent to Excel, but "params" are not.

25 May 2007 Aaron Urbas

Excellent function, works great for me. For those interested, you can modify this function to include text underlining by adding the line below to the function where the other parameters are set:

Excel.selection.Font.Underline = params(1).Underline;

and, of course, adding 'Underline' to the list of parameters. I found that the following integer values give:
1 - no underline
2 - single underline (normal Excel underline)
3 - double underline
4 - single underline, extra whitespace between bottom of number and line
5 - double underline, extra whitespace between bottom of number and line

17 Oct 2007 nour ould cher

thank

23 Apr 2008 mariem bakhouche

hello
please i want to know how to export points(data) from matlab to excel for drawing histogramme?

17 Jul 2008 Jonathan Burnage

Many thanks for this most useful function. Is it possible to add the capability to set the horizontal alignment of the text within the selection? I have tried making a macro and then copying the code but this does not seem to work.

Thanks again.

Jonathan

12 Aug 2008 Lisa Lewis

Thank you for an extremely helpful function!

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
data import Chandramouli Chandrasekaran 22 Oct 2008 07:56:25
data export Chandramouli Chandrasekaran 22 Oct 2008 07:56:25
colors Chandramouli Chandrasekaran 22 Oct 2008 07:56:25
output Chandramouli Chandrasekaran 22 Oct 2008 07:56:25
formatting export to excel Chandramouli Chandrasekaran 22 Oct 2008 07:56:25
utilities Chandramouli Chandrasekaran 22 Oct 2008 07:56:26
data Chandramouli Chandrasekaran 22 Oct 2008 07:56:26

Contact us at files@mathworks.com