Close





 

The sample demonstrates how to Create Excel file for Silverlight via Spire.XLS.

 

Thursday, 05 April 2012 06:24

Word Bookmark for Silverlight

Written by support iceblue

The sample demonstrates how to add bookmark into Word for Silverlight via Spire.Doc.

 

Table in Microsoft Word is used to present data information which can assist to explain specified paragraph contents. In order to have a better appearance, people can set Word table style. This guide shows how to use Spire.Doc to set table style in Word with C#/VB.NET.

 

Download Spire.Doc (or Spire.Office) with .NET Framework 2.0 (or above) together. Once make sure Spire.Doc (or Spire.Office) are correctly installed on system, follow the steps below to set Word table style

 

In this example, a Word document with table has been prepared. It is a student transcript template from Office.com.

Step 1 Load Document

Create a C#/VB.NET project in Visual Studio. Add Spire.Doc.dll as reference.

[C#]
            Document document = new Document();
            document.LoadFromFile(@"E:\work\Documents\Student Transcript.docx");
[Visual Basic]
            Dim document As New Document()
            document.LoadFromFile("E:\work\Documents\Student Transcript.docx")

Step 2 Set Table Style

  • Get table which you want to set style
  • Because table1 type is different from document.Sections[0].Tables[1] type, so use (Table) to transformed forcibly.

    [C#]
    Table table1 = (Table)document.Sections[0].Tables[1];
    
    [Visual Basic]
     Dim table1 As Table = CType(document.Sections(0).Tables(1), Table)
    
  • Set table row height.
  • [C#]
     table1.Rows[0].Height = 25;
    
    [Visual Basic]
     table1.Rows(0).Height = 25
    
  • Set Table Style
  • In order to have distinction. Keep the first cell in first row as before and set style for the second cell. Firstly, set alignment and background color for the second cell. Secondly, declare a paragraph style, including font size, color and apply this style in cell.

    [C#]
                table1.Rows[0].Cells[1].CellFormat.VerticalAlignment = VerticalAlignment.Middle;
                table1.Rows[0].Cells[1].CellFormat.BackColor = Color.LimeGreen;
    
                ParagraphStyle style = new ParagraphStyle(document);
                style.Name = "TableStyle";
                style.CharacterFormat.FontSize = 14;
                style.CharacterFormat.TextColor = Color.GhostWhite;
                document.Styles.Add(style);
                table1.Rows[0].Cells[1].Paragraphs[0].ApplyStyle(style.Name);
    
    [Visual Basic]
                table1.Rows(0).Cells(1).CellFormat.VerticalAlignment = VerticalAlignment.Middle
                table1.Rows(0).Cells(1).CellFormat.BackColor = Color.LimeGreen
    
                Dim style As New ParagraphStyle(document)
                style.Name = "TableStyle"
                style.CharacterFormat.FontSize = 14
                style.CharacterFormat.TextColor = Color.GhostWhite
                document.Styles.Add(style)
                table1.Rows(0).Cells(1).Paragraphs(0).ApplyStyle(style.Name)
    

    Step 3 Save and Launch

    [C#]
                document.SaveToFile("WordTable.docx", FileFormat.Docx);
                System.Diagnostics.Process.Start("WordTable.docx");
    
    [Visual Basic]
                document.SaveToFile("WordTable.docx", FileFormat.Docx)
                System.Diagnostics.Process.Start("WordTable.docx")
    
    

    Effective Screenshot

     

    This guide shows how to set Word table style such as size and color via Spire.Doc. However, Spire.Doc can do a lot on operating Word document Click to learn more…

     

    Download Spire.Doc

    Purchase Spire.Doc

    << Start < Prev 1 2 3 4 5 6 7 8 9 10 Next > End >>
    Page 4 of 48