Wrong retrieving of the isAlignmentApplied() flag on the custom style

Hi,
we’re experiencing an unexpected behavior when working with a custom cell style.

Specifically, after setting the Right alignment on the custom style and then unchecking the “Alignment” checkbox from the custom style configuration UI, the following method:
cell.getStyle().isAlignmentApplied()
still returns true, whereas we would expect it to return false since the alignment flag is no longer applied.

Please find attached a screenshot of the test we performed (you can see the problem on the excel cell F5).
image.png (174,5 KB)

excelCellStyle_AlignmentProblem.zip (7,6 KB)

Could you please check if this is a bug or if there’s something else we need to handle explicitly?
Thanks in advance and available for further information.
Luigi Marino

@luigimarino

Cause

The behavior you’re experiencing with the isAlignmentApplied() method returning true even after unchecking the “Alignment” checkbox in the custom style configuration UI is likely due to how the style properties are managed in Aspose.Cells. Specifically, the alignment setting may still be considered applied because the method checks if the alignment formatting is set, which may not be updated immediately upon changing the UI settings.

Solution

To ensure that the alignment flag is accurately reflected, you need to explicitly reset the alignment settings in your code after modifying the style through the UI. This can be achieved by setting the alignment to a default value or by using the setAlignmentApplied(false) method.

Code

Here’s a code snippet that demonstrates how to reset the alignment setting:

// Assuming 'cell' is your target cell
Style style = cell.getStyle();
style.setAlignmentApplied(false); // Reset the alignment flag
cell.setStyle(style); // Apply the updated style

Next Steps

  1. Implement the above code after you modify the custom style through the UI.
  2. Test if cell.getStyle().isAlignmentApplied() now returns false as expected.
  3. If the issue persists, check if there are any other style properties that might be affecting the alignment state.

Please proceed with these steps, and let me know if you need further assistance!

@luigimarino
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): CELLSJAVA-46409

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.

Please consider using the following sample code once version 25.7 (which is due in the first half of next month) becomes available.:

public static void main(String[] args) throws Throwable {
		  Workbook workbook = new Workbook(dir + "output.xlsx");
		  Style style = workbook.getWorksheets().get(0).getCells().get("F5").getStyle();
		  System.out.println(style.isAlignmentApplied());
		  Style parentStyle = style.getParentStyle();
		  if(parentStyle != null)
		  {
			  System.out.println(parentStyle.isAlignmentApplied());// false
			  System.out.println(parentStyle.getName());
		  }
    }

Please check parentStyle.isAlignmentApplied() of named style.

@luigimarino,

We are pleased to inform you that your issue (Ticket ID: “CELLSJAVA-46409”) has been resolved. The fix will be included in the upcoming release (Aspose.Cells v25.7) that we plan to release in the first half of July 2025. You will be notified when the next version is published.

The issues you have found earlier (filed as CELLSJAVA-46409) have been fixed in Aspose.Cells for Java 25.7.