![]() ![]() Yvan provides detailed documentation of how to use the functions. ![]() Note that Yvan's entry does not provide the functionality the my training customer was asking for, but I pointed him to this You connect to Excel once, do the necessary read/write operations, and disconnect once. Xlsread or xlswrite would suffer a performance hit because of the repeated connect/disconnect that it's doing with Excel. If you need to repeatedly read from or write to an Excel file, I don't mention the true motivation for him creating this. Nonetheless, this is a great suite of functions for connecting MATLAB with Excel. By creating a class that maintains the handles internally as a property, it protects the users This may be good or bad, but perhaps the intent is for users to use the functions provided by this suite and not the ones This handle exposes the user to various methods and properties provided by the Excel application. The hExcel returned from XConnect is a COM.Excel_Application. The other reason for creating a class in this case wouldīe to hide (encapsulate) the actual handles. Of course, you may still need to catch other errors that may occur. You wouldn't have to catch errors resulting from invalid handle inputs. Invisible to everyone except to the class instances. Each of them can be a class, and eachĬlass can contain methods that specifically operate on the instances of the class. Operate on handles that represent the Excel application, workbooks, and worksheets. One suggestion I have for improvement is to convert this into a class, instead of a suite of functions. The editor will highlight the same variables, so you can In fact, if you open the files in the MATLAB Editor, you can place the cursorĪt one of the handle variables to see how they are used or created. How the functions are related to each other. Each of these functions take in various handles (Excel application, workbook, or worksheet) as inputs, so it's easy to understand ![]() He uses intuitive function names, such as XConnect, XOpenBook, and XAddSheet. I chose to highlight Yvan's X Collection, because he provides a suite of functions for performing various simple tasks withinĮxcel, using ActiveX. Sure enough, I found quite a few entries, including this one (and many others) by our very own Brett Shoelson. I started browsing the File Exchange in hopes for finding additional examples that I could point people to for using actxserver with Excel. The reference page for actxserver has an example for connecting to Excel. Once connected to Excel, he can use the various APIs that are provided by Excel to customize. I pointed him to theįunction actxserver, which provides a way to connect to Windows® applications using ActiveX. Specifically, he wanted to change the width of a column and some of the cell colors. The person wanted the ability to control the formatting of cells, which xlswrite does not provide. In the training, we talk about functions like xlsread and xlswrite. Recently during my MATLAB Fundamentals training course, I received a few questions regarding how to exchange data between They feel comfortable in applying the tools in their day-to-day work. I get to take people who have never used MATLAB or Simulink to the point where My day job is a customer training engineer. Jiro's pick this week is The X Collection by Yvan Lengwiler. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |