Free Support Forum -

Indenting Help

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Simple question I hope. I’m looping through some rows. So I have the row number.

I have data in column A, and a number within column G.

Basically for each row I’d like to collect the value stored in row x column G and then indent the data contained within row x column A by that amount?

Any suggestion appreciated.


Thanks for your posting and using Aspose.Cells for .NET.

Please use the Style.IndentLevel property to indent your cell text. It will fulfill your needs.

Please check the following code for your more help about indenting text. The code also illustrates how to access the cell using column and row indices or using cell name.

I have attached the screenshot and output xlsx file generated by this code for your reference.


Workbook workbook = new Workbook();

Worksheet worksheet = workbook.Worksheets[0];

int r=2;

int c=2;

//Access cell C3 using row and column

Cell cell = worksheet.Cells[r, c];

//You can also access Cell C3 using its name like this

//Cell cc = worksheet.Cells[“C3”];

cell.PutValue(“Some Indented Value”);

//Set the indent level to two

Style style = cell.GetStyle();

style.IndentLevel = 2;


workbook.Save(“output.xlsx”, SaveFormat.Xlsx);



Please see the sample code below with the template file (attached) for your reference. Hopefully it will fit your needs on how to specify indent level for cells based on some range of data. The output file is also attached.

Sample code:

Worksheet worksheet = workbook.Worksheets[0];
Cells cells = worksheet.Cells;
int row = 0;
int col = CellsHelper.ColumnNameToIndex(“G”);
Style style;
//Browse first ten rows.
for (int i = 0; i < 10; i++)
row = i;
style = cells[i, 0].GetStyle();
style.IndentLevel = cells[i, col].IntValue;
cells[i, 0].SetStyle(style);


Let us know if you need anything else or you have other requirements.

Thank you.