Prerequisite: Apache POI libraries must be downloaded before creating this macro.
Download Apache POI libraries here
We will take an example to read three cell values from an excel sheet .xlsx and update the same in Simcenter STAR-CCM+ coordinate system.
Excel sheet values:
Update the additional library option in STAR-CCM+ so that it can read apache poi libraries:
Goto>>options>>Environment>>Expert>>User macro classpathStep-1:
Copy all the jar files from \\poi-4.1.2\\lib
Copy all the jar files from \\poi-4.1.2\\ooxml-lib
Paste the above jar files into \\poi-4.1.2Step-2:
The image below shows the imports for getting file input, adding exceptions, apache libraries for reading excel cells, sheets, and STAR-CCM+ libraries. Users may need to add or remove imports based on their macro requirements.Step-3:
To run this macro user need to specify the file path to .xlsx in the macroStep-4:
Get row, and column values using XSSFCell class and convert them to double (so that the read value can be assigned in Simcenter STAR-CCM+)Step-5:
Set the read values into Simcenter STAR-CCM+Step-6:
Run the macro
Find attached excel sheet and macro file with this article for your reference.