Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Wed Jan 20, 2016 10:49 am

Hi,

I am currently indenting paragraphs from the left and I want to line up the left hand side of a table to match the paragraph indent which is 34.
I have tried 'table.IndentFromLeft = 34' and table.PreferredWidth = New PreferredWidth(WidthType.Percentage, 85), but the left hand side of the table stays on the left margin of the document, but the table has resized ok.

How do I indent the table and also have the right hand side of the table line up to the right margin of the document?

Thanks,
Jez.

JezPearson
 
Posts: 10
Joined: Fri Sep 11, 2015 2:05 pm

Thu Jan 21, 2016 6:03 am

Hi,

Thanks for your posting and using our Spire.Doc.
Please use table.TableFormat.LeftIndent=34.
When table is aligned to left and its direction is left to right, it will line up the left hand side of a table.
Code: Select all
table.TableFormat.HorizontalAlignment = RowAlignment.Left;
            table.TableFormat.Bidi = false;

When table is aligned to right and its direction is right to left, it will line up the right hand side of a table.
Code: Select all
table.TableFormat.HorizontalAlignment = RowAlignment.Right;
            table.TableFormat.Bidi = true;


Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Thu Jan 21, 2016 12:28 pm

Hi Amy,

That has worked perfectly.

Thank you,
Jez.

JezPearson
 
Posts: 10
Joined: Fri Sep 11, 2015 2:05 pm

Fri Jan 22, 2016 1:34 am

Hi,

Thanks for your feedback.
I am glad that your issue has been resolved.
Welcome to write to us again for further problems.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Fri Apr 22, 2016 6:56 am

I'm having similar issues.

I got the following code:
Code: Select all
var table = section.AddTable(false);

table.TableFormat.HorizontalAlignment = RowAlignment.Left;
table.TableFormat.Bidi = false;
table.TableFormat.LeftIndent = 50;

TableRow row = null;

foreach (var something in something)
{
     row = table.AddRow(2);
}


Yet the table is still aligned to the left margin.

pbo
 
Posts: 19
Joined: Fri Oct 23, 2015 1:46 pm

Fri Apr 22, 2016 7:20 am

Hi,

Thanks for your posting.
I did a few changes for your code as your code cannot run directly but still was using the same format properties. I tested the following code and the result was fine, attached a result screenshot. I am using the latest verion of Spire.Office, Spire.Office Platinum (Hot Fix) Version:2.13.4.
Code: Select all
Document doc = new Document();
            Section section = doc.AddSection();
            var table = section.AddTable(true);
            table.ResetCells(2, 2);
            table.TableFormat.HorizontalAlignment = RowAlignment.Left;
            table.TableFormat.Bidi = false;
            table.TableFormat.LeftIndent = 50;

            doc.SaveToFile("sample.docx", FileFormat.Docx);


Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Fri Apr 22, 2016 8:51 am

Hello Amy,

When changing
Code: Select all
.AddTable(false);
to
Code: Select all
.AddTable(true);
, The alignment works perfectly. However when hiding the borders, the alignment is wrong.

Kind regards,
Stijn

pbo
 
Posts: 19
Joined: Fri Oct 23, 2015 1:46 pm

Fri Apr 22, 2016 9:02 am

Hi,

So sorry that there is indeed the issue. I have forwarded it to our dev team. We will inform you when it is fixed.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Wed Apr 27, 2016 8:32 am

Hi,

Please use the following code to resolve the issue.
Code: Select all
Document doc = new Document();
Section section = doc.AddSection();
var table = section.AddTable(false);
table.ResetCells(2, 2);
table.TableFormat.HorizontalAlignment = RowAlignment.Left;
table.TableFormat.Bidi = false;
table.IndentFromLeft = 50;

doc.SaveToFile("sample.docx", FileFormat.Docx);


Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Doc