Application Center - Maplesoft

App Preview:

Excel Integration with Maple

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application


 

Typesetting:-mrow(Typesetting:-mi(Image 

Excel Integration with Maple

Copyright Maplesoft, a division of Waterloo Maple Inc., 2007Typesetting:-mrow(Typesetting:-mi( 

Introduction 

 

 

With the release of Maple 11, data integration from Excel? data files has become a smooth and virtually effortless process.   

 

This tips and techniques article will demonstrate how to import Excel generated data,  modify it, and then export the data as an Excel spreadsheet.  It will also cover what the Maple Excel add-in is and provide an example of how to use it.   

Typesetting:-mrow(Typesetting:-mi(Image 

               

How can I import Excel data? 

Maple 11 supports .xls files which can be imported using the interactive assistant or by calling the corresponding command.  

 

Using the interactive assistant: 

  • Click on -
    Tools > Assistants > Import Data...

    The Data Import Assistant dialogue box should open

  • Navigate to and select the Excel File (see Figure 1 for a visual representation of steps 1 and 2)

  • Click Next.  Here you have the choice of importing an entire sheet or a specific range of cells.  

    If you would like to import the full sheet you can select the sheet name from the drop down box in the Sheet field and leave the Named Range field blank.  The Sheet field will default to the first sheet in the Excel file.  

    If you would like to import partial data from the spreadsheet you can do so by selecting the sheet name in the Sheet field and then specify the cell range in the Name Range field.  To specify a range of cells, the format must be
    <first cell>:<last cell>, see Figure 2.
 

Typesetting:-mrow(Typesetting:-mi( 

Image 

 

Typesetting:-mrow(Typesetting:-mi( 

Image 

To do this programmatically, the command needed is ExcelTools[Import].   

Entering the following command will launch the Data Import Assistant. 

> Typesetting:-mrow(Typesetting:-mi(
 

However, if you do not want to use the interactive assistant at all, you do have the option of specifying any (or all) of the following parameters: file name, sheet name, range of cells. 

For example:  

> Typesetting:-mrow(Typesetting:-mi(
> Typesetting:-mrow(Typesetting:-mi(
> Typesetting:-mrow(Typesetting:-mi(

Then the data is imported into your document as a 2 dimensional Array (which is stored as an rtable), with both indices starting from 1.   

For the Maple help page click here

Modifying the data  

Once the data has been imported, it becomes a Maple object and you do have the ability to make changes.  To modify the data double click on the summary format to launch the Matrix Browser.   The Matrix Browser will display your data and changes can be made, after you have made the necessary changes click Done.     

You also have the option to modify the data using Maple commands, as with any other Array.        

Note - By default, the summary format is displayed if the rtable imported is greater than a 10 by 10 Array.    

How can I export data as an Excel file? 

In Maple, large arrays, vectors, matrices, or higher dimensional rtables are displayed using a summary format.  The contents of these objects are hidden and can be viewed by using the interactive Matrix Browser.  Along with displaying the contents and providing the ability to make changes to the data, this interactive tool allows you to export data to an Excel spreadsheet.
 To launch the Matrix Browser, double-click the object, that is, the summary format.  If you would like to make any changes to your data, you can do so here by clicking in the cell and modifying the contents.
 Click the Export button in the Browse Matrix. The Export to Excel dialog opens.
 

  • Select the spreadsheet to which to export data by clicking the Browse button.

  • Select the Sheet Name: Sheet 1, 2, or 3.

  • (Optional) Enter the spreadsheet cell into which to enter the data. By default, the data is loaded starting in cell A1.

  • Click OK. The dialog closes. Click Done to close the Matrix Browser.
 

Note - If the file you are trying to save to is open or in use you will receive an error message 'file not found'. Ensure that the file selected is closed. 

Image 

 

To access these tools using the commands you would use ExcelTools[Export].  Unlike the Import command, this command requires at least one parameter - the name of the Array to be exported.  You can still specify a file name, sheet name, and cell range respectively, although these parameters are optional. 

The command below will launch the interactive Export to Excel dialogue box.  

> Typesetting:-mrow(Typesetting:-mi(

To avoid interacting with the dialogue box you will need to specify the Array to be exported along with a file name.  The other parameters, sheet name, and cell range remain optional. 

For example:  

> Typesetting:-mrow(Typesetting:-mi(
> Typesetting:-mrow(Typesetting:-mi(
 

For the Maple help page, click here

How do I use the Maple Excel Add-in? 

The Maple Excel add-in allows you to call Maple commands from within an Excel Spreadsheet 

 

To enable the Maple Excel Add-in:
From Excel's Tools menu, choose Add-Ins  

  • Select the Maple Excel Add-in check box

  • Click OK
 

Note - If you are using a version of Microsoft? Office that is not English, French, or German, the Maple Excel Add-in is not listed. To make the Add-in available:
a) Click Browse and navigate to the directory in which Maple is installed.
b) In the Excel directory, select the WMIMPLEX.xla file.
c) Click OK.   

With this add-in you have access to a subset of the Mathematics section of the Maple help system and a Maple Function Wizard to step you through the creation of a Maple function call.  

For the Maple help page click here

Example 

This example will demonstrate how the Maple Excel add-in works.  It will calculate the derivative of a function, plot the function and its derivative, and display the results inside Excel.   

  • Type the following basic formula in cell A1. The '=Maple' will call Maple from Excel and compute the result, x2, which will be displayed as the value for cell A1.
    =Maple("(x*x)")

  • In cell A2 enter x.  We will use this value when we take the derivative of cell A1.

  • In cell A3 enter the following
    =Maple("diff(&1,&2)",A1,A2)

    This will connect to Maple and compute the result, 2*x, which will be displayed as the value for cell A3.The symbol &1 is the placeholder for the value in cell A1, likewise the symbol &2 is the placeholder for the value in cell A2.

  • In cell A4 type the following formula
    =Maple("plot({&1,&2},x=-5..5)",A1,A3)

    This will connect to Maple to construct the plot of the functions x2 and 2x over the interval [-5,5].  The result will be displayed inside Excel, as below.

     

    Image  

 

Legal Notice: The copyright for this application is owned by Maplesoft. The application is intended to demonstrate the use of Maple to solve a particular problem. It has been made available for product evaluation purposes only and may not be used in any other context without the express permission of Maplesoft. 

Image