none
How to make Top and Bottam line visible of table in word using c# RRS feed

  • Question

  • Hi, I have added table with 1 row and 3 columns at header. I want to display Bottom line of table in header

    and Top line of Footer table visible here is my code

    object oMissing = Type.Missing;
    
                object fName = @"F:\Bhagawat.s\1020000101777777180712.rtf";
            
                Word._Application oWord = new Word.Application();
                Word.Document oDoc = oWord.Documents.Open(ref fName, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);//Here I omitted some oMissing.
                oWord.Visible = true;
    
                Word.Range oRange = oDoc.Sections[1].Headers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
    
                Word.Table oTable = oDoc.Tables.Add(oRange, 1, 3, ref oMissing, ref oMissing);
                int r, c;
                string strText;
                for (r = 1; r <= 1; r++)
                    for (c = 1; c <= 3; c++)
                    {
                        strText = "Lsoft" + r + "Pune" + c;
                        oTable.Cell(r, c).Range.Text = strText;
                    }
                //The col1 cell
                oTable.Cell(1, 1).Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
                //The col2 cell
                oTable.Cell(1, 2).Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
                //The col3 cell
                oTable.Cell(1, 3).Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphRight;
    
                //oTable.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleDouble;
                //oTable.Borders.InsideLineStyle = Word.WdLineStyle.wdLineStyleSingle;
    
                oTable.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleSingle;
                oTable.Borders.ApplyPageBordersToAllSections();
                //Footer goes here
               // Word.Range oRange = oDoc.Sections[1].Headers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
                Word.Range oRange1 = oDoc.Sections[1].Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
                Word.Table oTable1 = oDoc.Tables.Add(oRange1, 1, 3, ref oMissing, ref oMissing);
                int r1, c1;
                string strText1;
                for (r1 = 1; r1 <= 1; r1++)
                    for (c1 = 1; c1 <= 3; c1++)
                    {
                        strText1 = "Lsoft" + r1 + "Pune" + c1;
                        oTable1.Cell(r1, c1).Range.Text = strText1;
                    }
                //The col1 cell
                oTable1.Cell(1, 1).Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
                //The col2 cell
                oTable1.Cell(1, 2).Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
                //The col3 cell
                oTable1.Cell(1, 3).Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphRight;
                //Footer ends here
    
                //oTable1.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleDouble;
                //oTable1.Borders.InsideLineStyle = Word.WdLineStyle.wdLineStyleSingle;
    
                //oTable1.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleSingle;

    Thanks in advance....


    Experience the innovation with perfection.

    Monday, August 6, 2012 7:48 AM

Answers

  • hi found the solution

       oTable2.Borders[WdBorderType.wdBorderTop].LineStyle = Word.WdLineStyle.wdLineStyleNone;



    Experience the innovation with perfection.

    • Marked as answer by Bhagawat Friday, August 24, 2012 5:10 AM
    Friday, August 24, 2012 5:10 AM

All replies

  • Hi, I have added table with 1 row and 3 columns at header. I want to display Bottom line of table in header

    and Top line of Footer table visible here is my code

    You mean you want to put the whole table in the header and footer? If it only has one row, I'm wondering what else you could mean.

    If the table's bigger, I think the thing to would be to create a new single line table for the header, and another for the footer, and copy across row/cell contents.

    Monday, August 6, 2012 1:33 PM
  • I am inserting 1 table in header and another table in footer.

    I can show  InsideLineStyle true... Just like that i want to visible bottom line of header table and Top line of footer  table  vissible.  

    oTable.Borders.InsideLineStyle = Word.WdLineStyle.wdLineStyleSingle;


    Experience the innovation with perfection.

    Tuesday, August 7, 2012 4:49 AM
  • hi found the solution

       oTable2.Borders[WdBorderType.wdBorderTop].LineStyle = Word.WdLineStyle.wdLineStyleNone;



    Experience the innovation with perfection.

    • Marked as answer by Bhagawat Friday, August 24, 2012 5:10 AM
    Friday, August 24, 2012 5:10 AM