Style.Indent Bug

Using Aspose.Cells 4.8.2.0

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.SetStyle(Aspose.Cells.CellBorderType.Thin);

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

Style.IsTextWrapped = true;

Style.Font.Size = 8;

Style.Number = 49;

Style.Indent=0;

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.

Hi,

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();
workbook.Open(“e:\test\indentedtest.xls”);

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

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

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

workbook.Save(“e:\test\outindentedtest.xls”);


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.