Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
TommasoBelluzzo authored Nov 13, 2020
1 parent 5f1edb3 commit ee1a61d
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions ScriptsDataset/worksheets_batch.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,36 +92,41 @@ function worksheets_batch_internal(file,sheets,names)
wb.Save();
wb.Close();
catch e
warning('MATLAB:SystemicRisk',['An error occurred while cleaning the file ''' file '''.' newline() e.message]);
file_w = strrep(file,filesep(),[filesep() filesep()]);
warning('MATLAB:SystemicRisk',['An error occurred while cleaning the file ''' file_w '''.' newline() e.message]);
end

try
excel.Quit();
delete(excel);
catch e1
warning('MATLAB:SystemicRisk',['An error occurred while disposing the file ''' file ''' (step 1).' newline() e1.message]);
file_w = strrep(file,filesep(),[filesep() filesep()]);

warning('MATLAB:SystemicRisk',['An error occurred while disposing the file ''' file_w ''' (step 1).' newline() e1.message]);

try
delete(excel);
catch e2
warning('MATLAB:SystemicRisk',['An error occurred while disposing the file ''' file ''' (step 2).' newline() e2.message]);
warning('MATLAB:SystemicRisk',['An error occurred while disposing the file ''' file_w ''' (step 2).' newline() e2.message]);
end
end

end

function [sheets,names] = validate_input(sheets,names)

if (numel(sheets) ~= numel(names))
error('The ''sheets'' parameter and the ''names'' parameter must contain the same number of elements.');
end

if (any(cellfun(@(x)~ischar(x)||isempty(x),sheets)))
error('The ''sheets'' parameter contains invalid elements.');
end

if (~isempty(names) && any(cellfun(@(x)~ischar(x)||isempty(x)||(length(x) > 31),names)))
error('The ''names'' parameter contains invalid elements.');
if (~isempty(names))
if (numel(sheets) ~= numel(names))
error('The ''sheets'' parameter and the ''names'' parameter must contain the same number of elements.');
end

if (any(cellfun(@(x)~ischar(x)||isempty(x)||(length(x) > 31),names)))
error('The ''names'' parameter contains invalid elements.');
end
end

end

0 comments on commit ee1a61d

Please sign in to comment.