We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Style.Indent Bug

Using Aspose.Cells

I seem to have stumbed across an issue regarding setting the indent level of cells when the cells are merged. I have the following base style setup:

Style = Workbook.Styles[Workbook.Styles.Add()];

Style.Name = "SideElement";

Style.HorizontalAlignment = Aspose.Cells.TextAlignmentType.Left;

Style.VerticalAlignment = Aspose.Cells.TextAlignmentType.Center;


Style.Borders.DiagonalStyle = Aspose.Cells.CellBorderType.None;

Style.IsTextWrapped = true;

Style.Font.Size = 8;

Style.Number = 49;


I then create a worksheet with several cells each of which span 2 rows. I apply the style as:

aCell.GetMergedRange().Style = aSideElement;

if (vElement.Indent > 0)


aCell.GetMergedRange().Style.IndentLevel = vElement.Indent;


For example I have 8 merge cells and cells 3, 4 and 5 should have an Indent of 1. I'm seeing:

  • The first indented cell set it indent = 1 is not indented in the Excel output.
  • The next cell does get indetn=1, however all cells after this get indent = 1.


I have tested your scenario a bit using the attached version but could not find the issue, could you try the attached latest fix v4.8.2.6 and let us know if it works fine.

I have created a template file in MS Excel and merged some cells into a single cell, I have also set its indent level to 1 with some other formatting attributes, save the file. Now use the following code to change its indent level back to 0, it works fine.

Sample code:

Workbook workbook = new Workbook();

Style style = workbook.Styles[workbook.Styles.Add()];
style.Name = “SideElement”;
style.HorizontalAlignment = Aspose.Cells.TextAlignmentType.Left;
style.VerticalAlignment = Aspose.Cells.TextAlignmentType.Center;
style.Borders.DiagonalStyle = Aspose.Cells.CellBorderType.None;
style.IsTextWrapped = true;
style.Font.Size = 8;
style.Number = 49;

Cells cells = workbook.Worksheets[0].Cells;

cells[“K26”].GetMergedRange().Style = style;


If you still find the issue, kindly create a console application (with all the files input(if you have) and output file), zip the archive and post it here to show the issue, we will check it soon.

Thank you.