Exchange Workbook in the Application Builder
LiveLink™ also supports workbook exchange with the model in the Application Builder using either a Table form object or dedicated Language Elements.
Exchange Workbook Using a Table Form Object
In the Application Builder you can add a Table form object with the Load from file and/or Save to file toolbars.
See Table section in the COMSOL Multiphysics Application Builder Reference Manual.
When running the application to load data from an Excel workbook click Load from file button and select Microsoft Excel Workbook (*.xlsx) as File format. Once you have selected the file to import, the Excel Load window pops-up.
This is where you specify the worksheet and range where to import the data. In the Range field enter the top-left cell number or the cell range to load only the specified data within the cell range.
Clear Overwrite if you want to keep the data in the current table.
Click Load to import the table.
To save the data available in the table, click Save to file button and select Microsoft Excel Workbook (*.xlsx) as File format. Once you have selected the file where to save, the Excel Save window pops-up.
This is where you specify the worksheet and range where to export the data. In the Range field enter the top-left cell number or the cell range to save only the data that fit the specified cell range.
Clear Overwrite if you want to keep the nonempty cell in the file.
Select Include header if you want also to include the table header in the workbook.
Click Save to export the table.
Exchange Workbook Using the Method Editor
LiveLink™ offers specific language elements in the Application Builder to exchange data between the application and an Excel workbook. These are writeExcelFile and readExcelFile to write to an Excel file and read the data from an Excel file, respectively.
Using the method editor, the file you are working can also be available on the server.
See File Schemes and File Handling section in the COMSOL Multiphysics Application Builder Reference Manual.
You will find below the commands to exchange data with an Excel workbook using the method editor available in the Application Builder.
writeExcelFile(String filename, String[][] data)
Writes the given string data to the first cell onward in the first sheet of an Excel-file.
writeExcelFile(String filename, String sheet, String cell,    String[][] data)
Writes the given string data to the specified cell onward on the specified sheet of an Excel-file.
The strings set in data can defines number, text, or Excel formulas as in the example below:
String [][] data = new String[][] {{"Mydata", "=SUM(4,7)", "5", "=SUM(A1:C1)"}}
String[][] readExcelFile(String filename)
Reads from the first cell onward on the first sheet of an Excel-file into a String[][].
String[][] readExcelFile(String filename, String sheet,    String cell)
Reads from the specified cell onward on the specified sheet of an Excel-file into a String[][].
See the application example Beam Section Calculator (using LiveLink™ for Excel®) in the LiveLink for Excel Application library.