Interface IWSection
Represents a section.
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.Portable.dll
Syntax
public interface IWSection : ICompositeEntity, IEntity
Properties
Body
Gets the section body. Read-only.
Declaration
WTextBody Body { get; }
Property Value
Type | Description |
---|---|
WTextBody | The WTextBody of the current section. |
BreakCode
Gets or sets section break code of the current section.
Declaration
SectionBreakCode BreakCode { get; set; }
Property Value
Type | Description |
---|---|
SectionBreakCode | The SectionBreakCode member that specifies the break code. |
Columns
Gets the collection of columns which logically divide page on many printing or publishing areas. Read-only.
Declaration
ColumnCollection Columns { get; }
Property Value
Type | Description |
---|---|
ColumnCollection | The collection of columns in the section. |
HeadersFooters
Gets headers and footers of the current section. Read-only.
Declaration
WHeadersFooters HeadersFooters { get; }
Property Value
Type | Description |
---|---|
WHeadersFooters | The WHeadersFooters instance that specifies current section header, footer. |
PageSetup
Gets the page setup of the current section. Read-only.
Declaration
WPageSetup PageSetup { get; }
Property Value
Type | Description |
---|---|
WPageSetup | The WPageSetup of the current section. |
Paragraphs
Gets the paragraphs in the current section. Read-only.
Declaration
IWParagraphCollection Paragraphs { get; }
Property Value
Type | Description |
---|---|
IWParagraphCollection | The IWParagraphCollection that represents the collection of IWParagraph in the section. |
ProtectForm
Gets or sets a value indicating whether to allow editing of form fields in the section.
Declaration
bool ProtectForm { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if to allow editing of form fields; otherwise, false. |
Tables
Gets the tables in the current section. Read-only.
Declaration
IWTableCollection Tables { get; }
Property Value
Type | Description |
---|---|
IWTableCollection | The IWTableCollection that represents the collection of IWTable in the section. |
Methods
AddColumn(Single, Single)
Adds a new Column to the section.
Declaration
Column AddColumn(float width, float spacing)
Parameters
Type | Name | Description |
---|---|---|
System.Single | width | The float that specifies the width of the column. |
System.Single | spacing | The float that specifies the spacing between the columns. |
Returns
Type | Description |
---|---|
Column | The reference to the newly added Column object. |
Examples
The following example illustrates how to have multiple columns in a section.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add the section into Word document
IWSection section = document.AddSection();
//Add the column into the section
section.AddColumn(150, 20);
//Add the column into the section
section.AddColumn(150, 20);
//Add the column into the section
section.AddColumn(150, 20);
//Add a paragraph to created section
IWParagraph paragraph = section.AddParagraph();
//Add a paragraph to created section
paragraph = section.AddParagraph();
paragraph.Text = "Lorem ipsum dolor sit amet, lacus amet amet ultricies. Quisque mi venenatis morbi libero, orci dis, mi ut et class porta, massa ligula magna enim, aliquam orci vestibulum Turpis facilisis vitae consequat, cum a a,turpis dui consequat massa in dolor per, felis non amet.Auctor eleifend in omnis elit vestibulum, donec non elementum tellus est mauris, id aliquam, at lacus, arcu pretium proin lacus dolor et. Eu tortor, vel ultrices amet dignissim mauris vehicula";
//Append the text to the created paragraph
paragraph.AppendText(paragraph.Text);
//Add the column breaks
paragraph.AppendBreak(BreakType.ColumnBreak);
//Add a paragraph to created section
paragraph = section.AddParagraph();
//Append the text to the created paragraph
paragraph.AppendText(paragraph.Text);
//Add the column breaks
paragraph.AppendBreak(BreakType.ColumnBreak);
//Add a paragraph to created section
paragraph = section.AddParagraph();
//Append the text to the created paragraph
paragraph.AppendText(paragraph.Text);
//Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add the section into Word document
Dim section As IWSection = document.AddSection()
'Add the column into the section
section.AddColumn(150, 20)
'Add the column into the section
section.AddColumn(150, 20)
'Add the column into the section
section.AddColumn(150, 20)
'Add a paragraph to created section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add a paragraph to created section
paragraph = section.AddParagraph()
Dim paraText As String = "Lorem ipsum dolor sit amet, lacus amet amet ultricies. Quisque mi venenatis morbi libero, orci dis, mi ut et class porta, massa ligula magna enim, aliquam orci vestibulum Turpis facilisis vitae consequat, cum a a,turpis dui consequat massa in dolor per, felis non amet.Auctor eleifend in omnis elit vestibulum, donec non elementum tellus est mauris, id aliquam, at lacus, arcu pretium proin lacus dolor et. Eu tortor, vel ultrices amet dignissim mauris vehicula"
'Append the text to the created paragraph
paragraph.AppendText(paraText)
'Add the column breaks
paragraph.AppendBreak(BreakType.ColumnBreak)
'Add a paragraph to created section
paragraph = section.AddParagraph()
'Append the text to the created paragraph
paragraph.AppendText(paraText)
'Add the column breaks
paragraph.AppendBreak(BreakType.ColumnBreak)
'Add a paragraph to created section
paragraph = section.AddParagraph()
'Append the text to the created paragraph
paragraph.AppendText(paraText)
'Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
AddParagraph()
Adds the IWParagraph to the section body.
Declaration
IWParagraph AddParagraph()
Returns
Type | Description |
---|---|
IWParagraph | The reference to the newly created paragraph. |
Examples
The following example illustrates how to add a paragraph to the section.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Gets the first section in the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("First paragraph in section");
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Gets the first section in the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("First paragraph in section")
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
AddTable()
Adds the IWTable to the section body.
Declaration
IWTable AddTable()
Returns
Type | Description |
---|---|
IWTable | The reference to the newly created table. |
Examples
The following example illustrates how to add a table to the section.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Gets the first section in the document
IWSection section = document.AddSection();
//Add new table to the section
IWTable table = section.AddTable();
//Set rows and columns count
table.ResetCells(2, 2);
//Add contents to the table
IWParagraph paragraph = table[0, 0].AddParagraph();
paragraph.AppendText("Apple");
paragraph = table[0, 1].AddParagraph();
paragraph.AppendText("Red");
paragraph = table[1, 0].AddParagraph();
paragraph.AppendText("Banana");
paragraph = table[1, 1].AddParagraph();
paragraph.AppendText("Yellow");
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Gets the first section in the document
Dim section As IWSection = document.AddSection()
'Add new table to the section
Dim table As IWTable = section.AddTable()
'Set rows and columns count
table.ResetCells(2, 2)
'Add contents to the table
Dim paragraph As IWParagraph = table(0, 0).AddParagraph()
paragraph.AppendText("Apple")
paragraph = table(0, 1).AddParagraph()
paragraph.AppendText("Red")
paragraph = table(1, 0).AddParagraph()
paragraph.AppendText("Banana")
paragraph = table(1, 1).AddParagraph()
paragraph.AppendText("Yellow")
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
Clone()
Clones the WSection, creates a duplicate copy.
Declaration
WSection Clone()
Returns
Type | Description |
---|---|
WSection | The cloned WSection object. |
MakeColumnsEqual()
Makes all columns in the current section to be of equal width.
Declaration
void MakeColumnsEqual()
Examples
The following example illustrates how to have make the columns to be of equal width in a section.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument("Sample.docx");
//Gets the first section in the document
IWSection section = document.Sections[0];
//Make the columns to be of equal width
section.MakeColumnsEqual();
//Save and close the document
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument("Sample.docx")
'Gets the first section in the document
Dim section As IWSection = document.Sections(0)
'Make the columns to be of equal width
section.MakeColumnsEqual()
'Save and close the document
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub