xlwrite, available at
, enables mac users to write to .xls files. Standard matlab xlswrite function does not work on Mac. One argument of xlwrite is Range, an alpha-numeric value. If writing to an excel document from an array, it may be easier to refer to a column by it's number rather than its character derived name (eg. column 27 rather than column AA). This function enables this. Full explanation and examples given in help file of code. In command window, enter:
Help file reads as follows:
%xlRange(columnNum,rowNum) will return alpha-numeric excel range
% Scott Williams UTS Sydney 18-Apr-15
% This function and number2letter.m to be placed in Matlab folder for
% user defined functions.
% number2letter.m is % user defined function is used in execution
% - available at Mathworks downloads website, enclosed with this file in zip
% Advise to get xlwrite, by Alec De Zegher to use in conjunction with this code:
% -xlswrite has requirements also
%Range=xlRange(1,2)will return alpha-numeric character array 'A2'
% * Will return value -1 if out the range 1<columnNum<702
% * Error checking not exhaustive
% * Written for use with xlwrite, which works up to column 256 (column IV)
% * This function will not work past column 702 (column ZZ)
% * For use in xlwrite, the user defined function on Mathworks
% * xlwrite replaces xlswrite which does not work on Mac
% * Good for use with loops with arrays writing to excel document
% - Use column number of array instead of specifying alpha-numeric range
% * xlwrite is available at:
% Useful if using with array with 256 or less columns
% Usage examples:
%_Between asterisks copied from xlwrite help:
%******* Following commands entered prior to first xlswrite command execution
% * This function requires the POI library to be in your javapath.
% To add the Apache POI Library execute commands:
% (This assumes the POI lib files are in folder 'poi_library')
%1. xlwrite (user defined function for Mac):
% Typical usage may be;
% To enter 'Range' to xls function , say 'D17'
%Range=xlRange(4,17) returns the character array 'D17'
% to print to an array to desktop with filename 1.xls, starting at D17 on 'Sheet1'
% to check desired filepath, right click the file and get info
% Array=rand(20,3) %generates random array 3 columns wide, 20 rows
% Correct syntax for xlwrite to be adhered to.
% should you only want to copy the top part of the variable Array to the same excel file
% use the strcat function for Range:
% say desired range is 'B11:B13' then
% Range2=strcat(xlRange(2,11),':',xlRange(2,13))% returns 'B11:B13'
% Range reading does not seem to exist on mac, may work on PC
% Documentation indicates it should.
% to read cell range B11:F36 from the file example
% Range3=strcat(xlRange(2,11),':',xlRange(6,36))% returns 'B11:F36'
%I will respond to feedback very slowly. Apologies in advance.
Scott Williams (2022). xlRange, number2letter (https://www.mathworks.com/matlabcentral/fileexchange/50545-xlrange-number2letter), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!