Code covered by the BSD License  

Highlights from
xlwrite: Generate XLS(X) files without Excel on Mac/Linux/Win

image thumbnail

xlwrite: Generate XLS(X) files without Excel on Mac/Linux/Win

by

 

12 Oct 2012 (Updated )

Generates ‘.xls’ & '.xlsx' files on Mac/Linux/Win without Excel, using same syntax as xlswrite.

Test_xlWrite.m
%% Small demonstration on how to use XLWRITE

%% Initialisation of POI Libs
% Add Java POI Libs to matlab javapath
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');
javaaddpath('poi_library/stax-api-1.0.1.jar');

%% Data Generation for XLSX
% Define an xls name
fileName = 'test_xlwrite.xlsx';
sheetName = 'this_is_sheetname';
startRange = 'B3';

% Generate some data
xlsData = {'A Number' 'Boolean Data' 'Empty Cells' 'Strings';...
    1 true [] 'String Text';...
    5 false [] 'Another very descriptive text';...
    -6.26 false 'This should have been an empty cell but I made an error' 'This is text';...
    1e8 true [] 'Last cell with text';...
    1e3 false NaN NaN;...
    1e2 true [] 'test'}

%% Generate XLSX file
xlwrite(fileName, xlsData, sheetName, startRange);

Contact us