Mathematica notebooks can automatically generate an associated package file. This provides an easy way for you to export a set of Mathematica function definitions you would like to use in an Excel workbook. With this in mind, on the Excel side, the MathematicaLink add-in checks for a package file with the same name in the same directory when initializing a workbook. If one is found, the code in the file is considered the initialization code for the workbook. Here is how to create a package file from a notebook, then use the contents of the package file as initialization code in a workbook:
You should now have .nb, .m, and .xls files in the same directory with the same name. In the future, every time you save changes to the notebook, the package file is automatically updated. In turn, the next time you evaluate in Excel, the new set of function definitions will be automatically loaded and used. Notes • Using the package approach, you can easily develop and update function definitions for a workbook. However, you must remember to send the package file along with the workbook to enable others to interact with the workbook. • During development, be sure to save changes to your Mathematica notebook in order to update the package file before using it from the Excel side. |