Aspose.Words calculates these formulas correctly:
A1+B1
A1*B1
(A1>0) // returns 1 when not empty
(B1>0) // returns 1 when not empty
But fails when they get combined into one:
(A1>0) * (B1>0) * (A1+B1) // should return A1+B1 when both of them are not empty
Here is the sample code and Word document which reproduces the issue:
var doc = new Aspose.Words.Document("Result.DOCX");
doc.UpdateFields();
doc.Save("test.pdf", Aspose.Words.SaveFormat.Pdf);
Result.docx (14.1 KB)
@kaiwachter
It seems you’re encountering an issue with the formula (A1>0)*(B1>0)*(A1+B1)
not calculating as expected in Aspose.Words. This formula should return the sum of A1
and B1
when both are greater than zero, but it appears to be failing in this case.
Cause: The issue may stem from incorrect field codes, outdated field values, or the presence of empty or non-numeric values in A1
and B1
.
Solution: Here’s a step-by-step approach to troubleshoot and resolve the issue:
-
Check Field Codes: Ensure that the field codes in your Word document are correctly set up. You can toggle field codes in Word by pressing Alt + F9
to see if the formula is being interpreted correctly.
-
Update Fields: Make sure that you are calling doc.UpdateFields()
before saving the document. This ensures that all fields are recalculated based on the latest values.
-
Test Simplified Formulas: Since you mentioned that simpler formulas like A1+B1
and A1*B1
work correctly, try breaking down the complex formula into smaller parts to see where it fails. For example, test (A1>0)*(B1>0)
separately to confirm it returns the expected boolean result.
-
Check for Empty Values: Ensure that A1
and B1
are not empty or contain non-numeric values, as this could affect the calculation.
-
Review Documentation: If the issue persists, consider reviewing the Aspose.Words documentation for any specific notes on formula calculations or limitations.
Here’s a minimal code snippet to ensure you are updating fields correctly:
var doc = new Aspose.Words.Document("Result.DOCX");
doc.UpdateFields(); // Ensure fields are updated
doc.Save("D:\\test.pdf", Aspose.Words.SaveFormat.Pdf);
Next Steps: If you follow these steps and still face issues, please share any error messages or unexpected results you encounter. This will help in diagnosing the problem further.
Let me know if that helps!
@kaiwachter
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): WORDSNET-28506
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
The issues you have found earlier (filed as WORDSNET-28506) have been fixed in this Aspose.Words for .NET 25.9 update also available on NuGet.