File Exchange

image thumbnail

Write structure array into Excel sheet

version 1.0 (6.68 KB) by Wei-Rong Chen
Write a structure array into Excel sheet


Updated 11 Apr 2015

View License

% usage: xlscell=WriteXlsFromStruct(DataStruct, outXlsName, sheet, ifOvewriteExist);
% This function writes a 1x1 structure array into Excel file.
% Each field in the input structure containes the data of a column in the output Excel sheet.
% See the sample 'xlsStruct.mat' for the format of the input structure array.
% The data struct conforms to the output struct generated by 'xls2struct.m'.
% 'ifOvewriteExist': Whether or not overwrite existing output Excel file.
% See also 'xls2struct.m'

Cite As

Wei-Rong Chen (2021). Write structure array into Excel sheet (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (3)

Veronica Taurino

Hi! I changed a bit the last part because I had a trouble, the function didn't overwrite when I asked.
In this way, when I call the function with a 0 value for 'ifOvewriteExist', it create the .XLS if it does
not exist, otherwise overwrites it. I removed 'if ~exist(outXlsName,'file')', because for my purpose, it does
not contemplate the case my .XLS is already existing.
Thank you for your job

if ifOvewriteExist
if exist(outXlsName,'file'), delete(outXlsName);end
xlswrite(outXlsName,xlscell, sheet);
xlswrite(outXlsName,xlscell, sheet); <<<--- I removed the IF condition

Mason Karbassian

Andres Ojeda Laguna

MATLAB Release Compatibility
Created with R2008a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!