Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
85
word document questions using infragistics
posted

Hi,

2 quick questions concerning creating word documents using infragistics in c#.  I have tried online to find solutions but unfortunately can't find anything

I was looking to insert a horizontal line on my word document i have created across the page.  I am sure this is easy but can't find an example of it.

Another issue i am having is the width of the table i have created.  When i create a table it seems to set the width automatically.  I have played around with the other attributes but can't seem to find the correct one.  The code is below

Any help would be appreciated.

Thanks

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

TableBorderProperties

 

borderProps = docWriter.CreateTableBorderProperties();

borderProps.Color =

Color.Blue;

borderProps.Style =

TableBorderStyle.Single;

 

 

 

// Create table properties

 

 

TableProperties tableProps = docWriter.CreateTableProperties();

tableProps.Alignment =

ParagraphAlignment.Center;

 

tableProps.BorderProperties.Color = borderProps.Color;

tableProps.BorderProperties.Style = borderProps.Style;

 

 

// Create table row properties

 

 

TableRowProperties rowProps = docWriter.CreateTableRowProperties();

 

 

//Make the row a Header

rowProps.IsHeaderRow =

false;

 

 

// Create table cell properties

 

 

TableCellProperties cellProps = docWriter.CreateTableCellProperties();

cellProps.VerticalAlignment =

TableCellVerticalAlignment.Center;

 

 

docWriter.StartTable(2, tableProps);

 

 

// Begin a Row and apply table row properties

 

 

 

 

 

cellProps.Reset();

 

 

// DATA ROW

docWriter.StartTableRow();

font.Reset();

font.Name =

"Verdana";

font.ForeColor =

Color.Black;

font.Size = .14f;

 

 

// Cell Value for 2nd row 1st column

docWriter.StartTableCell(cellProps);

docWriter.StartParagraph();

 

 

Image img = Image.FromFile(@"d:\documents and settings\My Documents\My PicturesLogo.jpg");

 

 

// Create an Anchored Image

 

 

AnchoredPicture anchPic = docWriter.CreateAnchoredPicture(img);

docWriter.AddAnchoredPicture(anchPic);

 

docWriter.EndParagraph();

docWriter.EndTableCell();

 

 

// Cell Value for 2nd row 2nd column

docWriter.StartTableCell(cellProps);

docWriter.StartParagraph();

docWriter.AddTextRun(

"Some text in here.", font);

docWriter.AddNewLine();

docWriter.AddTextRun(

"More text in here", font);

docWriter.AddNewLine();

docWriter.AddTextRun(

"and some more text", font);

docWriter.EndTableRow();

 

docWriter.EndTable();

Parents
  • 69832
    Offline posted

    cromster said:
    I was looking to insert a horizontal line on my word document i have created across the page.

    1. Use WordDocumentWriter.CreateAnchored/CreateVmlShape to create a line
    2. Use WordDocumentWriter.AddAnchoredShape/AddInlineShape to add it to the current paragraph

    cromster said:
    Another issue i am having is the width of the table i have created.  When i create a table it seems to set the width automatically.

    Use the TableProperties.PreferredWidth property.

Reply Children