% 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'
Wei-Rong Chen (2021). Write structure array into Excel sheet (https://www.mathworks.com/matlabcentral/fileexchange/50465-write-structure-array-into-excel-sheet), MATLAB Central File Exchange. Retrieved .
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 exist(outXlsName,'file'), delete(outXlsName);end
xlswrite(outXlsName,xlscell, sheet); <<<--- I removed the IF condition
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!