Setting a left indent on a table cell

Hi,


I am using both Aspose.cells and Aspose.words. I am reading a table range from an excel spreadsheet and pushing the table through to a word document.

My excel cells have indenting. So I can see as I am processing through my excel cells, when I encounter a cell with an indentlevel > 0, the cell contents must be indented.

I am using the document builder to build the same table in word. How do I set a left indent value on my word cell to represent the same indenting from my excel cell.

Thanks

Hi,

Thanks for your inquiry. In this case, you can specify left indentation at Paragraph level. For example, please see the following code:

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

builder.StartTable();

builder.InsertCell();

CellFormat cellFormat = builder.CellFormat;

cellFormat.Width = 250;

cellFormat.LeftPadding = 30;

cellFormat.RightPadding = 30;

cellFormat.TopPadding = 30;

cellFormat.BottomPadding = 30;

ParagraphFormat paragraphFormat = builder.ParagraphFormat;

paragraphFormat.LeftIndent = 36;

builder.Writeln("I'm a wonderful formatted cell.");

builder.EndRow();

builder.EndTable();

doc.Save(@“C:\Temp\out.docx”);

I hope, this helps.

Best regards,

Thank you for your response.


Is there a way to determine the actual indent size in points (from the excel indentlevel) and apply the points size to the paragraphformat leftindent property?

This would then allow me to get the indent size on the word document consistent with the excel document.
Hi,

Thanks for your inquiry. As your request is related to Aspose.Cells, I am moving your thread in Aspose.Cells forum. My colleagues from Aspose.Cells team will answer you shortly.

Best regards,

Hi Meng,

Thanks for your posting and using Aspose APIs.

You can only find the indent level of the cell’s text using Style.IndentLevel property with Aspose.Cells. However, you cannot find actual indent level in points.

I have calculated the indent level in point using MS-Excel by first indenting the text and then autofitting the column width. I got different readings. 1 Indent Level takes some where between 1.28 - 1.43 points.

I have attached the screenshot showing the readings of indent level in points for your reference.

Screenshot: