Applying IndentLevel style property to a named range

It appears that “IndentLevel” is ignored when applied to a range which spans multiple rows and columns. Or, do I do something wrong here?
Here is code:
var style = ws.Workbook.CreateStyle();
style.IndentLevel = 2;
var styleFlag = new StyleFlag();
styleFlag.Indent = true;
var range = ws.Workbook.Worksheets.GetRangeByName(“MyRangeWIthMultipleRowsAndColumns”);
range.ApplyStyle(style, styleFlag);

The above code runs fine but cells in the range are not indented.

@bogdanw,
Thank you for your query.

I have tried this scenario and observed no issue as indentation is applied to the range of cells in a sample Excel file. Please give a try to the following sample code with the attached template files and share the feedback. Ensure that you are using the latest version Aspose.Cells for .NET 20.1.

Workbook workbook = new Workbook(path + "Book1.xlsx");
Worksheet ws = workbook.Worksheets[0];
var style = ws.Workbook.CreateStyle();
style.IndentLevel = 2;
var styleFlag = new StyleFlag();
styleFlag.Indent = true;
var range = ws.Workbook.Worksheets.GetRangeByName("MyRangeWIthMultipleRowsAndColumns");
range.ApplyStyle(style, styleFlag);
workbook.Save(path + "output.xlsx");

Book1.xlsx.zip (6.9 KB)
output.xlsx.zip (7.4 KB)

Ashan,
sorry for not replying sooner.
I can duplicate the situation, see the code below please.
A few words about the sample code though - I am trying to set “indent level” on all rows in a table in one stroke. I mean, I do not want to loop through columns. Everything works fine as long as I save spreadsheet to “xls/xlsx” format. However, when I save it to html formt “indent” seems to be lost.
To see this please comment out/uncomment line in the code below which sets “SaveOptions” param.
Here is the code (C#):
Workbook wb = new Workbook();
Worksheet ws = wb.Worksheets[0];
var tcStyle = ws.Workbook.CreateStyle();
tcStyle.IndentLevel = 2;
var tcStyleFlag = new StyleFlag { Indent = true };
// Add some data
for (int r = 0; r < 4; r++)
{
for (int c = 0; c < 4; c++)
{
if (r == 0)
{
var cellValue = string.Format(“Column {0}”, c);
ws.Cells[r, c].PutValue(cellValue);
}
else
{
var cellValue = r + c;
ws.Cells[r, c].PutValue(cellValue);
}
}
}
var range = ws.Cells.CreateRange(1,0,3,4);
var index = ws.ListObjects.Add(range.FirstRow - 1, range.FirstColumn, range.FirstRow + 3, range.FirstColumn + 3, true);
ws.ListObjects[index].TableStyleType = TableStyleType.TableStyleLight16;
range.ApplyStyle(tcStyle, tcStyleFlag);

        var myDir = @"DirectoryHeare.....";
        //XlsSaveOptions saveOptions = new XlsSaveOptions();
        HtmlSaveOptions saveOptions = new HtmlSaveOptions();
        wb.Save(myDir + "TestAsPoseExcel_8.xls", saveOptions);

@bogdanw,
We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-47178 – Indentation lost while creating table and converting to Html

@bogdanw,
This is to inform you that we have fixed your issue (logged earlier as “ CELLSNET-47178”) now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

@bogdanw,

Please try our latest version/fix: Aspose.Cells for .NET v20.2.2 (attached)

Your issue should be fixed in it.

Let us know your feedback.

Aspose.Cells20.2.2 For .Net2_AuthenticodeSigned.Zip (5.2 MB)
Aspose.Cells20.2.2 For .Net4.0.Zip (5.2 MB)

Howdy,
Do you think you would have this change any time soon in the “enterprise all” version soon?
We use “Enterprise” and we have license for it and, accordingly, I do not want to mess up anything by doing a peace meal update.
Thx,
Bogdan

@bogdanw,

Well, the fix, i.e., Aspose.Cells for .NET v20.2.2 is although an interim release but it is fully tested and you may use it in production server without any issue, it includes all the functionality (full fledged) of previous official release (Aspose.Cells for .NET v20.2) plus a few enhancements/fixes (till that fix). However, if you still want official/regular release (from Downloads section and nuget repos.), you may wait a couple of weeks. We are scheduled to publish our next official release of the product, i.e., Aspose.Cells for .NET v20.3 in the third week of March, 2020, you will also be notified once the release is published in Downloads and nuget repos, this release will also include your fix.

Hope, this helps a bit.

The issues you have found earlier (filed as CELLSNET-47178) have been fixed in Aspose.Cells for .NET v20.3. This message was posted using Bugs notification tool by Amjad_Sahi