Applying alignment style for SpredSheetML in .NET


I observe different approach in applying alignment style settings between Aspos.Cells and Excel.

In example SpreadSheetML I got set two styles one default with alignment vertical and horizontal set and one custom with set only vertical alignment.

  <Style ss:ID="Default" ss:Name="Normal">  
    <Alignment ss:Vertical="Bottom" ss:Horizontal="Left"/>  
    <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"/>  
  <Style ss:ID="TestAlignment">
    <Alignment ss:Vertical="Top" ss:ReadingOrder="LeftToRight" />
    <Borders />
    <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"/>
    <Interior />

and got two rows first will use default style second custom

  <Cell><Data ss:Type="Number">1</Data></Cell>  
  <Cell><Data ss:Type="Number">2</Data></Cell>  
  <Cell ss:StyleID="TestAlignment">
    <Data ss:Type="String">Test</Data>
  <Cell ss:StyleID="TestAlignment">
    <Data ss:Type="Number">2</Data>

When we compare directly open spreadsheetML in Excel with xlsx file created using Aspose.Cell base on the same spreadsheetML we see that alignment is set differently. Cells A1 and B2 in example here spreadsheetML was open directly in Excel have set only Vertical = Top alignment as it is set TestAlignment style and Horizontal was set to default value (General). On file from Aspose.Cells situation is different the same calls have got Vertical = Top and Horizontal = Left. So it looks like Excel approach is to use settings only from style assign for current cell ignoring Default style settings. Aspose.Cells approach is to merge style settings, we got Vertical setting from cell style TestAlignment and Horizontal setting from Default style.

This can be observe on attached screenshot

spreadsheet_alignment.png (22.9 KB)

Aspose.Cells approach seems to be in good approach because general style got update values from more details styles but because in Excel it works different (not necessary fine) I think that this should be change to way as Excel is handling it.



Thanks for considering Aspose APIs.

We were able to observe the issue and logged it in our database for investigation and for a fix. Once, the issue is resolved or we have some other news for you, we will let you know asap.

This issue has been logged as

  • CELLSNET-45673 - Alignment style applying for SpredSheetML


Thanks for using Aspose APIs.

This is to inform you that we have fixed your issue CELLSNET-45673 now. We will soon provide the fix after performing QA and including other enhancements and fixes.


Please try our latest version/fix: Aspose.Cells for .NET v17.9.4.

We have fixed your issue now.

Let us know your feedback.

The issues you have found earlier (filed as CELLSNET-45673) have been fixed in Aspose.Cells for .NET 17.10.