Skip to main content



      Home
Home » Modeling » Epsilon » Loading Excel file in Ant
Loading Excel file in Ant [message #1865274] Mon, 29 April 2024 15:16 Go to next message
Eclipse UserFriend
Hi,

I am trying to load an Excel file to pass to an EOL file in my Ant workflow. I am trying to load it using the code below based on the example in [1].

<epsilon.loadModel name="E" impl = 'org.eclipse.epsilon.emc.spreadsheets.excel.ExcelModel'>
<parameter name ="SPREADSHEET_FILE" file = "excel.xlsx"/>
<parameter name ="CONFIGURATION_FILE" file = "mapping.xml"/>
</epsilon.loadModel>

But the code throws this error: java.lang.NullPointerException: Cannot invoke "org.eclipse.epsilon.common.dt.launching.extensions.ModelTypeExtension.createModel()" because the return value of "org.eclipse.epsilon.common.dt.launching.extensions.ModelTypeExtension.forType(String)" is null

Thanks for your help

[1] https://eclipse.dev/epsilon/doc/articles/running-epsilon-ant-tasks-from-command-line/
Re: Loading Excel file in Ant [message #1865298 is a reply to message #1865274] Tue, 30 April 2024 09:45 Go to previous messageGo to next message
Eclipse UserFriend
Hi Nick,

Could you please share a minimal example we can use to reproduce this?

Thanks,
Dimitris
Re: Loading Excel file in Ant [message #1865307 is a reply to message #1865298] Tue, 30 April 2024 10:38 Go to previous messageGo to next message
Eclipse UserFriend
Hi Dimitris,

I have emailed the minimal example. Essentially I just added a build file containing the following to the org.eclipse.epsilon.examples.excel.formulas example to launch the EOL example from Ant.

<project>
<target name="main">

<epsilon.loadModel name="M" impl = "org.eclipse.epsilon.emc.spreadsheets.excel.ExcelModel">
<parameter name ="SPREADSHEET_FILE" file = "new-spreadsheet.xlsx"/>
<parameter name ="CONFIGURATION_FILE" file = "mapping.xml"/>
</epsilon.loadModel>

<epsilon.eol src="create-spreadsheet-with-formulas.eol">
<model ref="M"/>
</epsilon.eol>
</target>
</project>

[Updated on: Tue, 30 April 2024 10:42] by Moderator

Re: Loading Excel file in Ant [message #1865310 is a reply to message #1865307] Tue, 30 April 2024 10:43 Go to previous messageGo to next message
Eclipse UserFriend
Hi Nick,

I've been able to run your minimal example in 2.4 without issues. Could you please check that the "Run in the same JRE as the workspace" option is selected in the "JRE" tab of your ANT run configuration?

Thanks,
Dimitris
Re: Loading Excel file in Ant [message #1865313 is a reply to message #1865310] Tue, 30 April 2024 10:50 Go to previous messageGo to next message
Eclipse UserFriend
Hi Dimitris,

Thanks for the quick response!

I have it selected, I get a different error without that. I forgot to add default='main' to the Ant file, so maybe it is running nothing. The build file should be

<project default='main'>
<target name="main">

<epsilon.loadModel name="M" impl = "org.eclipse.epsilon.emc.spreadsheets.excel.ExcelModel">
<parameter name ="SPREADSHEET_FILE" file = "new-spreadsheet.xlsx"/>
<parameter name ="CONFIGURATION_FILE" file = "mapping.xml"/>
</epsilon.loadModel>

<epsilon.eol src="create-spreadsheet-with-formulas.eol">
<model ref="M"/>
</epsilon.eol>
</target>
</project>
Re: Loading Excel file in Ant [message #1865316 is a reply to message #1865313] Tue, 30 April 2024 10:59 Go to previous messageGo to next message
Eclipse UserFriend
Changing the epsilon.loadModel line as follows should do the trick:

<epsilon.loadModel name="E" type="ExcelModel" impl = "org.eclipse.epsilon.emc.spreadsheets.excel.ExcelModel">


Thanks,
Dimitris
Re: Loading Excel file in Ant [message #1865319 is a reply to message #1865316] Tue, 30 April 2024 12:09 Go to previous messageGo to next message
Eclipse UserFriend
That worked, thank you!

I have run into another issue though. I am trying to automatically generate an Excel template based on a metamodel that can be used to create instances of it. My idea was that I would start with a blank excel file, and then add sheets/columns and generate the mapping file as needed. The issue is that the new column headers are not being saved in the Excel file, even though I can see it exists and write to the rows in EOL. To modify the minimal example:

1) Change the line as you suggested in your last reply
2) Delete this line from build.xml in case the mapping caused an issue: <parameter name ="CONFIGURATION_FILE" file = "mapping.xml"/>
3) Replace content of create-spreadsheet-with-formulas.eol with:

var w = M.worksheets.selectOne(w|w.name.equals('Calc'));
w.addColumn(3,"newColumn");

var calc : new Calc;

calc.a = 1;
calc.b = 2;
calc.sum = "=A2+B2";
calc.newColumn = 5;

calc.sum.println(); // Prints 3
calc.newColumn.println(); // Prints 5

M.store();



Column D in the excel file has no header, but the 5 was added.

[Updated on: Tue, 30 April 2024 12:15] by Moderator

Re: Loading Excel file in Ant [message #1865322 is a reply to message #1865319] Tue, 30 April 2024 12:36 Go to previous messageGo to next message
Eclipse UserFriend
Adding columns/worksheets to a spreadsheet was not really within the use-cases we considered when we developed the Excel driver. Your best bet is to keep exploring the driver's Java API and calling its methods from EOL as you've been doing so far.

Thanks,
Dimitris
Re: Loading Excel file in Ant [message #1865325 is a reply to message #1865322] Tue, 30 April 2024 12:50 Go to previous messageGo to next message
Eclipse UserFriend
Ok thank you for the help!

About the API documentation, I was able to find Epsilon 2.3.0-SNAPSHOT API online and have been looking in that. The link on the Epsilon website for the current version leads to a page with some downloads and I'm not quite sure how to browse from that
Re: Loading Excel file in Ant [message #1865328 is a reply to message #1865325] Tue, 30 April 2024 13:07 Go to previous messageGo to next message
Eclipse UserFriend
Hmmm - this looks like a regression. I've created an issue and will look into this.

Thanks,
Dimitris
Re: Loading Excel file in Ant [message #1865340 is a reply to message #1865274] Tue, 30 April 2024 14:27 Go to previous message
Eclipse UserFriend
The interim Javadocs page should work now:

https://download.eclipse.org/epsilon/interim-javadoc/

Getting Javadocs for older releases will need a bit more thought on how we organise things. I'll discuss how to approach that with Dimitris.
Previous Topic:Alternative way to create references using EOL
Next Topic:Using EGL to instantiate an excel file
Goto Forum:
  


Current Time: Sat Oct 25 20:30:45 EDT 2025

Powered by FUDForum. Page generated in 0.05095 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top