Fri 18 Sep 2015 08:22:18 PM UTC, comment #1:
(Maybe this rather belongs on the patch tracker.)
I have been thinking about his from the time of the very first spreadsheet interface (COM) I made for the io package.
It would be very nice to have, but then I'd like to have it work for all interfaces and file formats that support named ranges. I'm afraid that's almost all interfaces and formats, then; not only .xlsx.
IOW, this is a substantial bit of work.
In addition some rigid error checking needs to be in place. Nonexistent ranges should be catched and treated in an intelligent way. E.g., xls2oct shouldn't just error out because when it was called from xlsread, the file pointer would vanish from scope but the operating system and/or JVM could still have zombies with spreadsheet data becoming inaccessible until the next reboot. Instead xls2oct should rather return with an empty data array but emit some warning. Where I write xls2oct I also mean the related interface-specific private functions.
And so forth. Some more thinking is required before this can be implemented.
Another issue is scope: some names only pertain to individual sheets, others to the entire workbook. That has to be tackled as well.
I think get_definedNames had better be called something like "getNamedRanges" or so and should be a private func, to be called by the spreadsheet routines when some data range is specified by the user and allowing validation. It should branch to respective spreadsheet interface-specific subfunctions in private/ named like "__OCT_xlsx_nmranges__.m", "__JOD_ods_nmranges__.m", etc.
As to user exposure, I think returning info on named ranges would be a nice and well-fitting extension for xlsfinfo.m (and odsfinfo.m).
xlsfinfo.m already does more than its Matlab sibling (ie., it returns occupied data ranges) so even more useful info wouldn't hurt :-) it could return a 4th output arg with the named ranges.
All in all I consider this to be welcome support for an old plan :-)
Thanks!
I'll set status to "postponed", but I'll start working on it - yet at slow pace. If you want to cooperate, email me privately.
(and some nitty-gritty:
- when just reading, call xlsopen with 0 for 2nd arg, just to be safe
- personally I would replace the while loop by a regexp.
For the rest I think you've clearly catched the spirit of the io package programming style ;-) )
|