davidakelley / cbd

Time series data management for Matlab
Other
3 stars 2 forks source link

xlsfile is broken in Matlab 2022a #6

Open davidakelley opened 2 years ago

davidakelley commented 2 years ago

xlsfile fails in Matlab 2022a with the following error:

Error using cbd.xlsfile
Error:File: xlsfile.m Line: 92 Column: 51
Identifier 'workbook' is not a function or a shared variable. To share 'workbook' with a nested function,
initialize it in the current scope. For more information, see Sharing Variables Between Parent and Nested
Functions.

I'm not sure what the long-term fix is since the COM interface seems to have changed somewhat, but a temporary solution appears to be to replace lines 78-101 of xlsfile with the following:

if ~newWb
    obj.xlApp.DisplayAlerts = 0;
    obj.xlApp.workbooks.Open(obj.file, 0, readOnly);
    obj.wkBook = obj.xlApp.ActiveWorkbook;
end

wbProps = get(obj.wkBook);
if wbProps.ReadOnly && ~readOnly
    warning('xlsfile:readOnly', 'Excel file opened read only.');
end

I'll try to circle back on this soon, but this should let you at least use xlsfile in the meantime.