Is it possible to change Calculation Option?

5 views
Skip to first unread message

pablo...@gmail.com

unread,
Apr 18, 2018, 3:09:07 PM4/18/18
to JExcel Forum
Hi!

I wonder if it is possible to change the calculation mode in the Excel Application. My Excel version provides me three options: Manual, Automatic and Automatic Except for Data Tables. I just need to select between the first two.

Thank you,
Pablo

Nataliya Rybynok

unread,
Apr 19, 2018, 4:29:50 AM4/19/18
to pablo...@gmail.com, JExcel Evaluation Support
Hello Pablo,
Thank you for reaching out!

Yes, it is possible to change the calculation mode. However, this functionality is not exposed via the high-level JExcel API, so it is necessary to use the native peers for working with the Calculation property.

Here is the sample code demonstrating the general approach:

private static XlCalculation getCalculation(){ XlCalculation[] result = {new XlCalculation(XlCalculation.xlCalculationAutomatic)}; try { application.getOleMessageLoop().doInvokeAndWait(new Runnable() { @Override public void run() { result[0] = application.getPeer().getCalculation(new Int32(0)); } }); } catch (Exception e) { e.printStackTrace(); } return result[0]; } private static void setCalculation(XlCalculation calculation){ try { application.getOleMessageLoop().doInvokeAndWait(new Runnable() { @Override public void run() { application.getPeer().setCalculation(new Int32(0), calculation); } }); } catch (Exception e) { e.printStackTrace(); } }

In this code, the "application" variable is an instance of com.jniwrapper.win32.jexcel.Application class.
The following sample code demonstrates how to use this approach:

XlCalculation calculation = getCalculation(); setCalculation(new XlCalculation(XlCalculation.xlCalculationManual));

Could you please also share some details about your project? Which company/university do you represent?

Best regards,
Nataliya Rybynok

Customer Service Manager | TeamDev, Ltd.
Phone +380 57 766-4300
teamdev.com


--
You received this message because you are subscribed to the Google Groups "JExcel Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jexcel-forum+unsubscribe@teamdev.com.
To view this discussion on the web visit https://groups.google.com/a/teamdev.com/d/msgid/jexcel-forum/543cc983-2e32-4e19-8044-bc21578a5833%40teamdev.com.

Reply all
Reply to author
Forward
0 new messages