xlRange, number2letter
xlwrite, available at
http://www.mathworks.com/matlabcentral/fileexchange/38591-xlwrite--generate-xls-x--files-without-excel-on-mac-linux-win
, 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 xlRange
Help file reads as follows:
%xlRange(columnNum,rowNum) will return alpha-numeric excel range
% Scott Williams UTS Sydney 18-Apr-15
%_
% Requirements:
% 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:
% http://www.mathworks.com/matlabcentral/fileexchange/38591-xlwrite--generate-xls-x--files-without-excel-on-mac-linux-win
% -xlswrite has requirements also
%_
%Range=xlRange(1,2)will return alpha-numeric character array 'A2'
%_
%Limitations:
% * 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)
%Usage:
% * 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')
% javaaddpath('poi_library/poi-3.8-20120326.jar');
% javaaddpath('poi_library/poi-ooxml-3.8-20120326.jar');
% javaaddpath('poi_library/poi-ooxml-schemas-3.8-20120326.jar');
% javaaddpath('poi_library/xmlbeans-2.3.0.jar');
% javaaddpath('poi_library/dom4j-1.6.1.jar');
%******
%_Usage examples
%_
%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
% FilePath='/users/username/desktop/1.xls'
% Array=rand(20,3) %generates random array 3 columns wide, 20 rows
% xlwrite(FilePath,Array,'Sheet1',xlRange(4,17))
% 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'
% xlwrite(FilePath,Array,'Sheet1',Range2)
%2. xlsread
% 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'
%xlsread(FilePath,'Sheet1',Range3)
% _
%I will respond to feedback very slowly. Apologies in advance.
%_
%
引用
Scott Williams (2024). xlRange, number2letter (https://www.mathworks.com/matlabcentral/fileexchange/50545-xlrange-number2letter), MATLAB Central File Exchange. に取得済み.
MATLAB リリースの互換性
プラットフォームの互換性
Windows macOS Linuxカテゴリ
タグ
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!バージョン | 公開済み | リリース ノート | |
---|---|---|---|
1.0.0.0 |