Can Matlab read an xls with multiple list values

1 次查看(过去 30 天)
I would like my future Matlab program to read in a xls spreadsheet where some of the values have been selected from a list in said spreadsheet.
Before I continue to create the spreadsheet, I would like to know if Matlab would have any potential issues reading it due to the lists?

回答(1 个)

dpb
dpb 2017-4-1
编辑:dpb 2017-4-1
xslread is limited to reading a contiguous, rectangular area so if your values from the list aren't in such a pattern, "no can do" without additional effort. (It would seem superficially by reading the documentation that a named area selection would work, but on trying it in the past have discovered that while Matlab doesn't throw an error, all one gets if the area isn't contiguous is the UL-most corner of the region, not the whole thing.)
Generally, in Matlab if you must use Excel you'll be better off to just read a whole sheet and do whatever subsetting you need in memory. Otherwise, options are to create an export file format more amenable to data transport or use direct ActiveX/COM interfacing which turns into more of an Excel syntax question than Matlab after open the connection.
  2 个评论
Jay
Jay 2017-4-1
I must not have made myself clear.
I do want Matlab to read the whole sheet then manipulate the data in that spreadsheet.
However the sheet has cell values populated from drop down lists.
Can / does Matlab read the specified values in the sheet or will cells that have values from drop down lists not be read correctly (i.e. not read the value the user has previously selected in excel)?
dpb
dpb 2017-4-2
编辑:dpb 2017-4-2
"...the sheet has cell values populated from drop down lists."
I don't know what that means. The sheet has elements in cells; what you will get from xlsread will be the content of those cells at the time you execute the call from the spreadsheet file when it is opened.
If you have concern about how some feature you're using in Excel works with xlsread I think you'll simply just have to test it and see what it does. However, opening a file and making a change in memory aren't reflected by a change in the returned values to Matlab until those changes in the Excel sheet are committed to disk. Then there's the issue of timing altho if it's manual that's not such an issue but if you're trying to somehow automate this then that can become an issue as well.
If you want to interact with an Excel object, you'll have to write the COM interfacing code yourself.
I notice a good deal of the guts of the Excel iofun functionality is implemented in m-files so there's a fair amount of useful syntax from which one could start, possibly. I find the Excel/VBA syntax so obtuse I almost always just give up before ever get anywhere because I find the documentation is also very difficult to navigate and it's just never been of sufficient interest to spend the time to finally actually learn more than bare rudiments. If, otoh, you do happen to know VBA/Excel pretty well, you can probably get something going relatively easily.

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by