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-4300teamdev.com