File Exchange

image thumbnail

xlsfont, xlsalign, xlsborder, xlswordart, xlscomment

version 1.0 (8.64 KB) by

5 functions to modify Microsoft Excel cell format & adds comments and WordArt

13 Downloads

Updated

View License

Look at functions help for more details and descriptions. Also included (PDF) file showing Excel Color Index to be used for specifying colors in those functions.

Examples:

xlsfont('file.xls','Sheet1','whole','font','Courier New');
xlsfont('file.xls','Sheet1','2:2','interior',1,11,4);
xlsfont('file.xls','Sheet1','A1','underline',3);

xlsalign('file.xls','Sheet1','A1:A2','MergeCells',1);
xlsalign('file.xls','Sheet1','A1:A2','Horizontal',3,'WrapText',1);
xlsalign('file.xls','Sheet1','A1:A2','Orientation',90,'ShrinkToFit',1);

xlsborder('file.xls','Sheet1','A1:A2','Box',1,2,1);
xlsborder('file.xls','Sheet1','A1:B2','Cross',6,4,5);
xlsborder('file.xls','Sheet1','A1:A2','EdgeTop',1,2,1,'EdgeBottom',4,3,3);

xlswordart('file.xls','Sheet1',7,'My Profile!',30,'Impact',1,1,50,50);

xlscomment('file.xls','Sheet1','B4','This is my Comment!',1)

Comments and Ratings (11)

Jan Siroky

Thank you, this is a great set of tools.

Bellow you can find a modification of xlscomment function that can write multiple comments.

function xlscomment(filename,sheetname,cells,comments,visible)

[fpath,file,ext] = fileparts(char(filename));
if isempty(fpath)
fpath = pwd;
end
Excel = actxserver('Excel.Application');
set(Excel,'Visible',0);
Workbook = invoke(Excel.Workbooks, 'open', [fpath filesep file ext]);
sheet = get(Excel.Worksheets, 'Item',sheetname);
invoke(sheet,'Activate');

% Adding Comments to a Cells !
for i=1:numel(comments)
X = get(Excel.ActiveSheet,'Range',cells{i});
X.Select;
try
X.AddComment;
catch
warning('comment already exists ... now replaced with new one');
end
set(X.Comment,'Visible',visible);
invoke(X.Comment,'Text',comments{i});
end
invoke(Workbook, 'Save');
invoke(Excel, 'Quit');
delete(Excel);

Han Oostdijk

Liaofan Lin

Great tool!

Mohammad

Super cool

Eric

Eric (view profile)

Well done. Note to users, to highlight/fill/color a cell in red, use a command something like:
xlsfont('file.xls','Sheet1','A1:A1','interior',3,0,3);

Read the documentation on this script for further explanation.

thanks a lot for these very useful functions!!
just one thing, the pdf is not included in the .zip!

Sahin Aktas

Aviator

This is great absolutely handy and well-written. This was what I was looking for for a long time.... Thanks. Keep up the good work.

J W

Very useful, I have been looking for this for long time....

g l

Not sure why nobody commented. But these are exactly what I am looking for!

MATLAB Release
MATLAB 6.5 (R13)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today