//Creates a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new paragraph to the section
WParagraph paragraph = section.AddParagraph() as WParagraph;
//Creates new group shape
GroupShape groupShape = new GroupShape(document);
//Adds group shape to the paragraph.
paragraph.ChildEntities.Add(groupShape);
//Creates new shape
Shape shape = new Shape(document, AutoShapeType.RoundedRectangle);
//Sets height and width for shape
shape.Height = 100;
shape.Width = 150;
//Sets horizontal and vertical position
shape.HorizontalPosition = 72;
shape.VerticalPosition = 72;
//Set wrapping style for shape
shape.WrapFormat.TextWrappingStyle = TextWrappingStyle.InFrontOfText;
//Sets horizontal and vertical origin
shape.HorizontalOrigin = HorizontalOrigin.Page;
shape.VerticalOrigin = VerticalOrigin.Page;
//Adds the specified shape to group shape
groupShape.Add(shape);
//Creates new picture
WPicture picture = new WPicture(document);
picture.LoadImage(Image.FromFile("Image.png"));
//Sets wrapping style for picture
picture.TextWrappingStyle = TextWrappingStyle.InFrontOfText;
//Sets height and width for the image
picture.Height = 100;
picture.Width = 100;
//Sets horizontal and vertical position
picture.HorizontalPosition = 400;
picture.VerticalPosition = 150;
//Sets horizontal and vertical origin
picture.HorizontalOrigin = HorizontalOrigin.Page;
picture.VerticalOrigin = VerticalOrigin.Page;
//Adds the specified picture to group shape
groupShape.Add(picture);
//Sets group shape rotation in degree
groupShape.Rotation = 90;
//Saves the Word document
document.Save("Sample.docx", FormatType.Docx);
//Closes the document
document.Close();
'Creates a new Word document
Dim document As WordDocument = New WordDocument
'Adds new section to the document
Dim section As IWSection = document.AddSection
'Adds new paragraph to the section
Dim paragraph As WParagraph = CType(section.AddParagraph, WParagraph)
'Creates new group shape
Dim groupShape As GroupShape = New GroupShape(document)
'Adds group shape to the paragraph.
paragraph.ChildEntities.Add(groupShape)
Dim shape As Shape = New Shape(document, AutoShapeType.RoundedRectangle)
'Sets height and width for shape
shape.Height = 100
shape.Width = 150
'Sets horizontal and vertical position
shape.HorizontalPosition = 72
shape.VerticalPosition = 72
'Set wrapping style for shape
shape.WrapFormat.TextWrappingStyle = TextWrappingStyle.InFrontOfText
'Sets horizontal and vertical origin
shape.HorizontalOrigin = HorizontalOrigin.Page
shape.VerticalOrigin = VerticalOrigin.Page
'Adds the specified shape to group shape
groupShape.Add(shape)
Dim picture As WPicture = New WPicture(document)
picture.LoadImage(Image.FromFile("Image.png"))
'Sets wrapping style for picture
picture.TextWrappingStyle = TextWrappingStyle.InFrontOfText
'Sets height and width for the image
picture.Height = 100
picture.Width = 100
'Sets horizontal and vertical position
picture.HorizontalPosition = 400
picture.VerticalPosition = 150
'Sets horizontal and vertical origin
picture.HorizontalOrigin = HorizontalOrigin.Page
picture.VerticalOrigin = VerticalOrigin.Page
'Adds the specified picture to group shape
groupShape.Add(picture)
'Sets group shape rotation in degree
groupShape.Rotation = 90
'Saves the Word document
document.Save("Sample.docx", FormatType.Docx)
'Closes the document
document.Close()
//Creates a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new paragraph to the section
WParagraph paragraph = section.AddParagraph() as WParagraph;
//Creates new group shape
GroupShape groupShape = new GroupShape(document);
//Adds group shape to the paragraph.
paragraph.ChildEntities.Add(groupShape);
//Creates new shape
Shape shape = new Shape(document, AutoShapeType.RoundedRectangle);
//Sets height and width for shape
shape.Height = 100;
shape.Width = 150;
//Sets horizontal and vertical position
shape.HorizontalPosition = 72;
shape.VerticalPosition = 72;
//Set wrapping style for shape
shape.WrapFormat.TextWrappingStyle = TextWrappingStyle.InFrontOfText;
//Sets horizontal and vertical origin
shape.HorizontalOrigin = HorizontalOrigin.Page;
shape.VerticalOrigin = VerticalOrigin.Page;
//Adds the specified shape to group shape
groupShape.Add(shape);
//Creates new picture
WPicture picture = new WPicture(document);
picture.LoadImage(Image.FromFile("Image.png"));
//Sets wrapping style for picture
picture.TextWrappingStyle = TextWrappingStyle.InFrontOfText;
//Sets height and width for the image
picture.Height = 100;
picture.Width = 100;
//Sets horizontal and vertical position
picture.HorizontalPosition = 400;
picture.VerticalPosition = 150;
//Sets horizontal and vertical origin
picture.HorizontalOrigin = HorizontalOrigin.Page;
picture.VerticalOrigin = VerticalOrigin.Page;
//Adds the specified picture to group shape
groupShape.Add(picture);
//Sets horizontal flip to the group shape
groupShape.FlipHorizontal = true;
//Saves the Word document
document.Save("Sample.docx", FormatType.Docx);
//Closes the document
document.Close();
'Creates a new Word document
Dim document As WordDocument = New WordDocument
'Adds new section to the document
Dim section As IWSection = document.AddSection
'Adds new paragraph to the section
Dim paragraph As WParagraph = CType(section.AddParagraph, WParagraph)
'Creates new group shape
Dim groupShape As GroupShape = New GroupShape(document)
'Adds group shape to the paragraph.
paragraph.ChildEntities.Add(groupShape)
Dim shape As Shape = New Shape(document, AutoShapeType.RoundedRectangle)
'Sets height and width for shape
shape.Height = 100
shape.Width = 150
'Sets horizontal and vertical position
shape.HorizontalPosition = 72
shape.VerticalPosition = 72
'Set wrapping style for shape
shape.WrapFormat.TextWrappingStyle = TextWrappingStyle.InFrontOfText
'Sets horizontal and vertical origin
shape.HorizontalOrigin = HorizontalOrigin.Page
shape.VerticalOrigin = VerticalOrigin.Page
'Adds the specified shape to group shape
groupShape.Add(shape)
Dim picture As WPicture = New WPicture(document)
picture.LoadImage(Image.FromFile("Image.png"))
'Sets wrapping style for picture
picture.TextWrappingStyle = TextWrappingStyle.InFrontOfText
'Sets height and width for the image
picture.Height = 100
picture.Width = 100
'Sets horizontal and vertical position
picture.HorizontalPosition = 400
picture.VerticalPosition = 150
'Sets horizontal and vertical origin
picture.HorizontalOrigin = HorizontalOrigin.Page
picture.VerticalOrigin = VerticalOrigin.Page
'Adds the specified picture to group shape
groupShape.Add(picture)
'Sets horizontal flip to the group shape
groupShape.FlipHorizontal = True
'Saves the Word document
document.Save("Sample.docx", FormatType.Docx)
'Closes the document
document.Close()
//Creates a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new paragraph to the section
WParagraph paragraph = section.AddParagraph() as WParagraph;
//Creates new group shape
GroupShape groupShape = new GroupShape(document);
//Adds group shape to the paragraph.
paragraph.ChildEntities.Add(groupShape);
//Creates new shape
Shape shape = new Shape(document, AutoShapeType.RoundedRectangle);
//Sets height and width for shape
shape.Height = 100;
shape.Width = 150;
//Sets horizontal and vertical position
shape.HorizontalPosition = 72;
shape.VerticalPosition = 72;
//Set wrapping style for shape
shape.WrapFormat.TextWrappingStyle = TextWrappingStyle.InFrontOfText;
//Sets horizontal and vertical origin
shape.HorizontalOrigin = HorizontalOrigin.Page;
shape.VerticalOrigin = VerticalOrigin.Page;
//Adds the specified shape to group shape
groupShape.Add(shape);
//Creates new picture
WPicture picture = new WPicture(document);
picture.LoadImage(Image.FromFile("Image.png"));
//Sets wrapping style for picture
picture.TextWrappingStyle = TextWrappingStyle.InFrontOfText;
//Sets height and width for the image
picture.Height = 100;
picture.Width = 100;
//Sets horizontal and vertical position
picture.HorizontalPosition = 400;
picture.VerticalPosition = 150;
//Sets horizontal and vertical origin
picture.HorizontalOrigin = HorizontalOrigin.Page;
picture.VerticalOrigin = VerticalOrigin.Page;
//Adds the specified picture to group shape
groupShape.Add(picture);
//Sets vertical flip to the group shape
groupShape.FlipVertical = true;
//Saves the Word document
document.Save("Sample.docx", FormatType.Docx);
//Closes the document
document.Close();
'Creates a new Word document
Dim document As WordDocument = New WordDocument
'Adds new section to the document
Dim section As IWSection = document.AddSection
'Adds new paragraph to the section
Dim paragraph As WParagraph = CType(section.AddParagraph, WParagraph)
'Creates new group shape
Dim groupShape As GroupShape = New GroupShape(document)
'Adds group shape to the paragraph.
paragraph.ChildEntities.Add(groupShape)
Dim shape As Shape = New Shape(document, AutoShapeType.RoundedRectangle)
'Sets height and width for shape
shape.Height = 100
shape.Width = 150
'Sets horizontal and vertical position
shape.HorizontalPosition = 72
shape.VerticalPosition = 72
'Set wrapping style for shape
shape.WrapFormat.TextWrappingStyle = TextWrappingStyle.InFrontOfText
'Sets horizontal and vertical origin
shape.HorizontalOrigin = HorizontalOrigin.Page
shape.VerticalOrigin = VerticalOrigin.Page
'Adds the specified shape to group shape
groupShape.Add(shape)
Dim picture As WPicture = New WPicture(document)
picture.LoadImage(Image.FromFile("Image.png"))
'Sets wrapping style for picture
picture.TextWrappingStyle = TextWrappingStyle.InFrontOfText
'Sets height and width for the image
picture.Height = 100
picture.Width = 100
'Sets horizontal and vertical position
picture.HorizontalPosition = 400
picture.VerticalPosition = 150
'Sets horizontal and vertical origin
picture.HorizontalOrigin = HorizontalOrigin.Page
picture.VerticalOrigin = VerticalOrigin.Page
'Adds the specified picture to group shape
groupShape.Add(picture)
'Sets vertical flip to the group shape
groupShape.FlipVertical = True
'Saves the Word document
document.Save("Sample.docx", FormatType.Docx)
'Closes the document
document.Close()
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
WSection section = document.AddSection() as WSection;
//Add a paragraph to created section
WParagraph paragraph = section.AddParagraph() as WParagraph;
string paraText = "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 a paragraph to created section
paragraph = section.AddParagraph() as WParagraph;
//Add the rectangle shape to the document
Syncfusion.DocIO.DLS.Shape shape = paragraph.AppendShape(AutoShapeType.Rectangle, 200, 75);
//Set wrapping type as inline
shape.WrapFormat.TextWrappingStyle = TextWrappingStyle.Inline;
//Set the fillformat for the shape
shape.FillFormat.Color = Color.AliceBlue;
shape.FillFormat.Fill = true;
shape.FillFormat.Transparency = 60;
//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 WSection = TryCast(document.AddSection(), WSection)
'Add a paragraph to created section
Dim paragraph As WParagraph = TryCast(section.AddParagraph(), WParagraph)
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 a paragraph to created section
paragraph = TryCast(section.AddParagraph(), WParagraph)
'Add the rectangle shape to the document
Dim shape As Syncfusion.DocIO.DLS.Shape = paragraph.AppendShape(AutoShapeType.Rectangle, 200, 75)
'Set wrapping type as inline
shape.WrapFormat.TextWrappingStyle = TextWrappingStyle.Inline
'Set the fillformat for the shape
shape.FillFormat.Color = Color.AliceBlue
shape.FillFormat.Fill = True
shape.FillFormat.Transparency = 60
'Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
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
WSection section = document.AddSection() as WSection;
//Add a paragraph to created section
WParagraph paragraph = section.AddParagraph() as WParagraph;
string paraText = "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 a paragraph to created section
paragraph = section.AddParagraph() as WParagraph;
//Add the rectangle shape to the document
Syncfusion.DocIO.DLS.Shape shape = paragraph.AppendShape(AutoShapeType.Rectangle, 200, 75);
//Set wrapping type as inline
shape.WrapFormat.TextWrappingStyle = TextWrappingStyle.Inline;
//Set the line format for the shape
shape.LineFormat.Line = true;
shape.LineFormat.Color = Color.Red;
shape.LineFormat.DashStyle = LineDashing.DashDot;
shape.LineFormat.Style = Syncfusion.DocIO.DLS.LineStyle.ThickThin;
shape.LineFormat.Weight = 3;
shape.LineFormat.Transparency = 30;
//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 WSection = TryCast(document.AddSection(), WSection)
'Add a paragraph to created section
Dim paragraph As WParagraph = TryCast(section.AddParagraph(), WParagraph)
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 a paragraph to created section
paragraph = TryCast(section.AddParagraph(), WParagraph)
'Add the rectangle shape to the document
Dim shape As Syncfusion.DocIO.DLS.Shape = paragraph.AppendShape(AutoShapeType.Rectangle, 200, 75)
'Set wrapping type as inline
shape.WrapFormat.TextWrappingStyle = TextWrappingStyle.Inline
'Set the line format for the shape
shape.LineFormat.Line = True
shape.LineFormat.Color = Color.Red
shape.LineFormat.DashStyle = LineDashing.DashDot
shape.LineFormat.Style = Syncfusion.DocIO.DLS.LineStyle.ThickThin
shape.LineFormat.Weight = 3
shape.LineFormat.Transparency = 30
'Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument("Template.docx");
//Add the section into Word document
WSection section = document.AddSection() as WSection;
//Add a paragraph to created section
WParagraph paragraph = document.Sections[0].Paragraphs[0];
//Create a new shape
Syncfusion.DocIO.DLS.Shape shape = new Syncfusion.DocIO.DLS.Shape(document, AutoShapeType.Rectangle);
//Specify the shape formatting options
shape.AlternativeText = "demo shape";
shape.FillFormat.Color = Color.LightBlue;
shape.Height = 75;
shape.Width = 100;
shape.HorizontalAlignment = ShapeHorizontalAlignment.Left;
shape.HorizontalOrigin = HorizontalOrigin.Margin;
shape.LineFormat.Line = true;
shape.LineFormat.Style = Syncfusion.DocIO.DLS.LineStyle.Single;
shape.Name = "Rectangle";
shape.Title = "Rectangle shape demo";
shape.VerticalAlignment = ShapeVerticalAlignment.Center;
shape.VerticalOrigin = VerticalOrigin.Page;
shape.WrapFormat.TextWrappingStyle = TextWrappingStyle.Square;
string paraText = "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";
//Add the new paragraph to shape with some text
shape.TextBody.AddParagraph().AppendText(paraText);
//Add the shape to paragraph
paragraph.ChildEntities.Add(shape);
//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("Template.docx")
'Add the section into Word document
Dim section As WSection = TryCast(document.AddSection(), WSection)
'Add a paragraph to created section
Dim paragraph As WParagraph = document.Sections(0).Paragraphs(0)
'Create a new shape
Dim shape As New Syncfusion.DocIO.DLS.Shape(document, AutoShapeType.Rectangle)
'Specify the shape formatting options
shape.AlternativeText = "demo shape"
shape.FillFormat.Color = Color.LightBlue
shape.Height = 75
shape.Width = 100
shape.HorizontalAlignment = ShapeHorizontalAlignment.Left
shape.HorizontalOrigin = HorizontalOrigin.Margin
shape.LineFormat.Line = True
shape.LineFormat.Style = Syncfusion.DocIO.DLS.LineStyle.[Single]
shape.Name = "Rectangle"
shape.Title = "Rectangle shape demo"
shape.VerticalAlignment = ShapeVerticalAlignment.Center
shape.VerticalOrigin = VerticalOrigin.Page
shape.WrapFormat.TextWrappingStyle = TextWrappingStyle.Square
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"
'Add the new paragraph to shape with some text
shape.TextBody.AddParagraph().AppendText(paraText)
'Add the shape to paragraph
paragraph.ChildEntities.Add(shape)
'Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
//Creates a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new paragraph to the section
WParagraph paragraph = section.AddParagraph() as WParagraph;
//Adds new shape to the document
Shape rectangle = paragraph.AppendShape(AutoShapeType.RoundedRectangle, 150, 100);
//Adds textbody contents to the shape
paragraph = rectangle.TextBody.AddParagraph() as WParagraph;
IWTextRange text = paragraph.AppendText("This text is in rounded rectangle shape");
//Sets rectangle shape rotation in degree
rectangle.Rotation = 90;
//Saves the Word document
document.Save("Sample.docx", FormatType.Docx);
//Closes the document
document.Close();
'Creates a new Word document
Dim document As WordDocument = New WordDocument
'Adds new section to the document
Dim section As IWSection = document.AddSection
'Adds new paragraph to the section
Dim paragraph As WParagraph = CType(section.AddParagraph, WParagraph)
'Adds new shape to the document
Dim rectangle As Shape = paragraph.AppendShape(AutoShapeType.RoundedRectangle, 150, 100)
'Adds textbody contents to the shape
paragraph = CType(rectangle.TextBody.AddParagraph, WParagraph)
Dim text As IWTextRange = paragraph.AppendText("This text is in rounded rectangle shape")
'Sets rectangle shape rotation in degree
rectangle.Rotation = 90
'Saves the Word document
document.Save("Sample.docx", FormatType.Docx)
'Closes the document
document.Close()
//Creates a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new paragraph to the section
WParagraph paragraph = section.AddParagraph() as WParagraph;
//Adds new shape to the document
Shape rectangle = paragraph.AppendShape(AutoShapeType.RoundedRectangle, 150, 100);
//Adds textbody contents to the shape
paragraph = rectangle.TextBody.AddParagraph() as WParagraph;
IWTextRange text = paragraph.AppendText("This text is in rounded rectangle shape");
//Sets horizontal flip to the rectangle shape
rectangle.FlipHorizontal = true;
//Saves the Word document
document.Save("Sample.docx", FormatType.Docx);
//Closes the document
document.Close();
'Creates a new Word document
Dim document As WordDocument = New WordDocument
'Adds new section to the document
Dim section As IWSection = document.AddSection
'Adds new paragraph to the section
Dim paragraph As WParagraph = CType(section.AddParagraph, WParagraph)
'Adds new shape to the document
Dim rectangle As Shape = paragraph.AppendShape(AutoShapeType.RoundedRectangle, 150, 100)
'Adds textbody contents to the shape
paragraph = CType(rectangle.TextBody.AddParagraph, WParagraph)
Dim text As IWTextRange = paragraph.AppendText("This text is in rounded rectangle shape")
'Sets horizontal flip to the rectangle shape
rectangle.FlipHorizontal = True
'Saves the Word document
document.Save("Sample.docx", FormatType.Docx)
'Closes the document
document.Close()
//Creates a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new paragraph to the section
WParagraph paragraph = section.AddParagraph() as WParagraph;
//Adds new shape to the document
Shape rectangle = paragraph.AppendShape(AutoShapeType.RoundedRectangle, 150, 100);
//Adds textbody contents to the shape
paragraph = rectangle.TextBody.AddParagraph() as WParagraph;
IWTextRange text = paragraph.AppendText("This text is in rounded rectangle shape");
//Sets vertical flip to the rectangle shape
rectangle.FlipVertical = true;
//Saves the Word document
document.Save("Sample.docx", FormatType.Docx);
//Closes the document
document.Close();
'Creates a new Word document
Dim document As WordDocument = New WordDocument
'Adds new section to the document
Dim section As IWSection = document.AddSection
'Adds new paragraph to the section
Dim paragraph As WParagraph = CType(section.AddParagraph, WParagraph)
'Adds new shape to the document
Dim rectangle As Shape = paragraph.AppendShape(AutoShapeType.RoundedRectangle, 150, 100)
'Adds textbody contents to the shape
paragraph = CType(rectangle.TextBody.AddParagraph, WParagraph)
Dim text As IWTextRange = paragraph.AppendText("This text is in rounded rectangle shape")
'Sets vertical flip to the rectangle shape
rectangle.FlipVertical = True
'Saves the Word document
document.Save("Sample.docx", FormatType.Docx)
'Closes the document
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
WParagraph paragraph = section.AddParagraph() as WParagraph;
paragraph.AppendText("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");
//Add new shape to the document
Shape rectangle = paragraph.AppendShape(AutoShapeType.RoundedRectangle, 150, 100);
//Set position for shape
rectangle.VerticalPosition = 72;
rectangle.HorizontalPosition = 72;
//Set text wrapping style
rectangle.WrapFormat.TextWrappingStyle = TextWrappingStyle.TopAndBottom;
rectangle.WrapFormat.DistanceBottom = 10;
rectangle.WrapFormat.DistanceLeft = 10;
rectangle.WrapFormat.DistanceRight = 10;
rectangle.WrapFormat.DistanceTop = 20;
paragraph.AppendText("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");
//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()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As WParagraph = TryCast(section.AddParagraph(), WParagraph)
paragraph.AppendText("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")
'Add new shape to the document
Dim rectangle As Shape = paragraph.AppendShape(AutoShapeType.RoundedRectangle, 150, 100)
'Set position for shape
rectangle.VerticalPosition = 72
rectangle.HorizontalPosition = 72
'Set text wrapping style
rectangle.WrapFormat.TextWrappingStyle = TextWrappingStyle.TopAndBottom
rectangle.WrapFormat.DistanceBottom = 10
rectangle.WrapFormat.DistanceLeft = 10
rectangle.WrapFormat.DistanceRight = 10
rectangle.WrapFormat.DistanceTop = 20
paragraph.AppendText("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")
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
//Loads an existing Word document into DocIO instance
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Creates the bookmark navigator instance to access the bookmark
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
//Moves the virtual cursor to the location before the end of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind");
//Gets the bookmark content as WordDocumentPart
WordDocumentPart wordDocumentPart = bookmarkNavigator.GetContent();
//Saves the WordDocumentPart as separate Word document
WordDocument newDocument = wordDocumentPart.GetAsWordDocument();
newDocument.Save("Result.docx", FormatType.Docx);
//Releases the resources hold by WordDocument instance
newDocument.Close();
document.Close();
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Creates the bookmark navigator instance to access the bookmark
Dim bookmarkNavigator As New BookmarksNavigator(document)
'Moves the virtual cursor to the location before the end of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind")
'Gets the bookmark content as WordDocumentPart
Dim wordDocumentPart As WordDocumentPart = bookmarkNavigator.GetContent()
'Saves the WordDocumentPart as separate Word document
Dim newDocument As WordDocument = wordDocumentPart.GetAsWordDocument()
newDocument.Save("Result.docx", FormatType.Docx)
'Releases the resources hold by WordDocument instance
newDocument.Close()
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Create the bookmark navigator instance to access the bookmark
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
//Move the virtual cursor to the before the end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind");
//Get the bookmark content
TextBodyPart part = bookmarkNavigator.GetBookmarkContent();
//Add the retrieved content into another new section
document.AddSection();
foreach(TextBodyItem item in part.BodyItems)
document.LastSection.Body.ChildEntities.Add(item);
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Create the bookmark navigator instance to access the bookmark
Dim bookmarkNavigator As New BookmarksNavigator(document)
'Move the virtual cursor to the before the end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind")
'Get the bookmark content
Dim part As TextBodyPart = bookmarkNavigator.GetBookmarkContent()
'Add the retrieved content into another new section
document.AddSection()
For Each item As TextBodyItem In part.BodyItems
document.LastSection.Body.ChildEntities.Add(item)
Next
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Create the bookmark navigator instance to access the bookmark
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
//Move the virtual cursor to the before the end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind", true, false);
//Get the bookmark content
TextBodyPart part = bookmarkNavigator.GetBookmarkContent();
//Add the retrieved content into another new section
document.AddSection();
foreach(TextBodyItem item in part.BodyItems)
document.LastSection.Body.ChildEntities.Add(item);
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Create the bookmark navigator instance to access the bookmark
Dim bookmarkNavigator As New BookmarksNavigator(document)
'Move the virtual cursor to the before the end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind", True, False)
'Get the bookmark content
Dim part As TextBodyPart = bookmarkNavigator.GetBookmarkContent()
'Add the retrieved content into another new section
document.AddSection()
For Each item As TextBodyItem In part.BodyItems
document.LastSection.Body.ChildEntities.Add(item)
Next
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Create the bookmark navigator instance to access the bookmark
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
//Move the virtual cursor to the before the end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind");
//Insert a new text before the bookmark end of the bookmark
bookmarkNavigator.InsertText(" Northwind Database is a set of tables containing data fitted into predefined categories.");
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Create the bookmark navigator instance to access the bookmark
Dim bookmarkNavigator As New BookmarksNavigator(document)
'Move the virtual cursor to the before the end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind")
'Insert a new text before the bookmark end of the bookmark
bookmarkNavigator.InsertText(" Northwind Database is a set of tables containing data fitted into predefined categories.")
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Create the bookmark navigator instance to access the bookmark
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
//Move the virtual cursor to the before the end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind");
//Insert a new text before the bookmark end of the bookmark
bookmarkNavigator.InsertText(" Northwind Database is a set of tables containing data fitted into predefined categories.", true);
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Create the bookmark navigator instance to access the bookmark
Dim bookmarkNavigator As New BookmarksNavigator(document)
'Move the virtual cursor to the before the end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind")
'Insert a new text before the bookmark end of the bookmark
bookmarkNavigator.InsertText(" Northwind Database is a set of tables containing data fitted into predefined categories.", True)
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Create the bookmark navigator instance to access the bookmark
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
//Move to the virtual cursor before the end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind", false, false);
//Insert a new paragraph before the bookmark end
IWParagraph paragraph = new WParagraph(document);
paragraph.AppendText("Northwind Database Contains the following tables:");
bookmarkNavigator.InsertParagraph(paragraph);
//Insert a new table before the bookmark end
WTable table = new WTable(document);
table.ResetCells(3, 2);
table[0, 0].AddParagraph().AppendText("Suppliers");
table[0, 1].AddParagraph().AppendText("2");
table[1, 0].AddParagraph().AppendText("Customers");
table[1, 1].AddParagraph().AppendText("1");
table[2, 0].AddParagraph().AppendText("Employees");
table[2, 1].AddParagraph().AppendText("3");
bookmarkNavigator.InsertTable(table);
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Create the bookmark navigator instance to access the bookmark
Dim bookmarkNavigator As New BookmarksNavigator(document)
'Move to the virtual cursor before the end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind", False, False)
'Insert a new paragraph before the bookmark end
Dim paragraph As IWParagraph = New WParagraph(document)
paragraph.AppendText("Northwind Database Contains the following tables:")
bookmarkNavigator.InsertParagraph(paragraph)
'Insert a new table before the bookmark end
Dim table As New WTable(document)
table.ResetCells(3, 2)
table(0, 0).AddParagraph().AppendText("Suppliers")
table(0, 1).AddParagraph().AppendText("2")
table(1, 0).AddParagraph().AppendText("Customers")
table(1, 1).AddParagraph().AppendText("1")
table(2, 0).AddParagraph().AppendText("Employees")
table(2, 1).AddParagraph().AppendText("3")
bookmarkNavigator.InsertTable(table)
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Create the bookmark navigator instance to access the bookmark
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
//Move to the virtual cursor after the end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind", false, true);
//Insert a new picture after the bookmark end
WPicture picture = bookmarkNavigator.InsertParagraphItem(ParagraphItemType.Picture) as WPicture;
picture.LoadImage(Image.FromFile("Northwind.png"));
picture.WidthScale = 50;
picture.HeightScale = 50;
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Create the bookmark navigator instance to access the bookmark
Dim bookmarkNavigator As New BookmarksNavigator(document)
'Move to the virtual cursor after the end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind", False, True)
'Insert a new picture after the bookmark end
Dim picture As WPicture = TryCast(bookmarkNavigator.InsertParagraphItem(ParagraphItemType.Picture), WPicture)
picture.LoadImage(Image.FromFile("Northwind.png"))
picture.WidthScale = 50
picture.HeightScale = 50
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Create the bookmark navigator instance to access the bookmark
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
//Move to the virtual cursor after the end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind", false, true);
//Insert a new paragraph before the bookmark start
IWParagraph paragraph = new WParagraph(document);
paragraph.AppendText("Northwind Database is a set of tables containing data fitted into predefined categories.");
bookmarkNavigator.InsertParagraph(paragraph);
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Create the bookmark navigator instance to access the bookmark
Dim bookmarkNavigator As New BookmarksNavigator(document)
'Move to the virtual cursor after the end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind", False, True)
'Insert a new paragraph before the bookmark start
Dim paragraph As IWParagraph = New WParagraph(document)
paragraph.AppendText("Northwind Database is a set of tables containing data fitted into predefined categories.")
bookmarkNavigator.InsertParagraph(paragraph)
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Create the bookmark navigator instance to access the bookmark
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
//Move to the virtual cursor before the bookmark end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind");
//Get the bookmark content
TextBodyPart textBodyPart = bookmarkNavigator.GetBookmarkContent();
document.AddSection();
IWParagraph paragraph = document.LastSection.AddParagraph();
paragraph.AppendText("Northwind Database is a set of tables containing data fitted into predefined categories.");
//Add the new bookmark into Word document
paragraph.AppendBookmarkStart("bm_empty");
paragraph.AppendBookmarkEnd("bm_empty");
//Move to the virtual cursor after the start location of the bookmark "bm_empty"
bookmarkNavigator.MoveToBookmark("bm_empty", true, true);
//Insert the text body part after the bookmark start
bookmarkNavigator.InsertTextBodyPart(textBodyPart);
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Create the bookmark navigator instance to access the bookmark
Dim bookmarkNavigator As New BookmarksNavigator(document)
'Move to the virtual cursor before the bookmark end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind")
'Get the bookmark content
Dim textBodyPart As TextBodyPart = bookmarkNavigator.GetBookmarkContent()
document.AddSection()
Dim paragraph As IWParagraph = document.LastSection.AddParagraph()
paragraph.AppendText("Northwind Database is a set of tables containing data fitted into predefined categories.")
'Add the new bookmark into Word document
paragraph.AppendBookmarkStart("bm_empty")
paragraph.AppendBookmarkEnd("bm_empty")
'Move to the virtual cursor after the start location of the bookmark "bm_empty"
bookmarkNavigator.MoveToBookmark("bm_empty", True, True)
'Insert the text body part after the bookmark start
bookmarkNavigator.InsertTextBodyPart(textBodyPart)
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Create the bookmark navigator instance to access the bookmark
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
//Move the virtual cursor to the before the end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind");
//Get the bookmark content
TextBodyPart part = bookmarkNavigator.GetBookmarkContent();
//Add the retrieved content into another new section
document.AddSection();
foreach(TextBodyItem item in part.BodyItems)
document.LastSection.Body.ChildEntities.Add(item);
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Create the bookmark navigator instance to access the bookmark
Dim bookmarkNavigator As New BookmarksNavigator(document)
'Move the virtual cursor to the before the end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind")
'Get the bookmark content
Dim part As TextBodyPart = bookmarkNavigator.GetBookmarkContent()
'Add the retrieved content into another new section
document.AddSection()
For Each item As TextBodyItem In part.BodyItems
document.LastSection.Body.ChildEntities.Add(item)
Next
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the template document with bookmark "Northwind" whose start and end preserved in different section
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Create the bookmark navigator instance to access the bookmark
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
//Move the virtual cursor to the before the end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind");
//Get the bookmark content as WordDocumentPart
WordDocumentPart wordDocumentPart = bookmarkNavigator.GetContent();
//Save the WordDocumentPart as separate Word document
WordDocument newDocument = wordDocumentPart.GetAsWordDocument();
newDocument.Save("Result.docx", FormatType.Docx);
//Release the resources hold by WordDocument instance
newDocument.Close();
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document with bookmark "Northwind" whose start and end preserved in different section
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Create the bookmark navigator instance to access the bookmark
Dim bookmarkNavigator As New BookmarksNavigator(document)
'Move the virtual cursor to the before the end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind")
'Get the bookmark content as WordDocumentPart
Dim wordDocumentPart As WordDocumentPart = bookmarkNavigator.GetContent()
'Save the WordDocumentPart as separate Word document
Dim newDocument As WordDocument = wordDocumentPart.GetAsWordDocument()
newDocument.Save("Result.docx", FormatType.Docx)
'Release the resources hold by WordDocument instance
newDocument.Close()
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Create the bookmark navigator instance to access the bookmark
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
//Move the virtual cursor to the before the end location of the bookmark " Northwind "
bookmarkNavigator.MoveToBookmark("Northwind");
//Delete bookmark content without deleting the format in the target document.
bookmarkNavigator.DeleteBookmarkContent(false);
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Create the bookmark navigator instance to access the bookmark
Dim bookmarkNavigator As New BookmarksNavigator(document)
'Move the virtual cursor to the before the end location of the bookmark " Northwind "
bookmarkNavigator.MoveToBookmark("Northwind")
'Delete bookmark content without deleting the format in the target document.
bookmarkNavigator.DeleteBookmarkContent(False)
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Create the bookmark navigator instance to access the bookmark
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
//Move to the virtual cursor before the bookmark end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind");
//Get the bookmark content
TextBodyPart textBodyPart = bookmarkNavigator.GetBookmarkContent();
document.AddSection();
IWParagraph paragraph = document.LastSection.AddParagraph();
paragraph.AppendText("Northwind Database is a set of tables containing data fitted into predefined categories.");
//Add the new bookmark into Word document
paragraph.AppendBookmarkStart("bm_empty");
paragraph.AppendBookmarkEnd("bm_empty");
//Move to the virtual cursor before the end location of the bookmark "bm_empty"
bookmarkNavigator.MoveToBookmark("bm_empty");
//Replace the bookmark content with text body part
bookmarkNavigator.ReplaceBookmarkContent(textBodyPart);
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Create the bookmark navigator instance to access the bookmark
Dim bookmarkNavigator As New BookmarksNavigator(document)
'Move to the virtual cursor before the bookmark end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind")
'Get the bookmark content
Dim textBodyPart As TextBodyPart = bookmarkNavigator.GetBookmarkContent()
document.AddSection()
Dim paragraph As IWParagraph = document.LastSection.AddParagraph()
paragraph.AppendText("Northwind Database is a set of tables containing data fitted into predefined categories.")
'Add the new bookmark into Word document
paragraph.AppendBookmarkStart("bm_empty")
paragraph.AppendBookmarkEnd("bm_empty")
'Move to the virtual cursor before the end location of the bookmark "bm_empty"
bookmarkNavigator.MoveToBookmark("bm_empty")
'Replace the bookmark content with text body part
bookmarkNavigator.ReplaceBookmarkContent(textBodyPart)
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the template document with bookmark "Northwind" whose start and end preserved in different section
WordDocument templateDocument = new WordDocument("Template.docx", FormatType.Docx);
//Create the bookmark navigator instance to access the bookmark
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(templateDocument);
//Move the virtual cursor to the before the end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind");
//Get the bookmark content as WordDocumentPart
WordDocumentPart wordDocumentPart = bookmarkNavigator.GetContent();
//Close the template document
templateDocument.Close();
//Load the Word document with bookmark NorthwindDB
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Create the bookmark navigator instance to access the bookmark
bookmarkNavigator = new BookmarksNavigator(document);
//Move the virtual cursor to the before the end location of the bookmark "NorthwindDB"
bookmarkNavigator.MoveToBookmark("NorthwindDB");
//Replace the bookmark content with word body part
bookmarkNavigator.ReplaceContent(wordDocumentPart);
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document with bookmark "Northwind" whose start and end preserved in different section
Dim templateDocument As New WordDocument("Template.docx", FormatType.Docx)
'Create the bookmark navigator instance to access the bookmark
Dim bookmarkNavigator As New BookmarksNavigator(templateDocument)
'Move the virtual cursor to the before the end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind")
'Get the bookmark content as WordDocumentPart
Dim wordDocumentPart As WordDocumentPart = bookmarkNavigator.GetContent()
'Close the template document
templateDocument.Close()
'Load the Word document with bookmark NorthwindDB
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Create the bookmark navigator instance to access the bookmark
bookmarkNavigator = New BookmarksNavigator(document)
'Move the virtual cursor to the before the end location of the bookmark "NorthwindDB"
bookmarkNavigator.MoveToBookmark("NorthwindDB")
'Replace the bookmark content with word body part
bookmarkNavigator.ReplaceContent(wordDocumentPart)
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Create the bookmark navigator instance to access the bookmark
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
document.AddSection();
IWParagraph paragraph = document.LastSection.AddParagraph();
//Add the new bookmark into Word document
paragraph.AppendBookmarkStart("bm_empty");
paragraph.AppendBookmarkEnd("bm_empty");
//Move to the virtual cursor before the end location of the bookmark "bm_empty"
bookmarkNavigator.MoveToBookmark("bm_empty");
//Replace the bookmark content with text body part
bookmarkNavigator.ReplaceBookmarkContent(" Northwind Database is a set of tables containing data fitted into predefined categories.", true);
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Create the bookmark navigator instance to access the bookmark
Dim bookmarkNavigator As New BookmarksNavigator(document)
document.AddSection()
Dim paragraph As IWParagraph = document.LastSection.AddParagraph()
'Add the new bookmark into Word document
paragraph.AppendBookmarkStart("bm_empty")
paragraph.AppendBookmarkEnd("bm_empty")
'Move to the virtual cursor before the end location of the bookmark "bm_empty"
bookmarkNavigator.MoveToBookmark("bm_empty")
'Replace the bookmark content with text body part
bookmarkNavigator.ReplaceBookmarkContent(" Northwind Database is a set of tables containing data fitted into predefined categories.", True)
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Get the bookmark instance with bookmark name
Syncfusion.DocIO.DLS.Bookmark bookmark = document.Bookmarks["Northwind"];
//Access the bookmark start�s owner paragraph using bookmark and change its back color
bookmark.BookmarkStart.OwnerParagraph.ParagraphFormat.BackColor = Color.AliceBlue;
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Get the bookmark instance with bookmark name
Dim bookmark As Syncfusion.DocIO.DLS.Bookmark = document.Bookmarks("Northwind")
'Access the bookmark start�s owner paragraph using bookmark and change its back color
bookmark.BookmarkStart.OwnerParagraph.ParagraphFormat.BackColor = Color.AliceBlue
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Get the bookmark instance using FindByName method of BookmarkCollection with bookmark name
Bookmark bookmark = document.Bookmarks.FindByName("Northwind");
//Access the bookmark start�s owner paragraph using bookmark and change its back color
bookmark.BookmarkStart.OwnerParagraph.ParagraphFormat.BackColor = Color.AliceBlue;
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Get the bookmark instance using FindByName method of BookmarkCollection with bookmark name
Dim bookmark As Bookmark = document.Bookmarks.FindByName("Northwind")
'Access the bookmark start�s owner paragraph using bookmark and change its back color
bookmark.BookmarkStart.OwnerParagraph.ParagraphFormat.BackColor = Color.AliceBlue
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Remove the bookmark at the second index from Word document.
document.Bookmarks.RemoveAt(1);
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Remove the bookmark at the second index from Word document.
document.Bookmarks.RemoveAt(1)
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Get the bookmark instance using FindByName method of BookmarkCollection with bookmark name
Bookmark bookmark = document.Bookmarks.FindByName("Northwind");
//Remove the bookmark named "Northwind" from Word document.
document.Bookmarks.Remove(bookmark);
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Get the bookmark instance using FindByName method of BookmarkCollection with bookmark name
Dim bookmark As Bookmark = document.Bookmarks.FindByName("Northwind")
'Remove the bookmark named "Northwind" from Word document.
document.Bookmarks.Remove(bookmark)
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Remove all the bookmarks from Word document
document.Bookmarks.Clear();
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Remove all the bookmarks from Word document
document.Bookmarks.Clear()
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
foreach (WSection section in document.Sections)
{
//Populates the specified number of columns with specified spacing.
if (section.Columns.Count > 0)
section.Columns.Populate(2, 10);
}
//Add the section into Word document
IWSection newSection = document.AddSection();
//Add the column into the section
newSection.AddColumn(150, 20);
//Add the column into the section
newSection.AddColumn(150, 20);
//Add a paragraph to created section
IWParagraph paragraph = newSection.AddParagraph();
//Add a paragraph to created section
paragraph = newSection.AddParagraph();
string paraText = "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 = newSection.AddParagraph();
//Append the text to the created paragraph
paragraph.AppendText(paraText);
//Add the column breaks
paragraph.AppendBreak(BreakType.ColumnBreak);
//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)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
For Each section As WSection In document.Sections
'Populates the specified number of columns with specified spacing.
If section.Columns.Count > 0 Then
section.Columns.Populate(2, 10)
End If
Next
'Add the section into Word document
Dim newSection As IWSection = document.AddSection()
'Add the column into the section
newSection.AddColumn(150, 20)
'Add the column into the section
newSection.AddColumn(150, 20)
'Add a paragraph to created section
Dim paragraph As IWParagraph = newSection.AddParagraph()
'Add a paragraph to created section
paragraph = newSection.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 = newSection.AddParagraph()
'Append the text to the created paragraph
paragraph.AppendText(paraText)
'Add the column breaks
paragraph.AppendBreak(BreakType.ColumnBreak)
'Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Comment.docx");
//Iterate the comments in the Word document
foreach (WComment comment in document.Comments)
{
//Modify the last paragraph text of an existing comment if it is added by "Peter"
if (comment.Format.User == "Peter")
comment.TextBody.LastParagraph.Text = "Modified Comment Content";
}
document.Save("ModifiedComment.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Comment.docx")
'Iterate the comments in the Word document
For Each comment As WComment In document.Comments
'Modify the last paragraph text of an existing comment if it is added by "Peter"
If comment.Format.User = "Peter" Then
comment.TextBody.LastParagraph.Text = "Modified Comment Content"
End If
Next
document.Save("ModifiedComment.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Comment.docx");
//Remove the second comment from a document
document.Comments.RemoveAt(1);
//Save and close the Word document
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Comment.docx")
'Remove the second comment from a document
document.Comments.RemoveAt(1)
'Save and close the Word document
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Comment.docx");
//Remove all the comments in a Word document
document.Comments.Clear();
//Save and close the Word document
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Comment.docx")
'Remove all the comments in a Word document
document.Comments.Clear()
'Save and close the Word document
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Comment.docx");
//Get the second comment from a document.
WComment comment = document.Comments[1];
//Remove comment from a document.
document.Comments.Remove(comment);
//Save and close the Word document
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Comment.docx")
'Get the second comment from a document.
Dim comment As WComment = document.Comments(1)
'Remove comment from a document.
document.Comments.Remove(comment)
'Save and close the Word document
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Open an input Word template
WordDocument document = new WordDocument(inputFileName);
//Access the styles collection which contains paragraph and character styles in Word document
WParagraphStyle style = new WParagraphStyle(document);
//Specify the style name.
style.Name = "User_Defined_style";
//Specify the character properties for the style
style.CharacterFormat.Bold = true;
style.CharacterFormat.FontName = "Arial";
style.CharacterFormat.FontSize = 14;
//Specify the paragraph properties for the style
style.ParagraphFormat.BackColor = Color.LightGray;
style.ParagraphFormat.AfterSpacing = 18f;
style.ParagraphFormat.BeforeSpacing = 18f;
StyleCollection styleCollection = document.Styles as StyleCollection;
//Add the style to the document styles collection.
styleCollection.Add(style);
//Save and close the document
document.Save(outputFileName, FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Open an input Word template
Dim document As New WordDocument(inputFileName)
'Access the styles collection which contains paragraph and character styles in Word document
Dim style As New WParagraphStyle(document)
'Specify the style name.
style.Name = "User_Defined_style"
'Specify the character properties for the style
style.CharacterFormat.Bold = True
style.CharacterFormat.FontName = "Arial"
style.CharacterFormat.FontSize = 14
'Specify the paragraph properties for the style
style.ParagraphFormat.BackColor = Color.LightGray
style.ParagraphFormat.AfterSpacing = 18F
style.ParagraphFormat.BeforeSpacing = 18F
Dim styleCollection As StyleCollection = TryCast(document.Styles, StyleCollection)
'Add the style to the document styles collection.
styleCollection.Add(style)
'Save and close the document
document.Save(outputFileName, FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Open an input Word template
WordDocument document = new WordDocument(inputFileName);
//Access the styles collection which contains paragraph and character styles in Word document
IStyleCollection styleCollection = document.Styles;
//Find the style with the name "Heading 1"
WParagraphStyle heading1ParagraphStyle = styleCollection.FindByName("Heading 1") as WParagraphStyle;
//Change the text color of style "Heading 1" as DarkBlue
heading1ParagraphStyle.CharacterFormat.TextColor = Color.DarkBlue;
//Change the first line indent of Paragraph as 36 points
heading1ParagraphStyle.ParagraphFormat.FirstLineIndent = 36;
document.Save(outputFileName, FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Open an input Word template
Dim document As New WordDocument(inputFileName)
'Access the styles collection which contains paragraph and character styles in Word document
Dim styleCollection As IStyleCollection = document.Styles
'Find the style with the name "Heading 1"
Dim heading1ParagraphStyle As WParagraphStyle = TryCast(styleCollection.FindByName("Heading 1"), WParagraphStyle)
'Change the text color of style "Heading 1" as DarkBlue
heading1ParagraphStyle.CharacterFormat.TextColor = Color.DarkBlue
'Change the first line indent of paragraph as 36 points
heading1ParagraphStyle.ParagraphFormat.FirstLineIndent = 36
document.Save(outputFileName, FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Open an input Word template
WordDocument document = new WordDocument(inputFileName);
//Access the styles collection which contains paragraph and character styles in Word document
IStyleCollection styleCollection = document.Styles;
//Find the style with the name "Heading 1"
WParagraphStyle heading1ParagraphStyle = styleCollection.FindByName("Heading 1", StyleType.ParagraphStyle) as WParagraphStyle;
//Change the text color of style "Heading 1" as DarkBlue
heading1ParagraphStyle.CharacterFormat.TextColor = Color.DarkBlue;
//Change the first line indent of Paragraph as 36 points
heading1ParagraphStyle.ParagraphFormat.FirstLineIndent = 36;
document.Save(outputFileName, FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Open an input Word template
Dim document As New WordDocument(inputFileName)
'Access the styles collection which contains paragraph and character styles in Word document
Dim styleCollection As IStyleCollection = document.Styles
'Find the style with the name "Heading 1"
Dim heading1ParagraphStyle As WParagraphStyle = TryCast(styleCollection.FindByName("Heading 1", StyleType.ParagraphStyle), WParagraphStyle)
'Change the text color of style "Heading 1" as DarkBlue
heading1ParagraphStyle.CharacterFormat.TextColor = Color.DarkBlue
'Change the first line indent of Paragraph as 36 points
heading1ParagraphStyle.ParagraphFormat.FirstLineIndent = 36
document.Save(outputFileName, FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Open an input Word template
WordDocument document = new WordDocument("Template.docx");
//Access the styles collection which contains paragraph and character styles in Word document
WParagraphStyle style = new WParagraphStyle(document);
//Specify the style name.
style.Name = "User_Defined_style";
//Specify the character properties for the style
style.CharacterFormat.Bold = true;
style.CharacterFormat.FontName = "Arial";
style.CharacterFormat.FontSize = 14;
//Specify the paragraph properties for the style
style.ParagraphFormat.BackColor = Color.LightGray;
style.ParagraphFormat.AfterSpacing = 18f;
style.ParagraphFormat.BeforeSpacing = 18f;
StyleCollection styleCollection = document.Styles as StyleCollection;
//Add the style to the document styles collection.
styleCollection.Add(style);
//Save and close the document
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Open an input Word template
Dim document As New WordDocument(inputFileName)
'Access the styles collection which contains paragraph and character styles in Word document
Dim style As New WParagraphStyle(document)
'Specify the style name.
style.Name = "User_Defined_style"
'Specify the character properties for the style
style.CharacterFormat.Bold = True
style.CharacterFormat.FontName = "Arial"
style.CharacterFormat.FontSize = 14
'Specify the paragraph properties for the style
style.ParagraphFormat.BackColor = Color.LightGray
style.ParagraphFormat.AfterSpacing = 18F
style.ParagraphFormat.BeforeSpacing = 18F
Dim styleCollection As StyleCollection = TryCast(document.Styles, StyleCollection)
'Add the style to the document styles collection.
styleCollection.Add(style)
'Save and close the document
document.Save(outputFileName, FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Open an input Word template
WordDocument document = new WordDocument("Template.docx");
//Access the styles collection which contains paragraph and character styles in Word document
IStyleCollection styleCollection = document.Styles;
//Find the style with the name "Heading 1"
WParagraphStyle heading1ParagraphStyle = styleCollection.FindByName("Heading 1") as WParagraphStyle;
//Change the text color of style "Heading 1" as DarkBlue
heading1ParagraphStyle.CharacterFormat.TextColor = Color.DarkBlue;
//Change the first line indent of Paragraph as 36 points
heading1ParagraphStyle.ParagraphFormat.FirstLineIndent = 36;
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Open an input Word template
Dim document As New WordDocument(inputFileName)
'Access the styles collection which contains paragraph and character styles in Word document
Dim styleCollection As IStyleCollection = document.Styles
'Find the style with the name "Heading 1"
Dim heading1ParagraphStyle As WParagraphStyle = TryCast(styleCollection.FindByName("Heading 1"), WParagraphStyle)
'Change the text color of style "Heading 1" as DarkBlue
heading1ParagraphStyle.CharacterFormat.TextColor = Color.DarkBlue
'Change the first line indent of paragraph as 36 points
heading1ParagraphStyle.ParagraphFormat.FirstLineIndent = 36
document.Save(outputFileName, FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Open an input Word template
WordDocument document = new WordDocument("Template.docx");
//Access the styles collection which contains paragraph and character styles in Word document
IStyleCollection styleCollection = document.Styles;
//Find the style with the name "Heading 1"
WParagraphStyle heading1ParagraphStyle = styleCollection.FindByName("Heading 1", StyleType.ParagraphStyle) as WParagraphStyle;
//Change the text color of style "Heading 1" as DarkBlue
heading1ParagraphStyle.CharacterFormat.TextColor = Color.DarkBlue;
//Change the first line indent of Paragraph as 36 points
heading1ParagraphStyle.ParagraphFormat.FirstLineIndent = 36;
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Open an input Word template
Dim document As New WordDocument(inputFileName)
'Access the styles collection which contains paragraph and character styles in Word document
Dim styleCollection As IStyleCollection = document.Styles
'Find the style with the name "Heading 1"
Dim heading1ParagraphStyle As WParagraphStyle = TryCast(styleCollection.FindByName("Heading 1", StyleType.ParagraphStyle), WParagraphStyle)
'Change the text color of style "Heading 1" as DarkBlue
heading1ParagraphStyle.CharacterFormat.TextColor = Color.DarkBlue
'Change the first line indent of Paragraph as 36 points
heading1ParagraphStyle.ParagraphFormat.FirstLineIndent = 36
document.Save(outputFileName, FormatType.Docx)
document.Close()
End Sub
//Load an existing Word document into DocIO instance.
WordDocument document = new WordDocument("Template.docx");
//get all the revisions from the revision collection and accepts all.
document.Revisions.AcceptAll();
//Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Load an existing Word document into DocIO instance.
Dim document As WordDocument = New WordDocument("Template.docx")
'Get all the revision from the revision collection and accepts all.
document.Revisions.AcceptAll()
'Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Load an existing Word document into DocIO instance.
WordDocument document = new WordDocument("Template.docx");
//get all the revisions from the revision collection and reject all.
document.Revisions.RejectAll();
//Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Load an existing Word document into DocIO instance.
Dim document As WordDocument = New WordDocument("Template.docx")
'Get all the revisions from the revision collection and reject all.
document.Revisions.RejectAll()
'Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Loads an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Gets the revision from the revision collections
Revision revision = document.Revisions[0];
//If the revision is formatting type of revision, then accept it
if (revision.RevisionType == RevisionType.Formatting)
revision.Accept();
//Saves and closes the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Loads an existing Word document
Dim document As WordDocument = New WordDocument("Template.docx")
'Gets the revision from the revision collections
Dim rev As Revision = document.Revisions(0)
'If the revision is formatting type of revision, then accept it
If rev.RevisionType Is RevisionType.Formatting Then rev.Accept()
'Saves and closes the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add tab at position 0;
paragraph.ParagraphFormat.Tabs.AddTab();
//Add tab stop at position 11
Tab firstTab = paragraph.ParagraphFormat.Tabs.AddTab(11);
//Add tab stop at position 62, with tab justification and tab leader.
paragraph.ParagraphFormat.Tabs.AddTab(62, TabJustification.Left, TabLeader.Single);
paragraph.AppendText("This sample\t illustrates the use of tabs in the paragraph. Tabs\t can be inserted or removed from the paragraph.");
//Remove tab stop from the collection
paragraph.ParagraphFormat.Tabs.RemoveByTabPosition(11);
//Remove tab at index 0;
paragraph.ParagraphFormat.Tabs.RemoveAt(0);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add tab at position 0;
paragraph.ParagraphFormat.Tabs.AddTab()
'Add tab stop at position 11
Dim firstTab As Tab = paragraph.ParagraphFormat.Tabs.AddTab(11)
'Add tab stop at position 62, with tab justification and tab leader.
paragraph.ParagraphFormat.Tabs.AddTab(62, TabJustification.Left, TabLeader.[Single])
paragraph.AppendText("This sample" & vbTab & " illustrates the use of tabs in the paragraph. Tabs" & vbTab & " can be inserted or removed from the paragraph.")
'Remove tab stop from the collection
paragraph.ParagraphFormat.Tabs.RemoveByTabPosition(11)
'Remove tab at index 0;
paragraph.ParagraphFormat.Tabs.RemoveAt(0)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//open a template document
WordDocument document = new WordDocument("Textbox.docx");
//Remove the textbox at index one.
document.TextBoxes.RemoveAt(1);
//Save and close the document
document.Save("Sample.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'open a template document
Dim document As New WordDocument("Textbox.docx")
'Remove the textbox at index one.
document.TextBoxes.RemoveAt(1)
'Save and close the document
document.Save("Sample.docx")
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//open a template document
WordDocument document = new WordDocument("Textbox.docx");
//Removes the textboxes from the document
document.TextBoxes.Clear();
//Save and close the document
document.Save("Sample.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'open a template document
Dim document As New WordDocument("Textbox.docx")
'Removes the textboxes from the document
document.TextBoxes.Clear()
'Save and close the document
document.Save("Sample.docx")
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section
IWSection section = document.AddSection();
//Add new paragraph
section.AddParagraph().AppendText("Price Details");
section.AddParagraph();
//Add a new table into Word document
IWTable table = section.AddTable();
//Add the first row into table
WTableRow row = table.AddRow();
//Create a new cell
WTableCell cell = new WTableCell(document);
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("Item");
//Add the cell to the cells collection.
row.Cells.Add(cell);
int index = row.Cells.IndexOf(cell);
//Create a new cell
cell = new WTableCell(document);
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("Price($)");
//Add the cell to the cells collection.
row.Cells.Insert(index + 1, cell);
//Add the second row into table
row = table.AddRow(true, false);
//Add the first cell into second row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("Apple");
//Add the second cell into second row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("50");
//Add the third row into table
row = table.AddRow(true, false);
//Add the first cell into third row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("Orange");
//Add the second cell into third row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("30");
//Add the third cell into third row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("Banana");
//Removes the specified cell.
row.Cells.Remove(cell);
//Save and close the document
document.Save("Table.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 new section
Dim section As IWSection = document.AddSection()
'Add new paragraph
section.AddParagraph().AppendText("Price Details")
section.AddParagraph()
'Add a new table into Word document
Dim table As IWTable = section.AddTable()
'Add the first row into table
Dim row As WTableRow = table.AddRow()
'Create a new cell
Dim cell As New WTableCell(document)
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("Item")
'Add the cell to the cells collection.
row.Cells.Add(cell)
Dim index As Integer = row.Cells.IndexOf(cell)
'Create a new cell
cell = New WTableCell(document)
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("Price($)")
'Add the cell to the cells collection.
row.Cells.Insert(index + 1, cell)
'Add the second row into table
row = table.AddRow(True, False)
'Add the first cell into second row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("Apple")
'Add the second cell into second row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("50")
'Add the third row into table
row = table.AddRow(True, False)
'Add the first cell into third row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("Orange")
'Add the second cell into third row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("30")
'Add the third cell into third row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("Banana")
'Removes the specified cell.
row.Cells.Remove(cell)
'Save and close the document
document.Save("Table.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument("Template.docx");
//Find the specified text from the document
TextSelection selection = document.Find("paragraph", false, false);
WTextRange range = selection.GetAsOneRange();
//Get its owner paragraph
WParagraph paragraph = range.OwnerParagraph;
WTextBody textbody = paragraph.OwnerTextBody;
//Get the collection of paragraphs in the section
WParagraphCollection collection = (WParagraphCollection)textbody.Paragraphs;
//Get the index of the paragraph
int index = collection.IndexOf(range.OwnerParagraph);
paragraph = new WParagraph(document);
paragraph.AppendText("hello world");
//Insert new item
collection.Insert(index + 1, paragraph);
//Removes paragraph at index zero
collection.RemoveAt(0);
//Save and close the paragraph.
document.Save("Result.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument("Template.docx")
'Find the specified text from the document
Dim selection As TextSelection = document.Find("paragraph", False, False)
Dim range As WTextRange = selection.GetAsOneRange()
'Get its owner paragraph
Dim paragraph As WParagraph = range.OwnerParagraph
Dim textbody As WTextBody = paragraph.OwnerTextBody
'Get the collection of paragraphs in the section
Dim collection As WParagraphCollection = DirectCast(textbody.Paragraphs, WParagraphCollection)
'Get the index of the paragraph
Dim index As Integer = collection.IndexOf(range.OwnerParagraph)
paragraph = New WParagraph(document)
paragraph.AppendText("hello world")
'Insert new item
collection.Insert(index - 1, paragraph)
'Removes paragraph at index zero
collection.RemoveAt(0)
'Save and close the paragraph.
document.Save("Result.docx")
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
section.AddParagraph().AppendText("Price Details");
section.AddParagraph();
//Add a new table into Word document
IWTable table = section.AddTable();
//Get the rows collection from table
WRowCollection rowCollection = table.Rows;
//Add the first row into table
WTableRow row = new WTableRow(document);
//Add the first cell into first row
WTableCell cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("Item");
//Add the second cell into first row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("Price($)");
//Add row to the collection
rowCollection.Add(row);
//Add the second row into table
row = new WTableRow(document);
//Add the first cell into second row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("Apple");
//Add the second cell into second row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("50");
//Insert row at index 1
rowCollection.Insert(1, row);
//Add the third row into table
row = new WTableRow(document);
//Add the first cell into third row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("Orange");
//Add the second cell into third row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("30");
//Insert row
rowCollection.Insert(2, row);
//Remove row at index 0.
rowCollection.RemoveAt(0);
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()
Dim section As IWSection = document.AddSection()
section.AddParagraph().AppendText("Price Details")
section.AddParagraph()
'Add a new table into Word document
Dim table As IWTable = section.AddTable()
'Get the rows collection from table
Dim rowCollection As WRowCollection = table.Rows
'Add the first row into table
Dim row As New WTableRow(document)
'Add the first cell into first row
Dim cell As WTableCell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("Item")
'Add the second cell into first row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("Price($)")
'Add row to the collection
rowCollection.Add(row)
'Add the second row into table
row = New WTableRow(document)
'Add the first cell into second row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("Apple")
'Add the second cell into second row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("50")
'Insert row at index 1
rowCollection.Insert(1, row)
'Add the third row into table
row = New WTableRow(document)
'Add the first cell into third row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("Orange")
'Add the second cell into third row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("30")
'Insert row
rowCollection.Insert(2, row)
'Remove row at index 0.
rowCollection.RemoveAt(0)
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx");
//Get the tables collection
WTableCollection tablecollection = document.Sections[0].Tables as WTableCollection;
//Create new table
WTable table = new WTable(document);
table.ResetCells(2,2);
//Add table to the collection
tablecollection.Add(table);
//Get the index of the added table
int index = tablecollection.IndexOf(table);
//Insert another table at next index
table = new WTable(document);
table.ResetCells(3, 3);
tablecollection.Insert(index + 1, table);
//Remove the table at index 0
tablecollection.RemoveAt(0);
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx")
'Get the tables collection
Dim tablecollection As WTableCollection = TryCast(document.Sections(0).Tables, WTableCollection)
'Create new table
Dim table As New WTable(document)
table.ResetCells(2, 2)
'Add table to the collection
tablecollection.Add(table)
'Get the index of the added table
Dim index As Integer = tablecollection.IndexOf(table)
'Insert another table at next index
table = New WTable(document)
table.ResetCells(3, 3)
tablecollection.Insert(index + 1, table)
'Remove the table at index 0
tablecollection.RemoveAt(0)
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Loads an existing document
WordDocument document = new WordDocument("Template.docx");
HTMLExport export = new HTMLExport();
//The images in the input document will be copied to this folder
document.SaveOptions.HtmlExportImagesFolder = @"D:\Data\";
//The headers and footers in the input will be exported
document.SaveOptions.HtmlExportHeadersFooters = true;
//Export the text form fields as editable
document.SaveOptions.HtmlExportTextInputFormFieldAsText = false;
//Set the style sheet type
document.SaveOptions.HtmlExportCssStyleSheetType = CssStyleSheetType.External;
//Set name for style sheet
document.SaveOptions.HtmlExportCssStyleSheetFileName = "UserDefinedFileName.css";
//Set the use absolute path as true
export.UseAbsolutePath = true;
//Save the document as html file
export.SaveAsXhtml(document, "WordtoHtml.html");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Loads an existing document
Dim document As New WordDocument("Template.docx")
Dim export As New HTMLExport()
'The images in the input document will be copied to this folder
document.SaveOptions.HtmlExportImagesFolder = "D:\Data\"
'The headers and footers in the input will be exported
document.SaveOptions.HtmlExportHeadersFooters = True
'Export the text form fields as editable
document.SaveOptions.HtmlExportTextInputFormFieldAsText = False
'Set the style sheet type
document.SaveOptions.HtmlExportCssStyleSheetType = CssStyleSheetType.External
'Set name for style sheet
document.SaveOptions.HtmlExportCssStyleSheetFileName = "UserDefinedFileName.css"
'Set the use absolute path as true
export.UseAbsolutePath = True;
'Save the document as html file
export.SaveAsXhtml(document, "WordtoHtml.html")
document.Close()
End Sub
//Loads an existing document
WordDocument document = new WordDocument("Template.docx");
HTMLExport export = new HTMLExport();
//Save the document as Xhtml file
export.SaveAsXhtml(document, "WordtoXHtml.html");
document.Close();
'Loads an existing document
Dim document As New WordDocument("Template.docx")
Dim export As New HTMLExport()
'Save the document as Xhtml file
export.SaveAsXhtml(document, "WordtoXHtml.html")
document.Close()
//Loads an existing document
WordDocument document = new WordDocument("Template.docx");
HTMLExport export = new HTMLExport();
//Save the document as Xhtml file
export.SaveAsXhtml(document, "WordtoXHtml.html", Encoding.Unicode);
document.Close();
'Loads an existing document
Dim document As New WordDocument("Template.docx")
Dim export As New HTMLExport()
'Save the document as Xhtml file
export.SaveAsXhtml(document, "WordtoXHtml.html", Encoding.Unicode)
document.Close()
//Creates a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Adds new text to the paragraph
paragraph.AppendText("Hello World!");
HTMLExport export = new HTMLExport();
MemoryStream stream = new MemoryStream();
//Save the document as Xhtml file
export.SaveAsXhtml(document, stream);
document.Close();
'Creates a new Word document
Dim document As New WordDocument()
'Adds new section to the document
Dim section As IWSection = document.AddSection()
'Adds new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Adds new text to the paragraph
paragraph.AppendText("Hello World!")
Dim export As New HTMLExport()
Dim stream As New MemoryStream()
'Save the document as Xhtml file
export.SaveAsXhtml(document, stream)
document.Close()
//Creates a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Adds new text to the paragraph
paragraph.AppendText("Hello World!");
HTMLExport export = new HTMLExport();
MemoryStream stream = new MemoryStream();
//Save the document as Xhtml file
export.SaveAsXhtml(document, stream, Encoding.Unicode);
document.Close();
'Creates a new Word document
Dim document As New WordDocument()
'Adds new section to the document
Dim section As IWSection = document.AddSection()
'Adds new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Adds new text to the paragraph
paragraph.AppendText("Hello World!")
Dim export As New HTMLExport()
Dim stream As New MemoryStream()
'Save the document as Xhtml file
export.SaveAsXhtml(document, stream, Encoding.Unicode)
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an instance of WordDocument class
WordDocument document = new WordDocument();
//Set the background type of the document
document.Background.Type = BackgroundType.Picture;
//Set the background image of the document
document.Background.Picture = Image.FromFile("Image.png");
//Add one section with one paragraph to the document
document.EnsureMinimal();
//Add the text range to the last paragraph of the section
document.LastParagraph.AppendText("Hello World!");
//Save the document in the given name and format
document.Save("Sample.docx", FormatType.Docx);
//Release the resources occupied by WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an instance of WordDocument class
Dim document As New WordDocument()
'Set the background type of the document
document.Background.Type = BackgroundType.Picture
'Set the background image of the document
document.Background.Picture = Image.FromFile("Image.png")
'Add one section with one paragraph to the document
document.EnsureMinimal()
'Add the text range to the last paragraph of the section
document.LastParagraph.AppendText("Hello World!")
'Save the document in the given name and format
document.Save("Sample.docx", FormatType.Docx)
'Release the resources occupied by WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into WordDocument instance
WordDocument document = new WordDocument("Sample.docx");
//Set the background type of the document
document.Background.Type = BackgroundType.Color;
//Set the background color of the document
document.Background.Color = Color.AliceBlue;
//Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx);
//Release the resources occupied by WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into WordDocument instance
Dim document As New WordDocument("Sample.docx")
'Set the background type of the document
document.Background.Type = BackgroundType.Color
'Set the background color of the document
document.Background.Color = Color.AliceBlue
'Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx)
'Release the resources occupied by WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an instance of WordDocument class
WordDocument document = new WordDocument();
//Set the background type of the document
document.Background.Type = BackgroundType.Gradient;
//Set the first color of the background gradient of the document
document.Background.Gradient.Color1 = Color.AliceBlue;
//Set the second color of the background gradient of the document
document.Background.Gradient.Color2 = Color.Purple;
//Set the first shading style of the background gradient of the document
document.Background.Gradient.ShadingStyle = GradientShadingStyle.DiagonalDown;
//Set the first shading variant of the background gradient of the document
document.Background.Gradient.ShadingVariant = GradientShadingVariant.ShadingMiddle;
//Add one section with one paragraph to the document
document.EnsureMinimal();
//Add the text range to the last paragraph of the section
document.LastParagraph.AppendText("Hello World!");
//Save the document in the given name and format
document.Save("Sample.docx", FormatType.Docx);
//Release the resources occupied by WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an instance of WordDocument class
Dim document As New WordDocument()
'Set the background type of the document
document.Background.Type = BackgroundType.Gradient
'Set the first color of the background gradient of the document
document.Background.Gradient.Color1 = Color.AliceBlue
'Set the second color of the background gradient of the document
document.Background.Gradient.Color2 = Color.Purple
'Set the first shading style of the background gradient of the document
document.Background.Gradient.ShadingStyle = GradientShadingStyle.DiagonalDown
'Set the first shading variant of the background gradient of the document
document.Background.Gradient.ShadingVariant = GradientShadingVariant.ShadingMiddle
'Add one section with one paragraph to the document
document.EnsureMinimal()
'Add the text range to the last paragraph of the section
document.LastParagraph.AppendText("Hello World!")
'Save the document in the given name and format
document.Save("Sample.docx", FormatType.Docx)
'Release the resources occupied by WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Set the value for Company property of the document
document.BuiltinDocumentProperties.Company = "Northwind Traders";
//Set the value for Manager property of the document
document.BuiltinDocumentProperties.Manager = "Paul Anderson";
//Set the value for Author property of the document
document.BuiltinDocumentProperties.Author = "Peter";
//Set the value for Comments property of the document
document.BuiltinDocumentProperties.Comments = "This document provide the sales information of the year 2015";
//Set the value for LastAuthor property of the document
document.BuiltinDocumentProperties.LastAuthor = "Johnson";
//Set the value for Title property of the document
document.BuiltinDocumentProperties.Title = "Sales Information";
//Set the value for Category property of the document
document.BuiltinDocumentProperties.Category = "Sales";
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Set the value for Company property of the document
document.BuiltinDocumentProperties.Company = "Northwind Traders"
'Set the value for Manager property of the document
document.BuiltinDocumentProperties.Manager = "Paul Anderson"
'Set the value for Author property of the document
document.BuiltinDocumentProperties.Author = "Peter"
'Set the value for Comments property of the document
document.BuiltinDocumentProperties.Comments = "This document provide the sales information of the year 2015"
'Set the value for LastAuthor property of the document
document.BuiltinDocumentProperties.LastAuthor = "Johnson"
'Set the value for Title property of the document
document.BuiltinDocumentProperties.Title = "Sales Information"
'Set the value for Category property of the document
document.BuiltinDocumentProperties.Category = "Sales"
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
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
WSection section = document.AddSection() as WSection;
//Add the column into the section
Column column1 = new Column(document);
column1.Width = 150;
column1.Space = 20;
section.Columns.Add(column1);
//Add the column into the section
Column column2 = new Column(document);
column2.Width = 150;
column2.Space = 20;
section.Columns.Add(column2);
//Add the column into the section
Column column3 = new Column(document);
column3.Width = 150;
column3.Space = 20;
section.Columns.Add(column3);
//Add a paragraph to created section
IWParagraph paragraph = section.AddParagraph();
//Add a paragraph to created section
paragraph = section.AddParagraph();
string paraText = "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();
}
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 WSection = TryCast(document.AddSection(), WSection)
'Add the column into the section
Dim column1 As New Column(document)
column1.Width = 150
column1.Space = 20
section.Columns.Add(column1)
'Add the column into the section
Dim column2 As New Column(document)
column2.Width = 150
column2.Space = 20
section.Columns.Add(column2)
'Add the column into the section
Dim column3 As New Column(document)
column3.Width = 150
column3.Space = 20
section.Columns.Add(column3)
'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
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Add the new custom property Typist with value
document.CustomDocumentProperties.Add("Typist", "Andrew");
//Add the new custom property Publisher with value
document.CustomDocumentProperties.Add("Publisher", "Stephen");
//Add the new custom property Recorded by with value
document.CustomDocumentProperties.Add("Recorded by", "Harry");
//Add the new custom property Recorded date with value
document.CustomDocumentProperties.Add("Recorded date", new DateTime(2015, 2, 23));
//Save and close the Word document
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Add the new custom property Typist with value
document.CustomDocumentProperties.Add("Typist", "Andrew")
'Add the new custom property Publisher with value
document.CustomDocumentProperties.Add("Publisher", "Stephen")
'Add the new custom property Recorded by with value
document.CustomDocumentProperties.Add("Recorded by", "Harry")
'Add the new custom property Recorded date with value
document.CustomDocumentProperties.Add("Recorded date", New DateTime(2015, 2, 23))
'Save and close the Word document
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("Web Hyperlink: ");
paragraph = section.AddParagraph();
//Append web hyperlink to the paragraph
IWField field = paragraph.AppendHyperlink("http://www.syncfusion.com", "Syncfusion", HyperlinkType.WebLink);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("Web Hyperlink: ")
paragraph = section.AddParagraph()
'Append web hyperlink to the paragraph
Dim field As IWField = paragraph.AppendHyperlink("http://www.syncfusion.com", "Syncfusion", HyperlinkType.WebLink)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("Email hyperlink: ");
paragraph = section.AddParagraph();
//Append Email hyperlink to the paragraph
paragraph.AppendHyperlink("mailto:john@gmail.com","John" , HyperlinkType.EMailLink);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("Email hyperlink: ")
paragraph = section.AddParagraph()
'Append Email hyperlink to the paragraph
paragraph.AppendHyperlink("mailto:john@gmail.com", "John", HyperlinkType.EMailLink)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("File Hyperlinks: ");
paragraph = section.AddParagraph();
//Append hyperlink field to the paragraph
paragraph.AppendHyperlink(@"D:\Template.docx","File", HyperlinkType.FileLink);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("File Hyperlinks: ")
paragraph = section.AddParagraph()
'Append hyperlink field to the paragraph
paragraph.AppendHyperlink("D:\Template.docx", "File", HyperlinkType.FileLink)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Create new Bookmark
paragraph.AppendBookmarkStart("Introduction");
paragraph.AppendText("Hyperlink");
paragraph.AppendBookmarkEnd("Introduction");
paragraph.AppendText("\nA hyperlink is a reference or navigation element in a document to another section of the same document or to another document that may be on or part of a (different) domain.");
paragraph = section.AddParagraph();
paragraph.AppendText("Bookmark Hyperlink: ");
paragraph = section.AddParagraph();
//Append Bookmark hyperlink to the paragraph
paragraph.AppendHyperlink("Introduction", "Bookmark", HyperlinkType.Bookmark);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Create new Bookmark
paragraph.AppendBookmarkStart("Introduction")
paragraph.AppendText("Hyperlink")
paragraph.AppendBookmarkEnd("Introduction")
paragraph.AppendText(vbLf & "A hyperlink is a reference or navigation element in a document to another section of the same document or to another document that may be on or part of a (different) domain.")
paragraph = section.AddParagraph()
paragraph.AppendText("Bookmark Hyperlink: ")
paragraph = section.AddParagraph()
'Append Bookmark hyperlink to the paragraph
paragraph.AppendHyperlink("Introduction", "Bookmark", HyperlinkType.Bookmark)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("Image Hyperlink");
paragraph = section.AddParagraph();
//Create a new image instance and load image
WPicture picture = new WPicture(document);
picture.LoadImage(Image.FromFile("Image.png"));
//Append new image hyperlink to the paragraph
paragraph.AppendHyperlink("http://www.syncfusion.com", picture, HyperlinkType.WebLink);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("Image Hyperlink")
paragraph = section.AddParagraph()
'Create a new image instance and load image
Dim picture As New WPicture(document)
picture.LoadImage(Image.FromFile("Image.png"))
'Append new image hyperlink to the paragraph
paragraph.AppendHyperlink("http://www.syncfusion.com", picture, HyperlinkType.WebLink)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add a section and a paragraph in the document
document.EnsureMinimal();
IWParagraph paragraph = document.LastParagraph;
paragraph.AppendText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua");
//Create a new picture watermark
PictureWatermark picWatermark = new PictureWatermark();
//Set the scaling to picture
picWatermark.Scaling = 120f;
picWatermark.Washout = true;
//Set the picture watermark to document
document.Watermark = picWatermark;
//Set the image to the picture watermark
picWatermark.Picture = Image.FromFile("ImagesPath" + "Water lilies.jpg");
document.Save("PictureWatermark.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 a section and a paragraph in the document
document.EnsureMinimal()
Dim paragraph As IWParagraph = document.LastParagraph
paragraph.AppendText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua")
'Create a new picture watermark
Dim picWatermark As New PictureWatermark()
'Set the scaling to picture
picWatermark.Scaling = 120.0F
picWatermark.Washout = True
Set the picture watermark to document
document.Watermark = picWatermark
Set the image to the picture watermark
picWatermark.Picture = Image.FromFile(ImagesPath + "Water lilies.jpg")
document.Save("PictureWatermark.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Create a new picture watermark
PictureWatermark picWatermark = new PictureWatermark(Image.FromFile("ImagesPath" + "Water lilies.jpg"), false);
//Set the picture watermark to document
document.Watermark = picWatermark;
document.Save("PictureWatermark.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Create a new picture watermark
Dim picWatermark As New PictureWatermark(Image.FromFile(ImagesPath + "Water lilies.jpg"), False)
'Set the picture watermark to document
document.Watermark = picWatermark
document.Save("PictureWatermark.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument("Template.docx");
//Add the section into Word document
WSection section = document.AddSection() as WSection;
//Access the first paragraph of the document
WParagraph paragraph = document.Sections[0].Paragraphs[0];
//Get the first tab from the paragraph
Tab tab = paragraph.ParagraphFormat.Tabs[0];
//Adjust the tab values
tab.Justification = TabJustification.Centered;
tab.Position = 200;
tab.TabLeader = Syncfusion.DocIO.DLS.TabLeader.Dotted;
//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("Template.docx")
'Add the section into Word document
Dim section As WSection = TryCast(document.AddSection(), WSection)
'Access the first paragraph of the document
Dim paragraph As WParagraph = document.Sections(0).Paragraphs(0)
'Get the first tab from the paragraph
Dim tab As Tab = paragraph.ParagraphFormat.Tabs(0)
'Adjust the tab values
tab.Justification = TabJustification.Centered
tab.Position = 200
tab.TabLeader = Syncfusion.DocIO.DLS.TabLeader.Dotted
'Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add a section and a paragraph in the document
document.EnsureMinimal();
IWParagraph paragraph = document.LastParagraph;
paragraph.AppendText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua");
//Create a new text watermark
TextWatermark textWatermark = new TextWatermark();
//Set the created watermark to document
document.Watermark = textWatermark;
//Set the text watermark font size
textWatermark.Size = 72;
//Set the text watermark layout to Horizontal
textWatermark.Layout = WatermarkLayout.Horizontal;
textWatermark.Semitransparent = false;
//Set the text watermark text color
textWatermark.Color = Color.Black;
//Set the text to text watermark text
textWatermark.Text = "TextWatermark";
document.Save("TextWatermark.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 a section and a paragraph in the document
document.EnsureMinimal()
Dim paragraph As IWParagraph = document.LastParagraph
paragraph.AppendText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua")
'Create a new text watermark
Dim textWatermark As New TextWatermark()
'Set the text watermark to document
document.Watermark = textWatermark
'Set the text watermark font size
textWatermark.Size = 72
'Set the text watermark layout to Horizontal
textWatermark.Layout = WatermarkLayout.Horizontal
textWatermark.Semitransparent = False
'Set the text watermark text color
textWatermark.Color = Color.Black
'Set the text to the text watermark
textWatermark.Text = "TextWatermark"
document.Save("TextWatermark.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template,docx");
//Create a new text watermark
TextWatermark textWatermark = new TextWatermark("Demo Text");
//Set the created watermark to document
document.Watermark = textWatermark;
document.Save("TextWatermark.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template,docx")
'Create a new text watermark
Dim textWatermark As New TextWatermark("Demo Text")
'Set the created watermark to document
document.Watermark = textWatermark
document.Save("TextWatermark.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template,docx");
//Create a new text watermark
TextWatermark textWatermark = new TextWatermark("Demo Text", "Arial", 48, WatermarkLayout.Diagonal);
//Set the created watermark to document
document.Watermark = textWatermark;
document.Save("TextWatermark.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template,docx")
'Create a new text watermark
Dim textWatermark As New TextWatermark("Demo Text", "Arial", 48, WatermarkLayout.Diagonal)
'Set the created watermark to document
document.Watermark = textWatermark
document.Save("TextWatermark.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("First Name of the customer: ");
//Add the DocVariable field with Variable name and its type
paragraph.AppendField("FirstName", FieldType.FieldDocVariable);
paragraph = section.AddParagraph();
paragraph.AppendText("Last Name of the customer: ");
//Add the DocVariable field with Variable name and its type
paragraph.AppendField("LastName", FieldType.FieldDocVariable);
//Add the value for variable in WordDocument.Variable collection
document.Variables.Add("FirstName", "Jeff");
document.Variables.Add("LastName", "Smith");
//Update the document fields
document.UpdateDocumentFields();
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument()
Dim section As IWSection = document.AddSection()
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("First Name of the customer: ")
'Add the DocVariable field with Variable name and its type
paragraph.AppendField("FirstName", FieldType.FieldDocVariable)
paragraph = section.AddParagraph()
paragraph.AppendText("Last Name of the customer: ")
'Add the DocVariable field with Variable name and its type
paragraph.AppendField("LastName", FieldType.FieldDocVariable)
'Add the value for variable in WordDocument.Variable collection
document.Variables.Add("FirstName", "Jeff")
document.Variables.Add("LastName", "Smith")
'Update the document fields
document.UpdateDocumentFields()
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Creates a new document.
WordDocument document = new WordDocument();
//Adds the first section to the document.
IWSection section = document.AddSection();
//Adds a paragraph to the section.
IWParagraph paragraph = section.AddParagraph();
//Sets DifferentFirstPage and DifferentOddEvenPages to true for inserting Header and Footer text.
section.PageSetup.DifferentFirstPage = true;
section.PageSetup.DifferentOddAndEvenPages = true;
//Appends some text to the first page in document.
paragraph.AppendText("\r\r[ First Page ] \r\rText Body_Text Body_Text Body_Text Body_Text Body_Text Body");
paragraph.ParagraphFormat.PageBreakAfter = true;
//Appends some text to the second page in document.
paragraph = section.AddParagraph();
paragraph.AppendText("\r\r[ Second Page ] \r\rText Body_Text Body_Text Body_Text Body_Text Body_Text Body");
paragraph.ParagraphFormat.PageBreakAfter = true;
//Appends some text to the third page in document.
paragraph = section.AddParagraph();
paragraph.AppendText("\r\r[ Third Page ] \r\rText Body_Text Body_Text Body_Text Body_Text Body_Text Body");
//Inserts First Page Header.
paragraph = new WParagraph(document);
paragraph.AppendText("[ FIRST PAGE Header ]");
section.HeadersFooters.FirstPageHeader.Paragraphs.Add(paragraph);
//Inserts First Page Footer.
paragraph = new WParagraph(document);
paragraph.AppendText("[ FIRST PAGE Footer ]");
section.HeadersFooters.FirstPageFooter.Paragraphs.Add(paragraph);
//Inserts Odd Pages Header.
paragraph = new WParagraph(document);
paragraph.AppendText("[ ODD Page Header Text goes here ]");
section.HeadersFooters.OddHeader.Paragraphs.Add(paragraph);
//Inserts Odd Pages Footer.
paragraph = new WParagraph(document);
paragraph.AppendText("[ ODD Page Footer Text goes here ]");
section.HeadersFooters.OddFooter.Paragraphs.Add(paragraph);
//Inserts Even Pages Header.
paragraph = new WParagraph(document);
paragraph.AppendText("[ EVEN Page Header Text goes here ]");
section.HeadersFooters.EvenHeader.Paragraphs.Add(paragraph);
//Inserts Even Pages Footer.
paragraph = new WParagraph(document);
paragraph.AppendText("[ EVEN Page Footer Text goes here ]");
section.HeadersFooters.EvenFooter.Paragraphs.Add(paragraph);
//Adds the second section to the document.
section = document.AddSection();
section.PageSetup.DifferentFirstPage = true;
//Appends some text to the Second Sections's first page in the document.
paragraph = section.AddParagraph();
paragraph.AppendText("\r\r[ First Page for SECOND SECTION ]\r[ ON DIFFERENT FIRTS PAGE ]\r\rText Body_Text Body_Text Body_Text Body_Text Body_Text Body");
paragraph.ParagraphFormat.PageBreakAfter = true;
//Appends some text to the Second Sections's second page in the document.
paragraph = section.AddParagraph();
paragraph.AppendText("\r\r[ Second Page for SECOND SECTION ]\rText Body_Text Body_Text Body_Text Body_Text Body_Text Body");
//Inserts Second Sections's First Header.
paragraph = new WParagraph(document);
paragraph.AppendText("[ SECOND SECTION FIRST PAGE Header ]");
section.HeadersFooters.FirstPageHeader.Paragraphs.Add(paragraph);
//Inserts Second Sections's First Footer.
paragraph = new WParagraph(document);
paragraph.AppendText("[ SECOND SECTION FIRST PAGE Footer ]");
section.HeadersFooters.FirstPageFooter.Paragraphs.Add(paragraph);
//Inserts Second Sections's Header.
paragraph = new WParagraph(document);
paragraph.AppendText("SECOND SECTION Header Text goes here");
section.HeadersFooters.OddHeader.Paragraphs.Add(paragraph);
//Inserts Second Sections's Footer.
paragraph = new WParagraph(document);
paragraph.AppendText("SECOND SECTION Footer Text goes here");
section.HeadersFooters.OddFooter.Paragraphs.Add(paragraph);
//Saves the document to disk.
document.Save("Sample.docx", FormatType.Docx);
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Creates a new document.
Dim document As WordDocument = New WordDocument()
'Adds the first section to the document.
Dim section As IWSection = document.AddSection()
'Adds a paragraph to the section.
Dim paragraph As IWParagraph = section.AddParagraph()
'Sets DifferentFirstPage and DifferentOddEvenPages as true for inserting Header and Footer text.
section.PageSetup.DifferentFirstPage = True
section.PageSetup.DifferentOddAndEvenPages = True
'Appends some text to the first page in document.
paragraph.AppendText(Constants.VB.NETCr + Constants.VB.NETCr and "[ First Page ] " and Constants.VB.NETCr + Constants.VB.NETCr and "Text Body_Text Body_Text Body_Text Body_Text Body_Text Body")
paragraph.ParagraphFormat.PageBreakAfter = True
'Appends some text to the second page in document.
paragraph = section.AddParagraph()
paragraph.AppendText(Constants.VB.NETCr + Constants.VB.NETCr and "[ Second Page ] " and Constants.VB.NETCr + Constants.VB.NETCr and "Text Body_Text Body_Text Body_Text Body_Text Body_Text Body")
paragraph.ParagraphFormat.PageBreakAfter = True
'Appends some text to the third page in document.
paragraph = section.AddParagraph()
paragraph.AppendText(Constants.VB.NETCr + Constants.VB.NETCr and "[ Third Page ] " and Constants.VB.NETCr + Constants.VB.NETCr and "Text Body_Text Body_Text Body_Text Body_Text Body_Text Body")
'Inserts First Page Header.
paragraph = New WParagraph(document)
paragraph.AppendText("[ FIRST PAGE Header ]")
section.HeadersFooters.FirstPageHeader.Paragraphs.Add(paragraph)
'Inserts First Page Footer.
paragraph = New WParagraph(document)
paragraph.AppendText("[ FIRST PAGE Footer ]")
section.HeadersFooters.FirstPageFooter.Paragraphs.Add(paragraph)
'Inserts Odd Pages Header.
paragraph = New WParagraph(document)
paragraph.AppendText("[ ODD Page Header Text goes here ]")
section.HeadersFooters.OddHeader.Paragraphs.Add(paragraph)
'Inserts Odd Pages Footer.
paragraph = New WParagraph(document)
paragraph.AppendText("[ ODD Page Footer Text goes here ]")
section.HeadersFooters.OddFooter.Paragraphs.Add(paragraph)
'Inserts Even Pages Header.
paragraph = New WParagraph(document)
paragraph.AppendText("[ EVEN Page Header Text goes here ]")
section.HeadersFooters.EvenHeader.Paragraphs.Add(paragraph)
'Inserts Even Pages Footer.
paragraph = New WParagraph(document)
paragraph.AppendText("[ EVEN Page Footer Text goes here ]")
section.HeadersFooters.EvenFooter.Paragraphs.Add(paragraph)
'Adds the second section to the document.
section = document.AddSection()
section.PageSetup.DifferentFirstPage = True
'Appends some text to the Second Sections's first page in the document.
paragraph = section.AddParagraph()
paragraph.AppendText(Constants.VB.NETCr + Constants.VB.NETCr and "[ First Page for SECOND SECTION ]" and Constants.VB.NETCr and "[ ON DIFFERENT FIRTS PAGE ]" and Constants.VB.NETCr + Constants.VB.NETCr and "Text Body_Text Body_Text Body_Text Body_Text Body_Text Body")
paragraph.ParagraphFormat.PageBreakAfter = True
'Appends some text to the Second Sections's second page in the document.
paragraph = section.AddParagraph()
paragraph.AppendText(Constants.VB.NETCr + Constants.VB.NETCr and "[ Second Page for SECOND SECTION ]" and Constants.VB.NETCr and "Text Body_Text Body_Text Body_Text Body_Text Body_Text Body")
'Inserts Second Sections's First Header.
paragraph = New WParagraph(document)
paragraph.AppendText("[ SECOND SECTION FIRST PAGE Header ]")
section.HeadersFooters.FirstPageHeader.Paragraphs.Add(paragraph)
'Inserts Second Sections's First Footer.
paragraph = New WParagraph(document)
paragraph.AppendText("[ SECOND SECTION FIRST PAGE Footer ]")
section.HeadersFooters.FirstPageFooter.Paragraphs.Add(paragraph)
'Inserts Second Sections's Header.
paragraph = New WParagraph(document)
paragraph.AppendText("SECOND SECTION Header Text goes here")
section.HeadersFooters.OddHeader.Paragraphs.Add(paragraph)
'Inserts Second Sections's Footer.
paragraph = New WParagraph(document)
paragraph.AppendText("SECOND SECTION Footer Text goes here")
section.HeadersFooters.OddFooter.Paragraphs.Add(paragraph)
'Saves the document to disk.
document.Save("Sample.docx", FormatType.Docx)
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new document
WordDocument document = new WordDocument();
//Add the first section to the document
IWSection section = document.AddSection();
//Insert the first section header
section.HeadersFooters.Header.AddParagraph().AppendText("[ First Section Header ]");
//Insert the first section footer
section.HeadersFooters.Footer.AddParagraph().AppendText("[ First Section Footer ]");
//Add a paragraph to the section
IWParagraph paragraph = section.AddParagraph();
string paraText = "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 some text to the first page in document
paragraph.AppendText("\r\r[ First Page ] \r\r" + paraText);
//Add the second section to the document
section = document.AddSection();
//Insert the second section header
section.HeadersFooters.Header.AddParagraph().AppendText("[ Second Section Header ]");
//Insert the second section footer.
section.HeadersFooters.Footer.AddParagraph().AppendText("[ Second Section Footer ]");
//Set LinkToPrevious as true for retrieve the header and footer from previous section
section.HeadersFooters.LinkToPrevious = true;
//Append some text to the second page in document
paragraph = section.AddParagraph();
paragraph.AppendText("\r\r[ Second Page ] \r\r" + paraText);
//Add the third section to the document
section = document.AddSection();
//Insert the third section header
section.HeadersFooters.Header.AddParagraph().AppendText("[ Third Section Header ]");
//Insert the third section footer
section.HeadersFooters.Footer.AddParagraph().AppendText("[ Third Section Footer ]");
//Append some text to the third page in document
paragraph = section.AddParagraph();
paragraph.AppendText("\r\r[ Third Page ] \r\r" + paraText);
//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 document
Dim document As New WordDocument()
'Add the first section to the document
Dim section As IWSection = document.AddSection()
'Insert the first section header
section.HeadersFooters.Header.AddParagraph().AppendText("[ First Section Header ]")
'Insert the first section footer
section.HeadersFooters.Footer.AddParagraph().AppendText("[ First Section Footer ]")
'Add a paragraph to the section
Dim paragraph As IWParagraph = 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 some text to the first page in document
paragraph.AppendText(Convert.ToString(vbCr & vbCr & "[ First Page ] " & vbCr & vbCr) & paraText)
'Add the second section to the document
section = document.AddSection()
'Insert the second section header
section.HeadersFooters.Header.AddParagraph().AppendText("[ Second Section Header ]")
'Insert the second section footer
section.HeadersFooters.Footer.AddParagraph().AppendText("[ Second Section Footer ]")
'Set LinkToPrevious as true for retrieve the header and footer from previous section
section.HeadersFooters.LinkToPrevious = True
'Append some text to the second page in document
paragraph = section.AddParagraph()
paragraph.AppendText(Convert.ToString(vbCr & vbCr & "[ Second Page ] " & vbCr & vbCr) & paraText)
'Add the third section to the document
section = document.AddSection()
'Insert the third section header
section.HeadersFooters.Header.AddParagraph().AppendText("[ Third Section Header ]")
'Insert the third section footer
section.HeadersFooters.Footer.AddParagraph().AppendText("[ Third Section Footer ]")
'Append some text to the third page in document
paragraph = section.AddParagraph()
paragraph.AppendText(Convert.ToString(vbCr & vbCr & "[ Third Page ] " & vbCr & vbCr) & paraText)
�Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create new Word document
WordDocument document = new WordDocument();
//Add new section
IWSection section = document.AddSection();
WTextBody textbody = section.Body;
//Add a paragraph to the text body
WParagraph paragraph = textbody.AddParagraph() as WParagraph;
//Add text
paragraph.AppendText("A new paragraph is added");
//Save and close the document
document.Save("Sample.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create new Word document
Dim document As New WordDocument()
'Add new section
Dim section As IWSection = document.AddSection()
Dim textbody As WTextBody = section.Body
'Add a paragraph to the text body
Dim paragraph As WParagraph = TryCast(textbody.AddParagraph(), WParagraph)
'Add text
paragraph.AppendText("A new paragraph is added")
'Save and close the document
document.Save("Sample.docx")
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create new Word document
WordDocument document = new WordDocument();
//Add new section
IWSection section = document.AddSection();
WTextBody textbody = section.Body;
//Add a table to the text body
IWTable table = textbody.AddTable();
table.ResetCells(2, 2);
//Save and close the document
document.Save("Sample.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create new Word document
Dim document As New WordDocument()
'Add new section
Dim section As IWSection = document.AddSection()
Dim textbody As WTextBody = section.Body
'Add a table to the text body
Dim table As IWTable = textbody.AddTable()
table.ResetCells(2, 2)
'Save and close the document
document.Save("Sample.docx")
document.Close()
End Sub
//Create new Word document
WordDocument document = new WordDocument();
//Add new section
IWSection section = document.AddSection();
WTextBody textbody = section.Body;
//Add a block content control to the text body
BlockContentControl blockControl = textbody.AddBlockContentControl(ContentControlType.RichText) as BlockContentControl;
//Add text to the control added
blockControl.TextBody.AddParagraph().AppendText("A new block control is added");
//Save and close the document
document.Save("Sample.docx");
document.Close();
'Create new Word document
Dim document As New WordDocument()
'Add new section
Dim section As IWSection = document.AddSection()
Dim textbody As WTextBody = section.Body
'Add a block content control to the text body
Dim blockControl As BlockContentControl = TryCast(textbody.AddBlockContentControl(ContentControlType.RichText), BlockContentControl)
'Add text to the control added
blockControl.TextBody.AddParagraph().AppendText("A new block control is added")
'Save and close the document
document.Save("Sample.docx")
document.Close()
//Load the template document
WordDocument document = new WordDocument("Template.docx");
//Html string to be inserted
string htmlstring = "This text is inserted as HTML string.
";
//Append Html string as first item of the second paragraph in the document
document.Sections[0].Body.InsertXHTML(htmlstring);
//Save and close the document
document.Save("Sample.docx");
document.Close();
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document
Dim document As New WordDocument("Template.docx")
'Html string to be inserted
Dim htmlstring As String = "This text is inserted as HTML string.
"
'Append Html string as first item of the second paragraph in the document
document.Sections(0).Body.InsertXHTML(htmlstring)
'Save and close the document
document.Save("Sample.docx")
document.Close()
End Sub
//Load the template document
WordDocument document = new WordDocument("Template.docx");
//Html string to be inserted
string htmlstring = "This text is inserted as HTML string.
";
//Append Html string as first item of the second paragraph in the document
document.Sections[0].Body.InsertXHTML(htmlstring, 2);
//Save and close the document
document.Save("Sample.docx");
document.Close();
'Load the template document
Dim document As New WordDocument("Template.docx")
'Html string to be inserted
Dim htmlstring As String = "This text is inserted as HTML string.
"
'Append Html string as first item of the second paragraph in the document
document.Sections(0).Body.InsertXHTML(htmlstring, 2)
'Save and close the document
document.Save("Sample.docx")
document.Close()
//Load the template document
WordDocument document = new WordDocument("Template.docx");
//Html string to be inserted
string htmlstring = "This text is inserted as HTML string.
";
//Validating the Html string
bool isValidHtml = document.LastSection.Body.IsValidXHTML(htmlstring, XHTMLValidationType.Transitional);
//If the Html string passes validation, it is inserted to document
if (isValidHtml)
{
//Append Html string as first item of the second paragraph in the document
document.Sections[0].Body.InsertXHTML(htmlstring, 2, 0);
}
//Save and close the document
document.Save("Sample.docx");
document.Close();
'Load the template document
Dim document As New WordDocument("Template.docx")
'Html string to be inserted
Dim htmlstring As String = "This text is inserted as HTML string.
"
'Validating the Html string
Dim isValidHtmlAs Boolean = document.LastSection.Body.IsValidXHTML(htmlstring, XHTMLValidationType.Transitional)
'If the Html string passes validation, it is inserted to document
If isValidHtmlThen
'Append Html string as first item of the second paragraph in the document
document.Sections(0).Body.InsertXHTML(htmlstring, 2, 0)
End If
'Save and close the document
document.Save("Sample.docx")
document.Close()
//Load the template document
WordDocument document = new WordDocument("Template.docx");
//Html string to be inserted
string htmlstring = "This text is inserted as HTML string.
";
string exception = "The string is not valid";
//Validating the Html string
bool isValidHtml = document.LastSection.Body.IsValidXHTML(htmlstring, XHTMLValidationType.Transitional, out exception);
//If the Html string passes validation, it is inserted to document
if (isValidHtml)
{
//Append Html string as first item of the second paragraph in the document
document.Sections[0].Body.InsertXHTML(htmlstring, 2, 0);
}
//Save and close the document
document.Save("Sample.docx");
document.Close();
'Load the template document
Dim document As New WordDocument("Template.docx")
'Html string to be inserted
Dim htmlstring As String = "This text is inserted as HTML string.
"
Dim exception As String = "The string is not valid"
'Validating the Html string
Dim isValidHtmlAs Boolean = document.LastSection.Body.IsValidXHTML(htmlstring, XHTMLValidationType.Transitional, exception)
'If the Html string passes validation, it is inserted to document
If isValidHtmlThen
'Append Html string as first item of the second paragraph in the document
document.Sections(0).Body.InsertXHTML(htmlstring, 2, 0)
End If
'Save and close the document
document.Save("Sample.docx")
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create new Word document
WordDocument document = new WordDocument();
//Add new section
IWSection section = document.AddSection();
WTextBody textbody = section.Body;
//Add one paragraph to the section body
textbody.EnsureMinimum();
textbody.LastParagraph.AppendText("Last paragraph");
//Save and close the document
document.Save("Sample.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create new Word document
Dim document As New WordDocument()
'Add new section
Dim section As IWSection = document.AddSection()
Dim textbody As WTextBody = section.Body
'Add one paragraph to the section body
textbody.EnsureMinimum()
textbody.LastParagraph.AppendText("Last paragraph")
'Save and close the document
document.Save("Sample.docx")
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template Word document
WordDocument document = new WordDocument("Template.docx");
//Get the textbody of first section
WTextBody textbody = document.Sections[0].Body;
//Get the last paragraph
IWParagraph paragraph = textbody.LastParagraph;
//Set horizontal alignment
paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Right;
//Save and close the document
document.Save("Sample.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template Word document
Dim document As New WordDocument("Template.docx")
'Get the textbody of first section
Dim textbody As WTextBody = document.Sections(0).Body
'Get the last paragraph
Dim paragraph As IWParagraph = textbody.LastParagraph
'Set horizontal alignment
paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Right
'Save and close the document
document.Save("Sample.docx")
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create new Word document
WordDocument document = new WordDocument();
//Add new section
IWSection section = document.AddSection();
WTextBody textbody = section.Body;
//Add a paragraph to the text body
WParagraph paragraph = textbody.AddParagraph() as WParagraph;
//Add text
paragraph.AppendText("A new paragraph is added");
//Save and close the document
document.Save("Sample.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create new Word document
Dim document As New WordDocument()
'Add new section
Dim section As IWSection = document.AddSection()
Dim textbody As WTextBody = section.Body
'Add a paragraph to the text body
Dim paragraph As WParagraph = TryCast(textbody.AddParagraph(), WParagraph)
'Add text
paragraph.AppendText("A new paragraph is added")
'Save and close the document
document.Save("Sample.docx")
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create new Word document
WordDocument document = new WordDocument();
//Add new section
IWSection section = document.AddSection();
WTextBody textbody = section.Body;
//Add a table to the text body
IWTable table = textbody.AddTable();
table.ResetCells(2, 2);
//Save and close the document
document.Save("Sample.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create new Word document
Dim document As New WordDocument()
'Add new section
Dim section As IWSection = document.AddSection()
Dim textbody As WTextBody = section.Body
'Add a table to the text body
Dim table As IWTable = textbody.AddTable()
table.ResetCells(2, 2)
'Save and close the document
document.Save("Sample.docx")
document.Close()
End Sub
//Create new Word document
WordDocument document = new WordDocument();
//Add new section
IWSection section = document.AddSection();
WTextBody textbody = section.Body;
//Add a block content control to the text body
BlockContentControl blockControl = textbody.AddBlockContentControl(ContentControlType.RichText) as BlockContentControl;
//Add text to the control added
blockControl.TextBody.AddParagraph().AppendText("A new block control is added");
//Save and close the document
document.Save("Sample.docx");
document.Close();
'Create new Word document
Dim document As New WordDocument()
'Add new section
Dim section As IWSection = document.AddSection()
Dim textbody As WTextBody = section.Body
'Add a block content control to the text body
Dim blockControl As BlockContentControl = TryCast(textbody.AddBlockContentControl(ContentControlType.RichText), BlockContentControl)
'Add text to the control added
blockControl.TextBody.AddParagraph().AppendText("A new block control is added")
'Save and close the document
document.Save("Sample.docx")
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the template document
WordDocument document = new WordDocument("Template.docx");
//Html string to be inserted
string htmlstring = "This text is inserted as HTML string.
";
//Append Html string as first item of the second paragraph in the document
document.Sections[0].Body.InsertXHTML(htmlstring);
//Save and close the document
document.Save("Sample.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document
Dim document As New WordDocument("Template.docx")
'Html string to be inserted
Dim htmlstring As String = "This text is inserted as HTML string.
"
'Append Html string as first item of the second paragraph in the document
document.Sections(0).Body.InsertXHTML(htmlstring)
'Save and close the document
document.Save("Sample.docx")
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the template document
WordDocument document = new WordDocument("Template.docx");
//Html string to be inserted
string htmlstring = "This text is inserted as HTML string.
";
//Append Html string as first item of the second paragraph in the document
document.Sections[0].Body.InsertXHTML(htmlstring, 2);
//Save and close the document
document.Save("Sample.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document
Dim document As New WordDocument("Template.docx")
'Html string to be inserted
Dim htmlstring As String = "This text is inserted as HTML string.
"
'Append Html string as first item of the second paragraph in the document
document.Sections(0).Body.InsertXHTML(htmlstring, 2)
'Save and close the document
document.Save("Sample.docx")
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the template document
WordDocument document = new WordDocument("Template.docx");
//Html string to be inserted
string htmlstring = "This text is inserted as HTML string.
";
//Validating the Html string
bool isValidHtml = document.LastSection.Body.IsValidXHTML(htmlstring, XHTMLValidationType.Transitional);
//If the Html string passes validation, it is inserted to document
if (isValidHtml)
{
//Append Html string as first item of the second paragraph in the document
document.Sections[0].Body.InsertXHTML(htmlstring, 2, 0);
}
//Save and close the document
document.Save("Sample.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document
Dim document As New WordDocument("Template.docx")
'Html string to be inserted
Dim htmlstring As String = "This text is inserted as HTML string.
"
'Validating the Html string
Dim isValidHtmlAs Boolean = document.LastSection.Body.IsValidXHTML(htmlstring, XHTMLValidationType.Transitional)
'If the Html string passes validation, it is inserted to document
If isValidHtmlThen
'Append Html string as first item of the second paragraph in the document
document.Sections(0).Body.InsertXHTML(htmlstring, 2, 0)
End If
'Save and close the document
document.Save("Sample.docx")
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the template document
WordDocument document = new WordDocument("Template.docx");
//Html string to be inserted
string htmlstring = "This text is inserted as HTML string.
";
string exception = "The string is not valid";
//Validating the Html string
bool isValidHtml = document.LastSection.Body.IsValidXHTML(htmlstring, XHTMLValidationType.Transitional, out exception);
//If the Html string passes validation, it is inserted to document
if (isValidHtml)
{
//Append Html string as first item of the second paragraph in the document
document.Sections[0].Body.InsertXHTML(htmlstring, 2, 0);
}
//Save and close the document
document.Save("Sample.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document
Dim document As New WordDocument("Template.docx")
'Html string to be inserted
Dim htmlstring As String = "This text is inserted as HTML string.
"
Dim exception As String = "The string is not valid"
'Validating the Html string
Dim isValidHtmlAs Boolean = document.LastSection.Body.IsValidXHTML(htmlstring, XHTMLValidationType.Transitional, exception)
'If the Html string passes validation, it is inserted to document
If isValidHtmlThen
'Append Html string as first item of the second paragraph in the document
document.Sections(0).Body.InsertXHTML(htmlstring, 2, 0)
End If
'Save and close the document
document.Save("Sample.docx")
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create new Word document
WordDocument document = new WordDocument();
//Add new section
IWSection section = document.AddSection();
WTextBody textbody = section.Body;
//Add one paragraph to the section body
textbody.EnsureMinimum();
textbody.LastParagraph.AppendText("Last paragraph");
//Save and close the document
document.Save("Sample.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create new Word document
Dim document As New WordDocument()
'Add new section
Dim section As IWSection = document.AddSection()
Dim textbody As WTextBody = section.Body
'Add one paragraph to the section body
textbody.EnsureMinimum()
textbody.LastParagraph.AppendText("Last paragraph")
'Save and close the document
document.Save("Sample.docx")
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template Word document
WordDocument document = new WordDocument("Template.docx");
//Get the textbody of first section
WTextBody textbody = document.Sections[0].Body;
//Get the last paragraph
IWParagraph paragraph = textbody.LastParagraph;
//Set horizontal alignment
paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Right;
//Save and close the document
document.Save("Sample.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template Word document
Dim document As New WordDocument("Template.docx")
'Get the textbody of first section
Dim textbody As WTextBody = document.Sections(0).Body
'Get the last paragraph
Dim paragraph As IWParagraph = textbody.LastParagraph
'Set horizontal alignment
paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Right
'Save and close the document
document.Save("Sample.docx")
document.Close()
End Sub
//Create an new instance of WordDocument class
WordDocument document = new WordDocument();
//Add a new section into the Word document
IWSection section = document.AddSection();
//Specify the page margins
section.PageSetup.Margins.All = 50f;
//Add a new simple paragraph into the section
IWParagraph paragraph = section.AddParagraph();
//Add a text range into the paragraph
paragraph.AppendText("Hello World!");
//Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx);
//Release the resources occupied by WordDocument instance
document.Close();
'Create an instance of WordDocument class
Dim document As New WordDocument()
'Add a new section into the Word document
Dim section As IWSection = document.AddSection()
'Specify the page margins
section.PageSetup.Margins.All = 50F
'Add a new simple paragraph into the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add a text range into the paragraph
paragraph.AppendText("Hello World!")
'Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx)
'Release the resources occupied by WordDocument instance
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Creates a new Word document.
WordDocument document = new WordDocument();
//Add a section and a paragraph in the empty document
document.EnsureMinimal();
IWParagraph paragraph = document.LastParagraph;
//Append text to the last paragraph of the document
paragraph.AppendText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua");
//Save and close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Creates a new Word document.
Dim document As New WordDocument()
'Add a section and a paragraph in the empty document
document.EnsureMinimal()
Dim paragraph As IWParagraph = document.LastParagraph
'Append text to the last paragraph of the document
paragraph.AppendText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua")
'Save and close the Word document
document.Save("Comment.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Append the text to the created paragraph
paragraph.AppendText("A new section is added to the document.");
//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 new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Append the text to the created paragraph
paragraph.AppendText("A new section is added to the document.")
'Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Create user defined style
IWParagraphStyle style = document.AddParagraphStyle("User_defined_style");
style.ParagraphFormat.BackColor = Color.LightGray;
style.ParagraphFormat.AfterSpacing = 18f;
style.ParagraphFormat.BeforeSpacing = 18f;
style.ParagraphFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.DotDash;
style.ParagraphFormat.Borders.LineWidth = 0.5f;
style.ParagraphFormat.LineSpacing = 15f;
style.CharacterFormat.FontName = "Calibri";
style.CharacterFormat.Italic = true;
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
IWTextRange text = paragraph.AppendText("A new paragraph style is created and is applied to this paragraph.");
//Apply the new style to paragraph
paragraph.ApplyStyle("User_defined_style");
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Create user defined style
Dim style As IWParagraphStyle = document.AddParagraphStyle("User_defined_style")
style.ParagraphFormat.BackColor = Color.LightGray
style.ParagraphFormat.AfterSpacing = 18.0F
style.ParagraphFormat.BeforeSpacing = 18.0F
style.ParagraphFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.DotDash
style.ParagraphFormat.Borders.LineWidth = 0.5F
style.ParagraphFormat.LineSpacing = 15.0F
style.CharacterFormat.FontName = "Calibri"
style.CharacterFormat.Italic = True
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
Dim text As IWTextRange = paragraph.AppendText("A new paragraph style is created and is applied to this paragraph.")
'Apply the new style to paragraph
paragraph.ApplyStyle("User_defined_style")
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new list style to the document
ListStyle listStyle = document.AddListStyle(ListType.Numbered, "UserdefinedList");
WListLevel levelOne = listStyle.Levels[0];
//Define the follow character, prefix, suffix, start index for level 0
levelOne.FollowCharacter = FollowCharacterType.Tab;
levelOne.NumberPrefix = "(";
levelOne.NumberSufix = ")";
levelOne.PatternType = ListPatternType.LowRoman;
levelOne.StartAt = 1;
levelOne.TabSpaceAfter = 5;
levelOne.NumberAlignment = ListNumberAlignment.Center;
WListLevel levelTwo = listStyle.Levels[1];
//Define the follow character, suffix, pattern, start index for level 1
levelTwo.FollowCharacter = FollowCharacterType.Tab;
levelTwo.NumberSufix = "}";
levelTwo.PatternType = ListPatternType.LowLetter;
levelTwo.StartAt = 2;
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add text to the paragraph
paragraph.AppendText("User defined list - Level 0");
//Apply default numbered list style
paragraph.ListFormat.ApplyStyle("UserdefinedList");
//Add second paragraph
paragraph = section.AddParagraph();
paragraph.AppendText("User defined list - Level 1");
//Continue last defined list
paragraph.ListFormat.ContinueListNumbering();
//Increase the level indent
paragraph.ListFormat.IncreaseIndentLevel();
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new list style to the document
Dim listStyle As ListStyle = document.AddListStyle(ListType.Numbered, "UserdefinedList")
Dim levelOne As WListLevel = listStyle.Levels(0)
'Define the follow character, prefix, suffix, start index for level 0
levelOne.FollowCharacter = FollowCharacterType.Tab
levelOne.NumberPrefix = "("
levelOne.NumberSufix = ")"
levelOne.PatternType = ListPatternType.LowRoman
levelOne.StartAt = 1
levelOne.TabSpaceAfter = 5
levelOne.NumberAlignment = ListNumberAlignment.Center
Dim levelTwo As WListLevel = listStyle.Levels(1)
'Define the follow character, suffix, pattern, start index for level 1
levelTwo.FollowCharacter = FollowCharacterType.Tab
levelTwo.NumberSufix = "}"
levelTwo.PatternType = ListPatternType.LowLetter
levelTwo.StartAt = 2
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add text to the paragraph
paragraph.AppendText("User defined list - Level 0")
'Apply default numbered list style
paragraph.ListFormat.ApplyStyle("UserdefinedList")
'Add second paragraph
paragraph = section.AddParagraph()
paragraph.AppendText("User defined list - Level 1")
'Continue last defined list
paragraph.ListFormat.ContinueListNumbering()
'Increase the level indent
paragraph.ListFormat.IncreaseIndentLevel()
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx");
//Get the document text and close the document
string text = document.GetText();
document.Close();
//Create new Word document
WordDocument newdocument = new WordDocument();
//Add new section
IWSection section = newdocument.AddSection();
//Add new paragraph
IWParagraph paragraph = section.AddParagraph();
//Append the text to the paragraph
paragraph.AppendText(text);
//Save and close the document
newdocument.Save("Sample.docx");
newdocument.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx")
'Get the document text and close the document
Dim text As String = document.GetText()
document.Close()
'Create new Word document
Dim newdocument As New WordDocument()
'Add new section
Dim section As IWSection = newdocument.AddSection()
'Add new paragraph
Dim paragraph As IWParagraph = section.AddParagraph()
'Append the text to the paragraph
paragraph.AppendText(text)
'Save and close the document
newdocument.Save("Sample.docx")
newdocument.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Open an existing document
WordDocument inputTemplateDoc = new WordDocument("Template.docx");
//Create a clone of Input Template
WordDocument clonedDocument = inputTemplateDoc.Clone();
//Close the input template document instance
inputTemplateDoc.Close();
//Save and Close the cloned document instance
clonedDocument.Save("ClonedDocument.docx");
clonedDocument.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Open an existing document
Dim inputTemplateDoc As New WordDocument(fileName)
'Create a clone of Input Template
Dim clonedDocument As WordDocument = inputTemplateDoc.Clone()
'Close the input template document instance
inputTemplateDoc.Close()
'Save and Close the cloned document instance
clonedDocument.Save("ClonedDocument.docx")
clonedDocument.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Open the source document
WordDocument sourceDocument = new WordDocument(sourceFileName);
//Open the destination document
WordDocument destinationDocument = new WordDocument(targetFileName);
//Import the last section of source document at the end of destination document
destinationDocument.ImportSection(sourceDocument.LastSection);
//Close the document instance
sourceDocument.Close();
//Save the destination document
destinationDocument.Save(outputFileName, FormatType.Docx);
//Close the document instance
destinationDocument.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Open the source document
Dim sourceDocument As New WordDocument("sourceFileName.docx")
'Open the destination document
Dim destinationDocument As New WordDocument("targetFileName.docx")
'Import the last section of source document at the end of destination document
destinationDocument.ImportSection(sourceDocument.LastSection)
'Close the document instance
sourceDocument.Close()
'Save the destination document
destinationDocument.Save("outputFileName.docx", FormatType.Docx)
'Close the document instance
destinationDocument.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Open the source document
WordDocument sourceDocument = new WordDocument("sourceFileName.docx");
//Open the destination document
WordDocument destinationDocument = new WordDocument("targetFileName.docx");
//Import the contents of source document at the end of destination document
destinationDocument.ImportContent(sourceDocument);
//Close the document instance
sourceDocument.Close()
//Save the destination document
destinationDocument.Save("outputFileName.docx", FormatType.Docx);
//Close the document instance
destinationDocument.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Open the source document
Dim sourceDocument As New WordDocument(sourceFileName)
'Open the destination document
Dim destinationDocument As New WordDocument(targetFileName)
'Import the contents of source document at the end of destination document
destinationDocument.ImportContent(sourceDocument)
'Close the document instance
sourceDocument.Close()
'Save the destination document
destinationDocument.Save(outputFileName, FormatType.Docx)
'Close the document instance
destinationDocument.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Open the source document
WordDocument sourceDocument = new WordDocument("sourceFileName.docx");
//Open the destination document
WordDocument destinationDocument = new WordDocument("targetFileName.docx");
//Import the contents of source document at the end of destination document
destinationDocument.ImportContent(sourceDocument, ImportOptions.UseDestinationStyles);
//Close the document instance
sourceDocument.Close();
//Save the destination document
destinationDocument.Save("outputFileName.docx", FormatType.Docx);
//Close the document instance
destinationDocument.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Open the source document
Dim sourceDocument As New WordDocument(sourceFileName)
'Open the destination document
Dim destinationDocument As New WordDocument(targetFileName)
'Import the contents of source document at the end of destination document
destinationDocument.ImportContent(sourceDocument, ImportOptions.UseDestinationStyles)
'Close the document instance
sourceDocument.Close()
'Save the destination document
destinationDocument.Save(outputFileName, FormatType.Docx)
'Close the document instance
destinationDocument.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Open the source document
WordDocument sourceDocument = new WordDocument("sourceFileName.docx");
//Open the destination document
WordDocument destinationDocument = new WordDocument("targetFileName.docx");
//Import the contents of source document at the end of destination document
destinationDocument.ImportContent(sourceDocument, true);
//Close the document instance
sourceDocument.Close();
//Save the destination document
destinationDocument.Save("outputFileName.docx", FormatType.Docx);
//Close the document instance
destinationDocument.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Open the source document
Dim sourceDocument As New WordDocument(sourceFileName)
'Open the destination document
Dim destinationDocument As New WordDocument(targetFileName)
'Import the contents of source document at the end of destination document
destinationDocument.ImportContent(sourceDocument, true)
'Close the document instance
sourceDocument.Close()
'Save the destination document
destinationDocument.Save(outputFileName, FormatType.Docx)
'Close the document instance
destinationDocument.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Add the built-in style to the document style collection
IStyle style = document.AddStyle(BuiltinStyle.Heading5);
//Apply the added built-in style to the last paragraph of the document
document.LastParagraph.ApplyStyle(style.Name);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Add the built-in style to the document style collection
Dim style As IStyle = document.AddStyle(BuiltinStyle.Heading5)
'Apply the added built-in style to the last paragraph of the document
document.LastParagraph.ApplyStyle(style.Name)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Check whether document has tracked changes
if (document.HasChanges)
//Accept the changes made to the document
document.AcceptChanges();
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Check whether document has tracked changes
If document.HasChanges Then
'Accept the changes made to the document
document.AcceptChanges()
End If
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Check whether document has tracked changes
if (document.HasChanges)
//Reject the changes made to the document
document.RejectChanges();
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Check whether document has tracked changes
If document.HasChanges Then
'Reject the changes made to the document
document.RejectChanges()
End If
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Apply the protection to the document
document.Protect(ProtectionType.AllowOnlyComments);
//Save and close the document instances
document.Save("Sample.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Apply the protection to the document
document.Protect(ProtectionType.AllowOnlyComments)
'Save and close the document instances
document.Save("Sample.docx")
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx", "password");
//Apply the protection to the document
document.Protect(ProtectionType.AllowOnlyComments);
//Save and close the document instances
document.Save("Sample.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Apply the protection to the document
document.Protect(ProtectionType.AllowOnlyComments, "password")
'Save and close the document instances
document.Save("Sample.docx")
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Open an input Word document
WordDocument document = new WordDocument("Template.docx");
//Encrypt the Word document with a password
document.EncryptDocument("password");
//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)
'Open an input Word document
Dim document As New WordDocument("Template.docx")
'Encrypt the Word document with a password
document.EncryptDocument("password")
'Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Open an input Word document
WordDocument document = new WordDocument("Template.docx");
//Remove the encryption from document
document.RemoveEncryption();
//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)
'Open an input Word document
Dim document As New WordDocument("Template.docx")
'Remove the encryption from document
document.RemoveEncryption();
'Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Get the collection of bookmark start in the word document
List<Entity> items = document.GetCrossReferenceItems(ReferenceType.Bookmark);
if (items.Count > 0)
//Change the first cross reference items owner paragraph back color as YelloGreen
(items[0] as BookmarkStart).OwnerParagraph.ParagraphFormat.BackColor = Color.YellowGreen;
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Get the collection of bookmark start in the word document
Dim items As List(Of Entity) = document.GetCrossReferenceItems(ReferenceType.Bookmark)
If items.Count > 0 Then
'Change the first cross reference items owner paragraph back color as YelloGreen
TryCast(items(0), BookmarkStart).OwnerParagraph.ParagraphFormat.BackColor = Color.YellowGreen
End If
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Save the document as Text file
document.SaveTxt("sample.txt", Encoding.ASCII);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Save the document as Text file
document.SaveTxt("sample.txt", Encoding.ASCII)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an new instance of WordDocument class
WordDocument document = new WordDocument();
//Open an existing document from file system
document.Open("Template.docx");
//Saves the specified document
document.Save("Sample.docx");
//Close the WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an new instance of WordDocument class
Dim document As New WordDocument()
'Open an existing document from file system
document.Open("Template.docx")
'Saves the specified document
document.Save("Sample.docx")
'Close the WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an new instance of WordDocument class
WordDocument document = new WordDocument();
//Open an existing document from file system
document.Open("Template.docx", FormatType.Docx);
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an new instance of WordDocument class
Dim document As New WordDocument()
'Open an existing document from file system
document.Open("Template.docx", FormatType.Docx)
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an new instance of WordDocument class
WordDocument document = new WordDocument();
//Open an existing document from file system
document.Open("Template.docx", FormatType.Docx, XHTMLValidationType.Strict, "basePath");
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an new instance of WordDocument class
Dim document As New WordDocument()
'Open an existing document from file system
document.Open("Template.docx", FormatType.Docx, "password", XHTMLValidationType.Strict, basePath)
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an new instance of WordDocument class
WordDocument document = new WordDocument();
//Open an existing document from file system
document.Open("Template.docx", FormatType.Docx, XHTMLValidationType.Strict);
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an new instance of WordDocument class
Dim document As New WordDocument()
'Open an existing document from file system
document.Open("Template.docx", FormatType.Docx, "password", XHTMLValidationType.Strict)
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an new instance of WordDocument class
WordDocument document = new WordDocument();
//Open an existing document from file system
document.Open("Template.docx", FormatType.Docx, "password");
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an new instance of WordDocument class
Dim document As New WordDocument()
'Open an existing document from file system
document.Open("Template.docx", FormatType.Docx, "password")
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
End Sub
//Create a new instance of WordDocument class
WordDocument document = new WordDocument();
//Open an existing document from file system
document.OpenReadOnly("Template.docx", FormatType.Docx, "password");
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
'Create a new instance of WordDocument class
Dim document As New WordDocument()
'Open an existing document from file system
document.OpenReadOnly("Template.docx", FormatType.Docx, "password")
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
//Create a new instance of WordDocument class
WordDocument document = new WordDocument();
//Open an existing document from file system
document.OpenReadOnly("Template.docx", FormatType.Docx, XHTMLValidationType.Strict);
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
'Create a new instance of WordDocument class
Dim document As New WordDocument()
'Open an existing document from file system
document.OpenReadOnly("Template.docx", FormatType.Docx, XHTMLValidationType.Strict)
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
//Create a new instance of WordDocument class
WordDocument document = new WordDocument();
//Open an existing document from file system
document.OpenReadOnly("Template.docx", FormatType.Docx, XHTMLValidationType.Strict, "basePath");
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
'Create a new instance of WordDocument class
Dim document As New WordDocument()
'Open an existing document from file system
document.OpenReadOnly("Template.docx", FormatType.Docx, XHTMLValidationType.Strict, basePath)
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an new instance of WordDocument class
WordDocument document = new WordDocument();
//Open an existing document from file system
document.Open("Template.docx");
//Saves the specified document
document.Save("Sample.docx");
//Close the WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an new instance of WordDocument class
Dim document As New WordDocument()
'Open an existing document from file system
document.Open("Template.docx")
'Saves the specified document
document.Save("Sample.docx")
'Close the WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an new instance of WordDocument class
WordDocument document = new WordDocument();
//Open an existing document from file system
document.Open("Template.docx");
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an new instance of WordDocument class
Dim document As New WordDocument()
'Open an existing document from file system
document.Open("Template.docx")
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
MemoryStream stream = new MemoryStream();
//Create the new WPicture for cover page image
WPicture coverImage = new WPicture(document);
coverImage.LoadImage(Image.FromFile("CoverImage.png"));
//Save the document as EPUB
document.SaveAsEpub("sample.epub", coverImage);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
Dim stream As New MemoryStream()
'Create the new WPicture for cover page image
Dim coverImage As New WPicture(document)
coverImage.LoadImage(Image.FromFile("CoverImage.png"))
'Save the document as EPUB
document.SaveAsEpub("sample.epub", coverImage)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an new instance of WordDocument class
WordDocument document = new WordDocument();
//Open an existing document from file system
document.Open("Template.docx");
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx, HttpContext.Current.Response, HttpContentDisposition.Attachment);
//Close the WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an new instance of WordDocument class
Dim document As New WordDocument()
'Open an existing document from file system
document.Open("Template.docx")
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx, Response, HttpContentDisposition.Attachment)
'Close the WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
MemoryStream stream = new MemoryStream();
//Create the new WPicture for cover page image
WPicture coverImage = new WPicture(document);
coverImage.LoadImage(Image.FromFile("CoverImage.png"));
//Save the document as EPUB
document.SaveAsEpub("sample.epub", coverImage, HttpContext.Current.Response, HttpContentDisposition.Attachment);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
Dim stream As New MemoryStream()
'Create the new WPicture for cover page image
Dim coverImage As New WPicture(document)
coverImage.LoadImage(Image.FromFile("CoverImage.png"))
'Save the document as EPUB
document.SaveAsEpub("sample.epub", coverImage, Response, HttpContentDisposition.Attachment)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an new instance of WordDocument class
WordDocument document = new WordDocument();
Stream fileStream = new FileStream("Sample.html", FileMode.Open, FileAccess.Read, FileShare.Read);
//Open an existing document from file system
document.Open(fileStream, FormatType.Docx, XHTMLValidationType.Strict, "basepath");
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an new instance of WordDocument class
Dim document As New WordDocument()
Dim fileStream As Stream = New FileStream("Sample.html", FileMode.Open, FileAccess.Read, FileShare.Read)
'Open an existing document from file system
document.Open(fileStream, FormatType.Docx, XHTMLValidationType.Strict, basepath)
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an new instance of WordDocument class
WordDocument document = new WordDocument();
Stream fileStream = new FileStream("Sample.html", FileMode.Open, FileAccess.Read, FileShare.Read);
//Open an existing document from file system
document.Open(fileStream, FormatType.Docx, XHTMLValidationType.Strict);
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an new instance of WordDocument class
Dim document As New WordDocument()
Dim fileStream As Stream = New FileStream("Sample.html", FileMode.Open, FileAccess.Read, FileShare.Read)
'Open an existing document from file system
document.Open(fileStream, FormatType.Docx, XHTMLValidationType.Strict)
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an new instance of WordDocument class
WordDocument document = new WordDocument();
Stream fileStream = new FileStream("Sample.docx", FileMode.Open, FileAccess.Read, FileShare.Read);
//Open an existing document from file system
document.Open(fileStream, FormatType.Docx);
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an new instance of WordDocument class
Dim document As New WordDocument()
Dim fileStream As Stream = New FileStream("Sample.docx", FileMode.Open, FileAccess.Read, FileShare.Read)
'Open an existing document from file system
document.Open(fileStream, FormatType.Docx)
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an new instance of WordDocument class
WordDocument document = new WordDocument();
Stream fileStream = new FileStream("Sample.docx", FileMode.Open, FileAccess.Read, FileShare.Read);
//Open an existing document from file system
document.Open(fileStream, FormatType.Docx, "password");
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an new instance of WordDocument class
Dim document As New WordDocument()
Dim fileStream As Stream = New FileStream("Sample.docx", FileMode.Open, FileAccess.Read, FileShare.Read)
'Open an existing document from file system
document.Open(fileStream, FormatType.Docx, "password")
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
MemoryStream stream = new MemoryStream();
//Save the document to stream
document.Save(stream, FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
Dim stream As New MemoryStream()
'Save the document to stream
document.Save(stream, FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument wordDocument = new WordDocument("Template.docx", FormatType.Docx);
//Initialize ChartToImageConverter for converting charts during Word to image conversion
wordDocument.ChartToImageConverter = new ChartToImageConverter();
//Set the scaling mode for charts (Normal mode reduces the file size)
wordDocument.ChartToImageConverter.ScalingMode = ScalingMode.Normal;
//Convert word document to image
Image[] images = wordDocument.RenderAsImages(ImageType.Bitmap);
//Close the document
wordDocument.Close();
int i = 0;
foreach (Image image in images)
{
//Save the images as jpeg
image.Save("WordToImage_" + i + ".jpeg", ImageFormat.Jpeg);
i++;
}
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim wordDocument As New WordDocument("Template.docx", FormatType.Docx)
'Initialize ChartToImageConverter for converting charts during Word to image conversion
wordDocument.ChartToImageConverter = New ChartToImageConverter()
'Set the scaling mode for charts (Normal mode reduces the file size)
wordDocument.ChartToImageConverter.ScalingMode = ScalingMode.Normal
'Convert word document to image
Dim images As Image() = wordDocument.RenderAsImages(ImageType.Bitmap)
'Close the document
wordDocument.Close()
Dim i As Integer = 0
For Each image As Image In images
'Save the images as jpeg
image.Save("WordToImage_" & i & ".jpeg", ImageFormat.Jpeg)
i += 1
Next
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument wordDocument = new WordDocument("Template.docx", FormatType.Docx);
//Initialize ChartToImageConverter for converting charts during Word to image conversion
wordDocument.ChartToImageConverter = new ChartToImageConverter();
//Set the scaling mode for charts (Normal mode reduces the file size)
wordDocument.ChartToImageConverter.ScalingMode = ScalingMode.Normal;
//Convert word document to stream
Stream imageStream = wordDocument.RenderAsImages(2, System.Drawing.Imaging.ImageFormat.Bmp);
//Close the document
wordDocument.Close();
//Convert the stream to Image
Image image = Image.FromStream(imageStream);
//Save the image as jpeg
image.Save("WordToImage.jpeg", ImageFormat.Jpeg);
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim wordDocument As New WordDocument("Template.docx", FormatType.Docx)
'Initialize ChartToImageConverter for converting charts during Word to image conversion
wordDocument.ChartToImageConverter = New ChartToImageConverter()
'Set the scaling mode for charts (Normal mode reduces the file size)
wordDocument.ChartToImageConverter.ScalingMode = ScalingMode.Normal
'Convert word document to stream
Dim imageStream As Stream = wordDocument.RenderAsImages(2, System.Drawing.Imaging.ImageFormat.Bmp)
'Close the document
wordDocument.Close()
'Convert the stream to Image
Dim image As Image = Image.FromStream(imageStream)
'Save the image as jpeg
image.Save("WordToImage.jpeg", ImageFormat.Jpeg)
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument wordDocument = new WordDocument("Template.docx", FormatType.Docx);
//Initialize ChartToImageConverter for converting charts during Word to image conversion
wordDocument.ChartToImageConverter = new ChartToImageConverter();
//Set the scaling mode for charts (Normal mode reduces the file size)
wordDocument.ChartToImageConverter.ScalingMode = ScalingMode.Normal;
//Convert word document to image
Image image = wordDocument.RenderAsImages(2, ImageType.Bitmap);
//Close the document
wordDocument.Close();
//Save the image
image.Save("WordToImage.jpeg", ImageFormat.Jpeg);
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim wordDocument As New WordDocument("Template.docx", FormatType.Docx)
'Initialize ChartToImageConverter for converting charts during Word to image conversion
wordDocument.ChartToImageConverter = New ChartToImageConverter()
'Set the scaling mode for charts (Normal mode reduces the file size)
wordDocument.ChartToImageConverter.ScalingMode = ScalingMode.Normal
'Convert word document to image
Dim image As Image = wordDocument.RenderAsImages(2, ImageType.Bitmap)
'Close the document
wordDocument.Close()
'Save the images as jpeg
image.Save("WordToImage_" & i & ".jpeg", ImageFormat.Jpeg)
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument wordDocument = new WordDocument("Template.docx", FormatType.Docx);
//Initialize ChartToImageConverter for converting charts during Word to image conversion
wordDocument.ChartToImageConverter = new ChartToImageConverter();
//Set the scaling mode for charts (Normal mode reduces the file size)
wordDocument.ChartToImageConverter.ScalingMode = ScalingMode.Normal;
//Convert word document to image
Image[] images = wordDocument.RenderAsImages(0, 2, ImageType.Bitmap);
//Close the document
wordDocument.Close();
int i = 0;
foreach (Image image in images)
{
//Save the images as jpeg
image.Save("WordToImage_" + i + ".jpeg", ImageFormat.Jpeg);
i++;
}
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim wordDocument As New WordDocument("Template.docx", FormatType.Docx)
'Initialize ChartToImageConverter for converting charts during Word to image conversion
wordDocument.ChartToImageConverter = New ChartToImageConverter()
'Set the scaling mode for charts (Normal mode reduces the file size)
wordDocument.ChartToImageConverter.ScalingMode = ScalingMode.Normal
'Convert word document to image
Dim images As Image() = wordDocument.RenderAsImages(0, 2, ImageType.Bitmap)
'Close the document
wordDocument.Close()
Dim i As Integer = 0
For Each image As Image In images
'Save the images as jpeg
image.Save("WordToImage_" & i & ".jpeg", ImageFormat.Jpeg)
i += 1
Next
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Find the first occurrence of a particular text in the document
TextSelection textSelection = document.Find(new Regex("panda"));
//Get the found text as single text range
WTextRange textRange = textSelection.GetAsOneRange();
//Modify the text
textRange.Text = "Replaced text";
//Set highlight color
textRange.CharacterFormat.HighlightColor = Color.Yellow;
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Find the first occurrence of a particular text in the document
Dim textSelection As TextSelection = document.Find(New Regex("panda"))
'Get the found text as single text range
Dim textRange As WTextRange = textSelection.GetAsOneRange()
'Modify the text
textRange.Text = "Replaced text"
'Set highlight color
textRange.CharacterFormat.HighlightColor = Color.Yellow
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Find the first occurrence of a particular text extended to several paragraphs in the document
TextSelection[] textSelections = document.FindSingleLine(new Regex("First paragraph Second paragraph"));
WParagraph paragraph = null;
foreach (TextSelection textSelection in textSelections)
{
//Get the found text as single text range and set highlight color
WTextRange textRange = textSelection.GetAsOneRange();
textRange.CharacterFormat.HighlightColor = Color.YellowGreen;
paragraph = textRange.OwnerParagraph;
}
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Find the first occurrence of a particular text extended to several paragraphs in the document
Dim textSelections As TextSelection() = document.FindSingleLine(new Regex("First paragraph Second paragraph"))
Dim paragraph As WParagraph = Nothing
For Each textSelection As TextSelection In textSelections
'Get the found text as single text range and set highlight color
Dim textRange As WTextRange = textSelection.GetAsOneRange()
textRange.CharacterFormat.HighlightColor = Color.YellowGreen
paragraph = textRange.OwnerParagraph
Next
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Find the first occurrence of a particular text in the document
TextSelection textSelection = document.Find("panda", true, true);
//Get the found text as single text range
WTextRange textRange = textSelection.GetAsOneRange();
//Modify the text
textRange.Text = "Replaced text";
//Set highlight color
textRange.CharacterFormat.HighlightColor = Color.Yellow;
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Find the first occurrence of a particular text in the document
Dim textSelection As TextSelection = document.Find("panda", true, true)
'Get the found text as single text range
Dim textRange As WTextRange = textSelection.GetAsOneRange()
'Modify the text
textRange.Text = "Replaced text"
'Set highlight color
textRange.CharacterFormat.HighlightColor = Color.Yellow
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Find the first occurrence of a particular text extended to several paragraphs in the document
TextSelection[] textSelections = document.FindSingleLine("First paragraph Second paragraph", true, false);
WParagraph paragraph = null;
foreach (TextSelection textSelection in textSelections)
{
//Get the found text as single text range and set highlight color
WTextRange textRange = textSelection.GetAsOneRange();
textRange.CharacterFormat.HighlightColor = Color.YellowGreen;
paragraph = textRange.OwnerParagraph;
}
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Find the first occurrence of a particular text extended to several paragraphs in the document
Dim textSelections As TextSelection() = document.FindSingleLine("First paragraph Second paragraph", True, False)
Dim paragraph As WParagraph = Nothing
For Each textSelection As TextSelection In textSelections
'Get the found text as single text range and set highlight color
Dim textRange As WTextRange = textSelection.GetAsOneRange()
textRange.CharacterFormat.HighlightColor = Color.YellowGreen
paragraph = textRange.OwnerParagraph
Next
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Find the occurrence of the Word "panda" in the document
TextSelection[] textSelection = document.FindAll(new Regex("panda"));
//Iterate through each occurrence and highlight it
foreach (TextSelection selection in textSelection)
{
IWTextRange textRange = selection.GetAsOneRange();
textRange.CharacterFormat.HighlightColor = Color.Yellow;
}
//Save and Close the document
document.Save("Result.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Find the occurrence of the word "panda" in the document
Dim textSelection As TextSelection() = document.FindAll(new Regex("panda"))
'Iterate through each occurrence and highlight it
For Each selection As TextSelection In textSelection
Dim textRange As IWTextRange = selection.GetAsOneRange()
textRange.CharacterFormat.HighlightColor = Color.Yellow
Next
document.Save("Result.docx")
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Find the occurrence of the Word "panda" in the document
TextSelection[] textSelection = document.FindAll("panda", false, true);
//Iterate through each occurrence and highlight it
foreach (TextSelection selection in textSelection)
{
IWTextRange textRange = selection.GetAsOneRange();
textRange.CharacterFormat.HighlightColor = Color.Yellow;
}
//Save and Close the document
document.Save("Result.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Find the occurrence of the word "panda" in the document
Dim textSelection As TextSelection() = document.FindAll("panda", false, true)
'Iterate through each occurrence and highlight it
For Each selection As TextSelection In textSelection
Dim textRange As IWTextRange = selection.GetAsOneRange()
textRange.CharacterFormat.HighlightColor = Color.Yellow
Next
document.Save("Result.docx")
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Replace all occurrence of a particular text in the document
document.Replace(new Regex("Paragraph"),"paragraph");
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
'Replace all occurrence of a particular text in the document
document.Replace(New Regex("Paragraph"), "paragraph")
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Replace all occurrence of a particular text in the document
document.Replace("Paragraph","paragraph", false, true);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
'Replace all occurrence of a particular text in the document
document.Replace("Paragraph", "paragraph", False, True)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Find the first occurrence of the regular expression
TextSelection selection = document.Find(new Regex("Panda"));
//Replace all occurrence of a particular regular expression with the text selection in the document
document.Replace("Giant panda", selection, true, false);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
'Find the first occurrence of the regular expression
Dim selection As TextSelection = document.Find(New Regex("Panda"))
'Replace all occurrence of a particular regular expression with the text selection in the document
document.Replace("Giant panda", selection, True, False)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Find the first occurrence of the regular expression
TextSelection selection = document.Find(new Regex("Panda"));
//Replace all occurrence of a particular regular expression with the text selection in the document
document.Replace("Giant panda", selection, true, false, true);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
'Find the first occurrence of the regular expression
Dim selection As TextSelection = document.Find(New Regex("Panda"))
'Replace all occurrence of a particular regular expression with the text selection in the document
document.Replace("Giant panda", selection, True, False, False)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Find the first occurrence of the regular expression
TextSelection selection = document.Find(new Regex("Panda"));
//Replace all occurrence of a particular regular expression with the text selection in the document
document.Replace(new Regex("Giant panda"), selection);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
'Find the first occurrence of the regular expression
Dim selection As TextSelection = document.Find(New Regex("Panda"))
'Replace all occurrence of a particular regular expression with the text selection in the document
document.Replace(New Regex("Giant panda"), selection)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Find the first occurrence of the regular expression
TextSelection selection = document.Find(new Regex("Panda"));
//Replace all occurrence of a particular regular expression with the text selection in the document
document.Replace(new Regex("Giant panda"), selection, true);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
'Find the first occurrence of the regular expression
Dim selection As TextSelection = document.Find(New Regex("Panda"))
'Replace all occurrence of a particular regular expression with the text selection in the document
document.Replace(New Regex("Giant panda"), selection, True)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Find the first occurrence of the regular expression
TextSelection selection = document.Find(new Regex("Panda"));
//Initialize text body part
TextBodyPart bodyPart = new TextBodyPart(selection);
//Replace a particular text with the text body part
document.Replace("Giant panda", bodyPart, true, false);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
'Find the first occurrence of the regular expression
Dim selection As TextSelection = document.Find(New Regex("Panda"))
'Initialize text body part
Dim bodyPart As New TextBodyPart(selection)
'Replace a particular text with the text body part
document.Replace("Giant panda", bodyPart, True, False)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Find the first occurrence of the regular expression
TextSelection selection = document.Find(new Regex("Panda"));
//Initialize text body part
TextBodyPart bodyPart = new TextBodyPart(selection);
//Replace a particular text with the text body part
document.Replace("Giant panda", bodyPart, true, false, true);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
'Find the first occurrence of the regular expression
Dim selection As TextSelection = document.Find(New Regex("Panda"))
'Initialize text body part
Dim bodyPart As New TextBodyPart(selection)
'Replace a particular text with the text body part
document.Replace("Giant panda", bodyPart, True, False, True)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Find the first occurrence of the regular expression
TextSelection selection = document.Find(new Regex("Panda"));
//Initialize text body part
TextBodyPart bodyPart = new TextBodyPart(selection);
//Replace a particular text with the text body part
document.Replace(new Regex("Giant panda"), bodyPart);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
'Find the first occurrence of the regular expression
Dim selection As TextSelection = document.Find(New Regex("Panda"))
'Initialize text body part
Dim bodyPart As New TextBodyPart(selection)
'Replace a particular text with the text body part
document.Replace(New Regex("Giant panda"), bodyPart)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Find the first occurrence of the regular expression
TextSelection selection = document.Find(new Regex("Panda"));
//Initialize text body part
TextBodyPart bodyPart = new TextBodyPart(selection);
//Replace a particular text with the text body part
document.Replace(new Regex("Giant panda"), bodyPart, true);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
'Find the first occurrence of the regular expression
Dim selection As TextSelection = document.Find(New Regex("Panda"))
'Initialize text body part
Dim bodyPart As New TextBodyPart(selection)
'Replace a particular text with the text body part
document.Replace(New Regex("Giant panda"), bodyPart, True)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Load the another existing Word document to replace
WordDocument replaceDocument = new WordDocument("Replace.docx");
//Replace all occurrence of a particular regular expression with the another document and close the document
document.Replace("Giant panda", replaceDocument, true, false);
replaceDocument.Close();
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
'Load the another existing Word document to replace
Dim replaceDocument As New WordDocument("Replace.docx")
'Replace all occurrence of a particular regular expression with the another document and close the document
document.Replace("Giant panda", replaceDocument, True, False)
replaceDocument.Close();
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Load the another existing Word document to replace
WordDocument replaceDocument = new WordDocument("Replace.docx");
//Replace all occurrence of a particular regular expression with the another document and close the document
document.Replace("Giant panda", replaceDocument, true, false, true);
replaceDocument.Close();
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
'Load the another existing Word document to replace
Dim replaceDocument As New WordDocument("Replace.docx")
'Replace all occurrence of a particular regular expression with the another document and close the document
document.Replace("Giant panda", replaceDocument, True, False, True)
replaceDocument.Close();
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Load the another existing Word document to replace
WordDocument replaceDocument = new WordDocument("Replace.docx");
//Replace all occurrence of a particular regular expression with the another document and close the document
document.Replace(new Regex("Giant panda"), replaceDocument, true);
replaceDocument.Close();
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
'Load the another existing Word document to replace
Dim replaceDocument As New WordDocument("Replace.docx")
'Replace all occurrence of a particular regular expression with the another document and close the document
document.Replace(New Regex("Giant panda"), replaceDocument, True)
replaceDocument.Close();
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
//Open an input word template
IWordDocument document = new WordDocument(@"Template.docx");
//Update the Paragraphs count, Word count and Character count in the document
document.UpdateWordCount();
//Save and close the Word document instance.
document.Save("Output.docx", FormatType.Docx);
document.Close();
}
'Open an input word template
Dim document As New IWordDocument("Template.docx")
'Update the Paragraphs count, Word count and Character count in the document.
document.UpdateWordCount()
�Save and close the Word document instance.
document.Save("Output.docx", FormatType.Docx)
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Open an input word template
WordDocument document = new WordDocument(@"Template.docx");
//Update the Page count, Paragraphs count, Word count and Character count in the document
document.UpdateWordCount(true);
//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)
'Open an input word template
Dim document As New WordDocument("Template.docx")
'Update the Page count, Paragraphs count, Word count and Character count in the document.
document.UpdateWordCount(True)
�Save and close the Word document instance.
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Input.docx", FormatType.Docx);
//Updates the fields present in a document.
document.UpdateDocumentFields();
document.Save("Result.docx", FormatType.Docx);
document.Close();
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Input.docx", FormatType.Docx)
'Updates the fields present in a document.
document.UpdateDocumentFields()
document.Save("Result.docx", FormatType.Docx)
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Input.docx", FormatType.Docx);
//Updates the Alternate chunks present in a document.
document.UpdateAlternateChunks();
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Input.docx", FormatType.Docx)
'Updates the Alternate chunks present in a document.
document.UpdateAlternateChunks()
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
//Open an input word template
WordDocument document = new WordDocument(@"Template.docx");
//Update the table of contents.
document.UpdateTableOfContents();
//Save and close the Word document instance.
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Open an input word template
Dim document As New WordDocument("Template.docx")
'Update the table of contents.
document.UpdateTableOfContents()
'Save and close the Word document instance.
document.Save("Sample.docx", FormatType.Docx)
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Replace the text extended to two paragraphs with simple text
document.ReplaceSingleLine("First paragraph Second paragraph", "Replaced paragraph", true, false);
//Save and close the document
document.Save("Replace.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Replace the text extended to two paragraphs with simple text
document.ReplaceSingleLine("First paragraph Second paragraph", "Replaced paragraph", True, False)
'Save and close the document
document.Save("Replace.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Replace the text extended to two paragraphs with simple text
document.ReplaceSingleLine(new Regex("First paragraph Second paragraph"), "Replaced paragraph");
//Save and close the document
document.Save("Replace.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Replace the text extended to two paragraphs with simple text
document.ReplaceSingleLine(New Regex("First paragraph Second paragraph"), "Replaced paragraph")
'Save and close the document
document.Save("Replace.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Find the first occurrence of a particular text in the document
TextSelection selection = document.Find("contents", false, false);
//Replace the text extended to two paragraphs with text selection
document.ReplaceSingleLine("First paragraph Second paragraph", selection, true, false);
//Save and close the document
document.Save("Replace.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Find the first occurrence of a particular text in the document
Dim selection As TextSelection = document.Find("contents", False, False)
'Replace the text extended to two paragraphs with text selection
document.ReplaceSingleLine("First paragraph Second paragraph", selection, True, False)
'Save and close the document
document.Save("Replace.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Find the first occurrence of a particular text in the document
TextSelection selection = document.Find("contents", false, false);
//Replace the text extended to two paragraphs with text selection
document.ReplaceSingleLine(new Regex("First paragraph Second paragraph"), selection);
//Save and close the document
document.Save("Replace.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Find the first occurrence of a particular text in the document
Dim selection As TextSelection = document.Find("contents", False, False)
'Replace the text extended to two paragraphs with text selection
document.ReplaceSingleLine(New Regex("First paragraph Second paragraph"), selection)
'Save and close the document
document.Save("Replace.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Find the first occurrence of a particular text in the document
TextSelection selection = document.Find("contents", false, false);
//Initialize text body part
TextBodyPart bodyPart = new TextBodyPart(selection);
//Replace a particular text with the text body part
document.ReplaceSingleLine("First paragraph Second paragraph", bodyPart, true, false);
//Save and close the document
document.Save("Replace.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Find the first occurrence of a particular text in the document
Dim selection As TextSelection = document.Find("contents", False, False)
'Initialize text body part
Dim bodyPart As New TextBodyPart(selection)
'Replace a particular text with the text body part
document.ReplaceSingleLine("First paragraph Second paragraph", bodyPart, True, False)
'Save and close the document
document.Save("Replace.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Find the first occurrence of a particular text in the document
TextSelection selection = document.Find("contents", false, false);
//Initialize text body part
TextBodyPart bodyPart = new TextBodyPart(selection);
//Replace a particular text with the text body part
document.ReplaceSingleLine(new Regex("First paragraph Second paragraph"), bodyPart);
//Save and close the document
document.Save("Replace.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Find the first occurrence of a particular text in the document
Dim selection As TextSelection = document.Find("contents", False, False)
'Initialize text body part
Dim bodyPart As New TextBodyPart(selection)
'Replace a particular text with the text body part
document.ReplaceSingleLine(New Regex("First paragraph Second paragraph"), bodyPart)
'Save and close the document
document.Save("Replace.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Find the first occurrence of a particular text in the document
TextSelection textSelection = document.Find("as graphical contents", false, true);
//Get the found text as single text range
WTextRange textRange = textSelection.GetAsOneRange();
//Modify the text
textRange.Text = "Replaced text";
//Set highlight color
textRange.CharacterFormat.HighlightColor = Color.Yellow;
//Find the next occurrence of a particular text from the previous paragraph
textSelection = document.FindNext(textRange.OwnerParagraph, "paragraph", true, false);
//Get the found text as single text range
WTextRange range = textSelection.GetAsOneRange();
//Set bold formatting
range.CharacterFormat.Bold = true;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Find the first occurrence of a particular text in the document
Dim textSelection As TextSelection = document.Find("as graphical contents", false, true)
'Get the found text as single text range
Dim textRange As WTextRange = textSelection.GetAsOneRange()
'Modify the text
textRange.Text = "Replaced text"
'Set highlight color
textRange.CharacterFormat.HighlightColor = Color.Yellow
'Find the next occurrence of a particular text from the previous paragraph
textSelection = document.FindNext(textRange.OwnerParagraph, "paragraph", true, false)
'Get the found text as single text range
Dim range As WTextRange = textSelection.GetAsOneRange()
'Set bold formatting
range.CharacterFormat.Bold = True
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Find the first occurrence of a particular text in the document
TextSelection textSelection = document.Find(new Regex("as graphical contents"));
//Get the found text as single text range
WTextRange textRange = textSelection.GetAsOneRange();
//Modify the text
textRange.Text = "Replaced text";
//Set highlight color
textRange.CharacterFormat.HighlightColor = Color.Yellow;
//Find the next occurrence of a particular text from the previous paragraph
textSelection = document.FindNext(textRange.OwnerParagraph, new Regex("paragraph"));
//Get the found text as single text range
WTextRange range = textSelection.GetAsOneRange();
//Set bold formatting
range.CharacterFormat.Bold = true;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Find the first occurrence of a particular text in the document
Dim textSelection As TextSelection = document.Find("as graphical contents")
'Get the found text as single text range
Dim textRange As WTextRange = textSelection.GetAsOneRange()
'Modify the text
textRange.Text = "Replaced text"
'Set highlight color
textRange.CharacterFormat.HighlightColor = Color.Yellow
'Find the next occurrence of a particular text from the previous paragraph
textSelection = document.FindNext(textRange.OwnerParagraph, "paragraph")
'Get the found text as single text range
Dim range As WTextRange = textSelection.GetAsOneRange()
'Set bold formatting
range.CharacterFormat.Bold = True
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Find the first occurrence of a particular text extended to several paragraphs in the document
TextSelection[] textSelections = document.FindSingleLine("First paragraph Second paragraph", true, false);
WParagraph paragraph = null;
foreach (TextSelection textSelection in textSelections)
{
//Get the found text as single text range and set highlight color
WTextRange textRange = textSelection.GetAsOneRange();
textRange.CharacterFormat.HighlightColor = Color.YellowGreen;
paragraph = textRange.OwnerParagraph;
}
//Find the next occurrence of a particular text extended to several paragraphs in the document
textSelections = document.FindNextSingleLine(paragraph, "First paragraph Second paragraph", true, false);
foreach (TextSelection textSelection in textSelections)
{
//Get the found text as single text range and set italic formatting
WTextRange text = textSelection.GetAsOneRange();
text.CharacterFormat.Italic = true;
}
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Find the first occurrence of a particular text extended to several paragraphs in the document
Dim textSelections As TextSelection() = document.FindSingleLine("First paragraph Second paragraph", True, False)
Dim paragraph As WParagraph = Nothing
For Each textSelection As TextSelection In textSelections
'Get the found text as single text range and set highlight color
Dim textRange As WTextRange = textSelection.GetAsOneRange()
textRange.CharacterFormat.HighlightColor = Color.YellowGreen
paragraph = textRange.OwnerParagraph
Next
'Find the next occurrence of a particular text extended to several paragraphs in the document
textSelections = document.FindNextSingleLine(paragraph, "First paragraph Second paragraph", True, False)
For Each textSelection As TextSelection In textSelections
'Get the found text as single text range and set italic formatting
Dim text As WTextRange = textSelection.GetAsOneRange()
text.CharacterFormat.Italic = True
Next
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Find the first occurrence of a particular text extended to several paragraphs in the document
TextSelection[] textSelections = document.FindSingleLine("First paragraph Second paragraph", true, false);
WParagraph paragraph = null;
foreach (TextSelection textSelection in textSelections)
{
//Get the found text as single text range and set highlight color
WTextRange textRange = textSelection.GetAsOneRange();
textRange.CharacterFormat.HighlightColor = Color.YellowGreen;
paragraph = textRange.OwnerParagraph;
}
//Find the next occurrence of a particular text extended to several paragraphs in the document
textSelections = document.FindNextSingleLine(paragraph, new Regex("First paragraph Second paragraph"));
foreach (TextSelection textSelection in textSelections)
{
//Get the found text as single text range and set italic formatting
WTextRange text = textSelection.GetAsOneRange();
text.CharacterFormat.Italic = true;
}
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Find the first occurrence of a particular text extended to several paragraphs in the document
Dim textSelections As TextSelection() = document.FindSingleLine("First paragraph Second paragraph", True, False)
Dim paragraph As WParagraph = Nothing
For Each textSelection As TextSelection In textSelections
'Get the found text as single text range and set highlight color
Dim textRange As WTextRange = textSelection.GetAsOneRange()
textRange.CharacterFormat.HighlightColor = Color.YellowGreen
paragraph = textRange.OwnerParagraph
Next
'Find the next occurrence of a particular text extended to several paragraphs in the document
textSelections = document.FindNextSingleLine(paragraph, new Regex("First paragraph Second paragraph"))
For Each textSelection As TextSelection In textSelections
'Get the found text as single text range and set italic formatting
Dim text As WTextRange = textSelection.GetAsOneRange()
text.CharacterFormat.Italic = True
Next
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the document with macros
WordDocument document = new WordDocument("Sample.docm");
//Check whether the document has macros and remove them
if (document.HasMacros)
document.RemoveMacros();
//Save the document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the document with macros
Dim document As New WordDocument("Sample.docm")
'Check whether the document has macros and remove them
If document.HasMacros Then
document.RemoveMacros()
End If
'Save the document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument wordDocument = new WordDocument("Template.docx", FormatType.Docx);
//Initialize ChartToImageConverter for converting charts during Word to pdf conversion
wordDocument.ChartToImageConverter = new ChartToImageConverter();
//Create an instance of DocToPDFConverter
DocToPDFConverter converter = new DocToPDFConverter();
//Convert Word document into PDF document
PdfDocument pdfDocument = converter.ConvertToPDF(wordDocument);
//Close the instance of Word document object
wordDocument.Close();
//Save the PDF file
pdfDocument.Save("WordtoPDF.pdf");
//Close the instance of PDF document object
pdfDocument.Close(true);
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim wordDocument As New WordDocument("Template.docx", FormatType.Docx)
'Initialize ChartToImageConverter for converting charts during Word to pdf conversion
/// wordDocument.ChartToImageConverter = New ChartToImageConverter()
'Create an instance of DocToPDFConverter
Dim converter As New DocToPDFConverter()
'Convert Word document into PDF document
Dim pdfDocument As PdfDocument = converter.ConvertToPDF(wordDocument)
'Close the instance of document object
wordDocument.Close()
'Save the PDF file
pdfDocument.Save("WordtoPDF.pdf")
'Close the instance of document object
pdfDocument.Close(True)
End Sub
// Loads an existing Word document.
WordDocument wordDocument = new WordDocument("template.docx", FormatType.Docx);
// Initializes the SubstituteFont event to perform font substitution during Word to PDF conversion.
wordDocument.FontSettings.SubstituteFont += new SubstituteFontEventHandler(SubstituteFont);
// Creates an instance of DocToPDFConverter.
DocToPDFConverter converter = new DocToPDFConverter();
// Converts the Word document into PDF document.
PdfDocument pdfDocument = converter.ConvertToPDF(wordDocument);
// Closes the instance of Word document object.
wordDocument.Close();
// Saves the PDF file.
pdfDocument.Save("WordtoPDF.pdf");
// Closes the instance of PDF document object.
pdfDocument.Close(true);
private void SubstituteFont(object sender, SubstituteFontEventArgs args)
{
// Sets the alternate font when a specified font is not installed in the production environment.
if (args.OrignalFontName == "Arial Unicode MS")
args.AlternateFontName = "Arial";
else
args.AlternateFontName = "Times New Roman";
}
' Loads an existing Word document.
Dim wordDocument As New WordDocument("template.docx", FormatType.Docx)
' Initializes the SubstituteFont event to perform font substitution during Word to PDF conversion.
AddHandler wordDocument.FontSettings.SubstituteFont, AddressOf SubstituteFont
' Creates an instance of DocToPDFConverter.
Dim converter As New DocToPDFConverter()
' Converts the Word document into PDF document.
Dim pdfDocument As PdfDocument = converter.ConvertToPDF(wordDocument)
' Closes the instance of document object.
wordDocument.Close()
' Saves the PDF file .
pdfDocument.Save("WordtoPDF.pdf")
' Closes the instance of document object.
pdfDocument.Close(True)
Private Sub SubstituteFont(ByVal sender As Object, ByVal args As SubstituteFontEventArgs)
' Sets the alternate font when a specified font is not installed in the production environment.
If args.OrignalFontName = "Arial Unicode MS" Then
args.AlternateFontName = "Arial"
Else
args.AlternateFontName = "Times New Roman"
End If
End Sub
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Retrieve the last section of the document and add new paragraph
document.LastSection.AddParagraph().AppendText("Adding new paragraph to the document");
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Retrieve the last section of the document and add new paragraph
document.LastSection.AddParagraph().AppendText("Adding new paragraph to the document")
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Set the last paragraph back color as Blue
document.LastParagraph.ParagraphFormat.BackColor = Color.Blue;
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Set the last paragraph back color as Blue
document.LastParagraph.ParagraphFormat.BackColor = Color.Blue
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Set the endnote format
document.EndnoteNumberFormat = FootEndNoteNumberFormat.Arabic;
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Set the endnote format
document.EndnoteNumberFormat = FootEndNoteNumberFormat.Arabic
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Set the footnote number format
document.FootnoteNumberFormat = FootEndNoteNumberFormat.UpperCaseRoman;
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Set the footnote number format
document.FootnoteNumberFormat = FootEndNoteNumberFormat.UpperCaseRoman
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Set the endnote restart index number
document.RestartIndexForEndnote = EndnoteRestartIndex.RestartForEachSection;
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Set the endnote restart index number
document.RestartIndexForEndnote = EndnoteRestartIndex.RestartForEachSection
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Set the endnote position at end of each section
document.EndnotePosition = EndnotePosition.DisplayEndOfSection;
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Set the endnote position at end of each section
document.EndnotePosition = EndnotePosition.DisplayEndOfSection
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Set the footnote restart index number
document.RestartIndexForFootnotes = FootnoteRestartIndex.RestartForEachPage;
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Set the footnote restart index number
document.RestartIndexForFootnotes = FootnoteRestartIndex.RestartForEachPage
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Set the footnote position at immediately beneath text
document.FootnotePosition = FootnotePosition.PrintImmediatelyBeneathText;
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Set the footnote position at immediately beneath text
document.FootnotePosition = FootnotePosition.PrintImmediatelyBeneathText
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//protect the document from editing
document.ProtectionType = Syncfusion.DocIO.ProtectionType.AllowOnlyReading;
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'protect the document from editing
document.ProtectionType = Syncfusion.DocIO.ProtectionType.AllowOnlyReading
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Set the footnote initial number
document.InitialFootnoteNumber = 3;
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Set the footnote initial number
document.InitialFootnoteNumber = 3
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Set the endnote initial number
document.InitialEndnoteNumber = 5;
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Set the endnote initial number
document.InitialEndnoteNumber = 5
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("First Name of the customer: ");
//Add the DocVariable field with Variable name and its type
paragraph.AppendField("FirstName", FieldType.FieldDocVariable);
paragraph = section.AddParagraph();
paragraph.AppendText("Last Name of the customer: ");
//Add the DocVariable field with Variable name and its type
paragraph.AppendField("LastName", FieldType.FieldDocVariable);
//Add the value for variable in WordDocument.Variable collection
document.Variables.Add("FirstName", "Jeff");
document.Variables.Add("LastName", "Smith");
//Update the document fields
document.UpdateDocumentFields();
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument()
Dim section As IWSection = document.AddSection()
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("First Name of the customer: ")
'Add the DocVariable field with Variable name and its type
paragraph.AppendField("FirstName", FieldType.FieldDocVariable)
paragraph = section.AddParagraph()
paragraph.AppendText("Last Name of the customer: ")
'Add the DocVariable field with Variable name and its type
paragraph.AppendField("LastName", FieldType.FieldDocVariable)
'Add the value for variable in WordDocument.Variable collection
document.Variables.Add("FirstName", "Jeff")
document.Variables.Add("LastName", "Smith")
'Update the document fields
document.UpdateDocumentFields()
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Enable the TrackChanges to track the edits as revision
document.TrackChanges = true;
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Enable the TrackChanges to track the edits as revision
document.TrackChanges = True
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Set to replace only the first occurrence of a particular text
document.ReplaceFirst = true;
//Find the first occurrence of a particular text in the document
TextSelection selection = document.Find("contents", false, false);
//Initialize text body part
TextBodyPart bodyPart = new TextBodyPart(selection);
//Replace a particular text with the text body part
document.Replace("paragraph", bodyPart, false, true, true);
//Save and close the document
document.Save("Replace.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Set to replace only the first occurrence of a particular text
document.ReplaceFirst = True
'Find the first occurrence of a particular text in the document
Dim selection As TextSelection = document.Find("contents", False, False)
'Initialize text body part
Dim bodyPart As New TextBodyPart(selection)
'Replace a particular text with the text body part
document.Replace("paragraph", bodyPart, False, True, True)
'Save and close the document
document.Save("Replace.docx", FormatType.Docx)
document.Close()
End Sub
//Creates an new instance of WordDocument class.
WordDocument srcDocument = new WordDocument("SourceTemplate.docx");
// Creates an new instance of WordDocument class.
WordDocument destDocument = new WordDocument("DestinationTemplate.docx");
//Import the contents of source document at the end of destination document with destination styles.
destDocument.ImportOptions = ImportOptions.UseDestinationStyles;
destDocument.Sections.Add(srcDocument.LastSection.Clone());
// Releases the resources occupied by WordDocument instance.
srcDocument.Close();
// Saves the document in the given name and format.
destDocument.Save("Document.docx", FormatType.Docx);
// Releases the resources occupied by WordDocument instance.
destDocument.Close();
'Creates an new instance of WordDocument class.
Dim srcDocument As New WordDocument("SourceTemplate.docx")
' Creates an new instance of WordDocument class.
Dim destDocument As New WordDocument("DestinationTemplate.docx")
'Import the contents of source document at the end of destination document with destination styles.
destDocument.ImportOptions = ImportOptions.UseDestinationStyles
destDocument.Sections.Add(srcDocument.LastSection.Clone())
' Releases the resources occupied by WordDocument instance.
srcDocument.Close()
' Saves the document in the given name and format.
destDocument.Save("Document.docx", FormatType.Docx)
' Releases the resources occupied by WordDocument instance.
destDocument.Close()
// Creates an new instance of WordDocument class.
WordDocument srcDocument = new WordDocument();
// Adds a section and a paragraph in the empty document.
srcDocument.EnsureMinimal();
// Sets bold to character format of "Normal" style to differentiate source and destination document.
(srcDocument.Styles.FindByName("Normal") as WParagraphStyle).CharacterFormat.Bold = true;
// Creates an new instance of WordDocument class.
WordDocument destDocument = new WordDocument();
// Adds a section and a paragraph in the empty document.
destDocument.EnsureMinimal();
// Sets false value to exclude importing duplicate styles to destination document.
destDocument.ImportStyles = false;
destDocument.Sections.Add(srcDocument.LastSection.Clone());
// Releases the resources occupied by WordDocument instance.
srcDocument.Close();
// Saves the document in the given name and format.
destDocument.Save("Document.docx", FormatType.Docx);
// Releases the resources occupied by WordDocument instance.
destDocument.Close();
' Creates an new instance of WordDocument class.
Dim srcDocument As New WordDocument()
' Adds a section and a paragraph in the empty document.
srcDocument.EnsureMinimal()
' Sets bold to character format of "Normal" style to differentiate source and destination document.
TryCast(srcDocument.Styles.FindByName("Normal"), WParagraphStyle).CharacterFormat.Bold = True
' Creates an new instance of WordDocument class.
Dim destDocument As New WordDocument()
' Adds a section and a paragraph in the empty document.
destDocument.EnsureMinimal()
' Sets false value to exclude importing duplicate styles to destination document.
destDocument.ImportStyles = False
destDocument.Sections.Add(srcDocument.LastSection.Clone())
' Releases the resources occupied by WordDocument instance.
srcDocument.Close()
' Saves the document in the given name and format.
destDocument.Save("Document.docx", FormatType.Docx)
' Releases the resources occupied by WordDocument instance.
destDocument.Close()
// Creates an new instance of WordDocument class.
WordDocument srcDocument = new WordDocument();
// Adds a section and a paragraph in the empty document.
srcDocument.EnsureMinimal();
// Creates a paragraph style (with name "Test") and adds into source document.
WParagraphStyle paragraphStyle = new WParagraphStyle(srcDocument);
paragraphStyle.Name = "Test";
srcDocument.Styles.Add(paragraphStyle);
// Creates an new instance of WordDocument class.
WordDocument destDocument = new WordDocument();
// Adds a section and a paragraph in the empty document.
destDocument.EnsureMinimal();
// Creates a character style (with same paragraph styel name in source) and adds into destination document.
WCharacterStyle characterStyle = new WCharacterStyle(destDocument);
characterStyle.Name = "Test";
destDocument.Styles.Add(characterStyle);
// Sets true value to include importing duplicate styles (mismatched with types) to destination document.
destDocument.ImportStylesOnTypeMismatch = true;
destDocument.Sections.Add(srcDocument.LastSection.Clone());
// Releases the resources occupied by WordDocument instance.
srcDocument.Close();
// Saves the document in the given name and format.
destDocument.Save("Document.docx", FormatType.Docx);
// Releases the resources occupied by WordDocument instance.
destDocument.Close();
' Creates an new instance of WordDocument class.
Dim srcDocument As New WordDocument()
' Adds a section and a paragraph in the empty document.
srcDocument.EnsureMinimal()
' Creates a paragraph style (with name "Test") and adds into source document.
Dim paragraphStyle As New WParagraphStyle(srcDocument)
paragraphStyle.Name = "Test"
srcDocument.Styles.Add(paragraphStyle)
' Creates an new instance of WordDocument class.
Dim destDocument As New WordDocument()
' Adds a section and a paragraph in the empty document.
destDocument.EnsureMinimal()
' Creates a character style (with same paragraph styel name in source) and adds into destination document.
Dim characterStyle As New WCharacterStyle(destDocument)
characterStyle.Name = "Test"
destDocument.Styles.Add(characterStyle)
' Sets true value to include importing duplicate styles (mismatched with types) to destination document.
destDocument.ImportStylesOnTypeMismatch = True
destDocument.Sections.Add(srcDocument.LastSection.Clone())
' Releases the resources occupied by WordDocument instance.
srcDocument.Close()
' Saves the document in the given name and format.
destDocument.Save("Document.docx", FormatType.Docx)
' Releases the resources occupied by WordDocument instance.
destDocument.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Apply the Arial font instead of the Arabic font, if the system does not contains Arabic font
document.FontSubstitutionTable.Add("Arabic", "Arial");
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Apply the Arial font instead of the Arabic font, if the system does not contains Arabic font
document.FontSubstitutionTable.Add("Arabic", "Arial");
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Loads an existing Word document
WordDocument wordDocument = new WordDocument("Template.docx", FormatType.Docx);
//Sets revision types to preserve track changes in PDF conversion.
wordDocument.RevisionOptions.ShowMarkup = RevisionType.Insertions | RevisionType.Formatting | RevisionType.Deletions;
//Instantiation of DocToPDFConverter for Word to PDF conversion
DocToPDFConverter converter = new DocToPDFConverter();
//Converts Word document into PDF document
PdfDocument pdfDocument = converter.ConvertToPDF(wordDocument);
//Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf");
//Releases all resources used by the object
converter.Dispose();
//Closes the instance of document objects
wordDocument.Close();
pdfDocument.Close(true);
'Loads an existing Word document
Dim wordDocument As WordDocument = New WordDocument("Template.docx", FormatType.Docx)
'Sets revision types to preserve track changes in PDF conversion.
wordDocument.RevisionOptions.ShowMarkup = RevisionType.Insertions Or RevisionType.Formatting Or RevisionType.Deletions
'Instantiation of DocToPDFConverter for Word to PDF conversion
Dim converter As DocToPDFConverter = New DocToPDFConverter
'Converts Word document into PDF document
Dim pdfDocument As PdfDocument = converter.ConvertToPDF(wordDocument)
'Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf")
'Releases all resources used by the object
converter.Dispose()
'Closes the instance of document objects
wordDocument.Close()
pdfDocument.Close(True)
//Load an existing Word document into WordDocument instance
WordDocument document = new WordDocument("Sample.docx");
//Add a new simple paragraph into the last section of the document
IWParagraph paragraph = document.LastSection.AddParagraph();
//Add a text range into the paragraph
paragraph.AppendText("Hello World!");
//Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx);
//Release the resources occupied by WordDocument instance
document.Close();
'Load an existing Word document into WordDocument instance
Dim document As New WordDocument("Sample.docx")
'Add a new simple paragraph into the last section of the document
Dim paragraph As IWParagraph = document.LastSection.AddParagraph()
'Add a text range into the paragraph
paragraph.AppendText("Hello World!")
'Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx)
'Release the resources occupied by WordDocument instance
document.Close()
//Load an existing Word document into WordDocument instance
WordDocument document = new WordDocument("Sample.docx", "password");
//Add a new simple paragraph into the last section of the document
IWParagraph paragraph = document.LastSection.AddParagraph();
//Add a text range into the paragraph
paragraph.AppendText("Hello World!");
//Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx);
//Release the resources occupied by WordDocument instance
document.Close();
'Load an existing Word document into WordDocument instance
Dim document As New WordDocument("Sample.docx", "password")
'Add a new simple paragraph into the last section of the document
Dim paragraph As IWParagraph = document.LastSection.AddParagraph()
'Add a text range into the paragraph
paragraph.AppendText("Hello World!")
'Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx)
'Release the resources occupied by WordDocument instance
document.Close()
//Load an existing Word document into WordDocument instance
WordDocument document = new WordDocument("Sample.docx", FormatType.Docx);
//Add a new simple paragraph into the last section of the document
IWParagraph paragraph = document.LastSection.AddParagraph();
//Add a text range into the paragraph
paragraph.AppendText("Hello World!");
//Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx);
//Release the resources occupied by WordDocument instance
document.Close();
'Load an existing Word document into WordDocument instance
Dim document As New WordDocument("Sample.docx", FormatType.Docx)
'Add a new simple paragraph into the last section of the document
Dim paragraph As IWParagraph = document.LastSection.AddParagraph()
'Add a text range into the paragraph
paragraph.AppendText("Hello World!")
'Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx)
'Release the resources occupied by WordDocument instance
document.Close()
//Load an existing HTML file into WordDocument instance with Strict validation type
WordDocument document = new WordDocument("Sample.html", FormatType.Html, XHTMLValidationType.Strict);
//Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx);
//Release the resources occupied by WordDocument instance
document.Close();
'Load an existing HTML file into WordDocument instance with Strict validation type
Dim document As New WordDocument("Sample.html", FormatType.Html, XHTMLValidationType.[Strict])
'Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx)
'Release the resources occupied by WordDocument instance
document.Close()
//Load an existing Word document into WordDocument instance
WordDocument document = new WordDocument("Sample.docx", FormatType.Docx, "password");
//Add a new simple paragraph into the last section of the document
IWParagraph paragraph = document.LastSection.AddParagraph();
//Add a text range into the paragraph
paragraph.AppendText("Hello World!");
//Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx);
//Release the resources occupied by WordDocument instance
document.Close();
'Load an existing Word document into WordDocument instance
Dim document As New WordDocument("Sample.docx", FormatType.Docx, "password")
'Add a new simple paragraph into the last section of the document
Dim paragraph As IWParagraph = document.LastSection.AddParagraph()
'Add a text range into the paragraph
paragraph.AppendText("Hello World!")
'Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx)
'Release the resources occupied by WordDocument instance
document.Close()
Stream htmlFile = new FileStream("Sample.html", FileMode.Open, FileAccess.Read, FileShare.Read);
//Load an existing Stream into WordDocument instance with Strict validation type
WordDocument document = new WordDocument(htmlFile, FormatType.Html, XHTMLValidationType.Strict);
//Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx);
//Release the resources occupied by WordDocument instance
document.Close();
Dim htmlFile As Stream = New FileStream("Sample.html", FileMode.Open, FileAccess.Read, FileShare.Read)
'Load an existing Stream into WordDocument instance with Strict validation type
Dim document As New WordDocument(htmlFile, FormatType.Html, XHTMLValidationType.[Strict])
'Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx)
'Release the resources occupied by WordDocument instance
document.Close()
//Create an instance of WordDocument class
WordDocument document = new WordDocument();
//Add a new section into the Word document
IWSection section = document.AddSection();
//Specify the page margins
section.PageSetup.Margins.All = 50f;
//Add a new simple paragraph into the section
IWParagraph paragraph = section.AddParagraph();
//Add a text range into the paragraph
paragraph.AppendText("Hello World!");
//Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx);
//Release the resources occupied by WordDocument instance
document.Close();
'Create an instance of WordDocument class
Dim document As New WordDocument()
'Add a new section into the Word document
Dim section As IWSection = document.AddSection()
'Specify the page margins
section.PageSetup.Margins.All = 50F
'Add a new simple paragraph into the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add a text range into the paragraph
paragraph.AppendText("Hello World!")
'Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx)
'Release the resources occupied by WordDocument instance
document.Close()
Stream fileStream = new FileStream("Sample.docx", FileMode.Open, FileAccess.Read, FileShare.Read);
//Load an existing Stream into WordDocument instance
WordDocument document = new WordDocument(fileStream);
//Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx);
//Release the resources occupied by WordDocument instance
document.Close();
Dim fileStream As Stream = New FileStream("Sample.docx", FileMode.Open, FileAccess.Read, FileShare.Read)
'Load an existing Stream into WordDocument instance
Dim document As New WordDocument(fileStream)
'Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx)
'Release the resources occupied by WordDocument instance
document.Close()
Stream fileStream = new FileStream("Sample.docx", FileMode.Open, FileAccess.Read, FileShare.Read);
//Load an existing Stream into WordDocument instance
WordDocument document = new WordDocument(fileStream, FormatType.Docx);
//Add a new simple paragraph into the last section of the document
IWParagraph paragraph = document.LastSection.AddParagraph();
//Add a text range into the paragraph
paragraph.AppendText("Hello World!");
//Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx);
//Release the resources occupied by WordDocument instance
document.Close();
Dim fileStream As Stream = New FileStream("Sample.docx", FileMode.Open, FileAccess.Read, FileShare.Read)
'Load an existing Stream into WordDocument instance
Dim document As New WordDocument(fileStream, FormatType.Docx)
'Add a new simple paragraph into the last section of the document
Dim paragraph As IWParagraph = document.LastSection.AddParagraph()
'Add a text range into the paragraph
paragraph.AppendText("Hello World!")
'Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx)
'Release the resources occupied by WordDocument instance
document.Close()
Stream fileStream = new FileStream("Sample.docx", FileMode.Open, FileAccess.Read, FileShare.Read);
//Load an existing Stream into WordDocument instance
WordDocument document = new WordDocument(fileStream, "password");
//Add a new simple paragraph into the last section of the document
IWParagraph paragraph = document.LastSection.AddParagraph();
//Add a text range into the paragraph
paragraph.AppendText("Hello World!");
//Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx);
//Release the resources occupied by WordDocument instance
document.Close();
Dim fileStream As Stream = New FileStream("Sample.docx", FileMode.Open, FileAccess.Read, FileShare.Read)
'Load an existing Stream into WordDocument instance
Dim document As New WordDocument(fileStream, "password")
'Add a new simple paragraph into the last section of the document
Dim paragraph As IWParagraph = document.LastSection.AddParagraph()
'Add a text range into the paragraph
paragraph.AppendText("Hello World!")
'Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx)
'Release the resources occupied by WordDocument instance
document.Close()
Stream fileStream = new FileStream("Sample.docx", FileMode.Open, FileAccess.Read, FileShare.Read);
//Load an existing Stream into WordDocument instance
WordDocument document = new WordDocument(fileStream, FormatType.Docx, "password");
//Add a new simple paragraph into the last section of the document
IWParagraph paragraph = document.LastSection.AddParagraph();
//Add a text range into the paragraph
paragraph.AppendText("Hello World!");
//Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx);
//Release the resources occupied by WordDocument instance
document.Close();
Dim fileStream As Stream = New FileStream("Sample.docx", FileMode.Open, FileAccess.Read, FileShare.Read)
'Load an existing Stream into WordDocument instance
Dim document As New WordDocument(fileStream, FormatType.Docx, "password")
'Add a new simple paragraph into the last section of the document
Dim paragraph As IWParagraph = document.LastSection.AddParagraph()
'Add a text range into the paragraph
paragraph.AppendText("Hello World!")
'Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx)
'Release the resources occupied by WordDocument instance
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Creates a new Word document.
WordDocument document = new WordDocument();
//Add a section and a paragraph in the empty document
document.EnsureMinimal();
IWParagraph paragraph = document.LastParagraph;
//Append text to the last paragraph of the document
paragraph.AppendText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua");
//Save and close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Creates a new Word document.
Dim document As New WordDocument()
'Add a section and a paragraph in the empty document
document.EnsureMinimal()
Dim paragraph As IWParagraph = document.LastParagraph
'Append text to the last paragraph of the document
paragraph.AppendText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua")
'Save and close the Word document
document.Save("Comment.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Append the text to the created paragraph
paragraph.AppendText("A new section is added to the document.");
//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 new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Append the text to the created paragraph
paragraph.AppendText("A new section is added to the document.")
'Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Create user defined style
IWParagraphStyle style = document.AddParagraphStyle("User_defined_style");
style.ParagraphFormat.BackColor = Color.LightGray;
style.ParagraphFormat.AfterSpacing = 18f;
style.ParagraphFormat.BeforeSpacing = 18f;
style.ParagraphFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.DotDash;
style.ParagraphFormat.Borders.LineWidth = 0.5f;
style.ParagraphFormat.LineSpacing = 15f;
style.CharacterFormat.FontName = "Calibri";
style.CharacterFormat.Italic = true;
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
IWTextRange text = paragraph.AppendText("A new paragraph style is created and is applied to this paragraph.");
//Apply the new style to paragraph
paragraph.ApplyStyle("User_defined_style");
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Create user defined style
Dim style As IWParagraphStyle = document.AddParagraphStyle("User_defined_style")
style.ParagraphFormat.BackColor = Color.LightGray
style.ParagraphFormat.AfterSpacing = 18.0F
style.ParagraphFormat.BeforeSpacing = 18.0F
style.ParagraphFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.DotDash
style.ParagraphFormat.Borders.LineWidth = 0.5F
style.ParagraphFormat.LineSpacing = 15.0F
style.CharacterFormat.FontName = "Calibri"
style.CharacterFormat.Italic = True
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
Dim text As IWTextRange = paragraph.AppendText("A new paragraph style is created and is applied to this paragraph.")
'Apply the new style to paragraph
paragraph.ApplyStyle("User_defined_style")
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new list style to the document
ListStyle listStyle = document.AddListStyle(ListType.Numbered, "UserdefinedList");
WListLevel levelOne = listStyle.Levels[0];
//Define the follow character, prefix, suffix, start index for level 0
levelOne.FollowCharacter = FollowCharacterType.Tab;
levelOne.NumberPrefix = "(";
levelOne.NumberSufix = ")";
levelOne.PatternType = ListPatternType.LowRoman;
levelOne.StartAt = 1;
levelOne.TabSpaceAfter = 5;
levelOne.NumberAlignment = ListNumberAlignment.Center;
WListLevel levelTwo = listStyle.Levels[1];
//Define the follow character, suffix, pattern, start index for level 1
levelTwo.FollowCharacter = FollowCharacterType.Tab;
levelTwo.NumberSufix = "}";
levelTwo.PatternType = ListPatternType.LowLetter;
levelTwo.StartAt = 2;
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add text to the paragraph
paragraph.AppendText("User defined list - Level 0");
//Apply default numbered list style
paragraph.ListFormat.ApplyStyle("UserdefinedList");
//Add second paragraph
paragraph = section.AddParagraph();
paragraph.AppendText("User defined list - Level 1");
//Continue last defined list
paragraph.ListFormat.ContinueListNumbering();
//Increase the level indent
paragraph.ListFormat.IncreaseIndentLevel();
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new list style to the document
Dim listStyle As ListStyle = document.AddListStyle(ListType.Numbered, "UserdefinedList")
Dim levelOne As WListLevel = listStyle.Levels(0)
'Define the follow character, prefix, suffix, start index for level 0
levelOne.FollowCharacter = FollowCharacterType.Tab
levelOne.NumberPrefix = "("
levelOne.NumberSufix = ")"
levelOne.PatternType = ListPatternType.LowRoman
levelOne.StartAt = 1
levelOne.TabSpaceAfter = 5
levelOne.NumberAlignment = ListNumberAlignment.Center
Dim levelTwo As WListLevel = listStyle.Levels(1)
'Define the follow character, suffix, pattern, start index for level 1
levelTwo.FollowCharacter = FollowCharacterType.Tab
levelTwo.NumberSufix = "}"
levelTwo.PatternType = ListPatternType.LowLetter
levelTwo.StartAt = 2
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add text to the paragraph
paragraph.AppendText("User defined list - Level 0")
'Apply default numbered list style
paragraph.ListFormat.ApplyStyle("UserdefinedList")
'Add second paragraph
paragraph = section.AddParagraph()
paragraph.AppendText("User defined list - Level 1")
'Continue last defined list
paragraph.ListFormat.ContinueListNumbering()
'Increase the level indent
paragraph.ListFormat.IncreaseIndentLevel()
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx");
//Get the document text and close the document
string text = document.GetText();
document.Close();
//Create new Word document
WordDocument newdocument = new WordDocument();
//Add new section
IWSection section = newdocument.AddSection();
//Add new paragraph
IWParagraph paragraph = section.AddParagraph();
//Append the text to the paragraph
paragraph.AppendText(text);
//Save and close the document
newdocument.Save("Sample.docx");
newdocument.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx")
'Get the document text and close the document
Dim text As String = document.GetText()
document.Close()
'Create new Word document
Dim newdocument As New WordDocument()
'Add new section
Dim section As IWSection = newdocument.AddSection()
'Add new paragraph
Dim paragraph As IWParagraph = section.AddParagraph()
'Append the text to the paragraph
paragraph.AppendText(text)
'Save and close the document
newdocument.Save("Sample.docx")
newdocument.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Open an existing document
WordDocument inputTemplateDoc = new WordDocument("Template.docx");
//Create a clone of Input Template
WordDocument clonedDocument = inputTemplateDoc.Clone();
//Close the input template document instance
inputTemplateDoc.Close();
//Save and Close the cloned document instance
clonedDocument.Save("ClonedDocument.docx");
clonedDocument.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Open an existing document
Dim inputTemplateDoc As New WordDocument(fileName)
'Create a clone of Input Template
Dim clonedDocument As WordDocument = inputTemplateDoc.Clone()
'Close the input template document instance
inputTemplateDoc.Close()
'Save and Close the cloned document instance
clonedDocument.Save("ClonedDocument.docx")
clonedDocument.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Open the source document
WordDocument sourceDocument = new WordDocument("sourceFileName.docx");
//Open the destination document
WordDocument destinationDocument = new WordDocument("targetFileName.docx");
//Import the last section of source document at the end of destination document
destinationDocument.ImportSection(sourceDocument.LastSection);
//Close the document instance
sourceDocument.Close();
//Save the destination document
destinationDocument.Save("outputFileName.docx", FormatType.Docx);
//Close the document instance
destinationDocument.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Open the source document
Dim sourceDocument As New WordDocument(sourceFileName)
'Open the destination document
Dim destinationDocument As New WordDocument(targetFileName)
'Import the last section of source document at the end of destination document
destinationDocument.ImportSection(sourceDocument.LastSection)
'Close the document instance
sourceDocument.Close()
'Save the destination document
destinationDocument.Save(outputFileName, FormatType.Docx)
'Close the document instance
destinationDocument.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Open the source document
WordDocument sourceDocument = new WordDocument("sourceFileName.docx");
//Open the destination document
WordDocument destinationDocument = new WordDocument("targetFileName.docx");
//Import the contents of source document at the end of destination document
destinationDocument.ImportContent(sourceDocument);
//Close the document instance
sourceDocument.Close();
//Save the destination document
destinationDocument.Save("outputFileName.docx", FormatType.Docx);
//Close the document instance
destinationDocument.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Open the source document
Dim sourceDocument As New WordDocument(sourceFileName)
'Open the destination document
Dim destinationDocument As New WordDocument(targetFileName)
'Import the contents of source document at the end of destination document
destinationDocument.ImportContent(sourceDocument)
'Close the document instance
sourceDocument.Close()
'Save the destination document
destinationDocument.Save(outputFileName, FormatType.Docx)
'Close the document instance
destinationDocument.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Open the source document
WordDocument sourceDocument = new WordDocument("sourceFileName.docx");
//Open the destination document
WordDocument destinationDocument = new WordDocument("targetFileName.docx");
//Import the contents of source document at the end of destination document
destinationDocument.ImportContent(sourceDocument, ImportOptions.UseDestinationStyles);
//Close the document instance
sourceDocument.Close();
//Save the destination document
destinationDocument.Save("outputFileName.docx", FormatType.Docx);
//Close the document instance
destinationDocument.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Open the source document
Dim sourceDocument As New WordDocument(sourceFileName)
'Open the destination document
Dim destinationDocument As New WordDocument(targetFileName)
'Import the contents of source document at the end of destination document
destinationDocument.ImportContent(sourceDocument, ImportOptions.UseDestinationStyles)
'Close the document instance
sourceDocument.Close()
'Save the destination document
destinationDocument.Save(outputFileName, FormatType.Docx)
'Close the document instance
destinationDocument.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Open the source document
WordDocument sourceDocument = new WordDocument("sourceFileName.docx");
//Open the destination document
WordDocument destinationDocument = new WordDocument("targetFileName.docx");
//Import the contents of source document at the end of destination document
destinationDocument.ImportContent(sourceDocument, true);
//Close the document instance
sourceDocument.Close();
//Save the destination document
destinationDocument.Save("outputFileName.docx", FormatType.Docx);
//Close the document instance
destinationDocument.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Open the source document
Dim sourceDocument As New WordDocument(sourceFileName)
'Open the destination document
Dim destinationDocument As New WordDocument(targetFileName)
'Import the contents of source document at the end of destination document
destinationDocument.ImportContent(sourceDocument, true)
'Close the document instance
sourceDocument.Close()
'Save the destination document
destinationDocument.Save(outputFileName, FormatType.Docx)
'Close the document instance
destinationDocument.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Add the built-in style to the document style collection
IStyle style = document.AddStyle(BuiltinStyle.Heading5);
//Apply the added built-in style to the last paragraph of the document
document.LastParagraph.ApplyStyle(style.Name);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Add the built-in style to the document style collection
Dim style As IStyle = document.AddStyle(BuiltinStyle.Heading5)
'Apply the added built-in style to the last paragraph of the document
document.LastParagraph.ApplyStyle(style.Name)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Check whether document has tracked changes
if (document.HasChanges)
//Accept the changes made to the document
document.AcceptChanges();
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Check whether document has tracked changes
If document.HasChanges Then
'Accept the changes made to the document
document.AcceptChanges()
End If
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Check whether document has tracked changes
if (document.HasChanges)
//Reject the changes made to the document
document.RejectChanges();
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Check whether document has tracked changes
If document.HasChanges Then
'Reject the changes made to the document
document.RejectChanges()
End If
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Apply the protection to the document
document.Protect(ProtectionType.AllowOnlyComments);
//Save and close the document instances
document.Save("Sample.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Apply the protection to the document
document.Protect(ProtectionType.AllowOnlyComments)
'Save and close the document instances
document.Save("Sample.docx")
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx", "password");
//Apply the protection to the document
document.Protect(ProtectionType.AllowOnlyComments);
//Save and close the document instances
document.Save("Sample.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Apply the protection to the document
document.Protect(ProtectionType.AllowOnlyComments, "password")
'Save and close the document instances
document.Save("Sample.docx")
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Open an input Word document
WordDocument document = new WordDocument("Template.docx");
//Encrypt the Word document with a password
document.EncryptDocument("password");
//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)
'Open an input Word document
Dim document As New WordDocument("Template.docx")
'Encrypt the Word document with a password
document.EncryptDocument("password")
'Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Open an input Word document
WordDocument document = new WordDocument("Template.docx");
//Remove the encryption from document
document.RemoveEncryption();
//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)
'Open an input Word document
Dim document As New WordDocument("Template.docx")
'Remove the encryption from document
document.RemoveEncryption();
'Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Get the collection of bookmark start in the word document
List< Entity > items = document.GetCrossReferenceItems(ReferenceType.Bookmark);
if (items.Count > 0)
//Change the first cross reference items owner paragraph back color as YelloGreen
(items[0] as BookmarkStart).OwnerParagraph.ParagraphFormat.BackColor = Color.YellowGreen;
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Get the collection of bookmark start in the word document
Dim items As List(Of Entity) = document.GetCrossReferenceItems(ReferenceType.Bookmark)
If items.Count > 0 Then
'Change the first cross reference items owner paragraph back color as YelloGreen
TryCast(items(0), BookmarkStart).OwnerParagraph.ParagraphFormat.BackColor = Color.YellowGreen
End If
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Save the document as Text file
document.SaveTxt("sample.txt", Encoding.ASCII);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Save the document as Text file
document.SaveTxt("sample.txt", Encoding.ASCII)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
MemoryStream stream = new MemoryStream();
//Save the document as Text file
document.SaveTxt(stream, Encoding.ASCII);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
Dim stream As New MemoryStream()
'Save the document as Text file
document.SaveTxt(stream, Encoding.ASCII)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an new instance of WordDocument class
WordDocument document = new WordDocument();
//Open an existing document from file system
document.Open("Template.docx");
//Saves the specified document
document.Save("Sample.docx");
//Close the WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an new instance of WordDocument class
Dim document As New WordDocument()
'Open an existing document from file system
document.Open("Template.docx")
'Saves the specified document
document.Save("Sample.docx")
'Close the WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an new instance of WordDocument class
WordDocument document = new WordDocument();
//Open an existing document from file system
document.Open("Template.docx", FormatType.Docx);
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an new instance of WordDocument class
Dim document As New WordDocument()
'Open an existing document from file system
document.Open("Template.docx", FormatType.Docx)
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an new instance of WordDocument class
WordDocument document = new WordDocument();
//Open an existing document from file system
document.Open("Template.docx", FormatType.Docx, XHTMLValidationType.Strict, "basePath");
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an new instance of WordDocument class
Dim document As New WordDocument()
'Open an existing document from file system
document.Open("Template.docx", FormatType.Docx, "password", XHTMLValidationType.Strict, basePath)
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an new instance of WordDocument class
WordDocument document = new WordDocument();
//Open an existing document from file system
document.Open("Template.docx", FormatType.Docx, XHTMLValidationType.Strict);
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an new instance of WordDocument class
Dim document As New WordDocument()
'Open an existing document from file system
document.Open("Template.docx", FormatType.Docx, "password", XHTMLValidationType.Strict)
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an new instance of WordDocument class
WordDocument document = new WordDocument();
//Open an existing document from file system
document.Open("Template.docx", FormatType.Docx, "password");
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an new instance of WordDocument class
Dim document As New WordDocument()
'Open an existing document from file system
document.Open("Template.docx", FormatType.Docx, "password")
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
End Sub
//Create a new instance of WordDocument class
WordDocument document = new WordDocument();
//Open an existing document from file system
document.OpenReadOnly("Template.docx", FormatType.Docx, "password");
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
'Create a new instance of WordDocument class
Dim document As New WordDocument()
'Open an existing document from file system
document.OpenReadOnly("Template.docx", FormatType.Docx, "password")
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
//Create a new instance of WordDocument class
WordDocument document = new WordDocument();
//Open an existing document from file system
document.OpenReadOnly("Template.docx", FormatType.Docx, XHTMLValidationType.Strict);
//Saves the specified document
document.Save("Sample.Docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
'Create a new instance of WordDocument class
Dim document As New WordDocument()
'Open an existing document from file system
document.OpenReadOnly("Template.docx", FormatType.Docx, XHTMLValidationType.Strict)
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
//Create a new instance of WordDocument class
WordDocument document = new WordDocument();
//Open an existing document from file system
document.OpenReadOnly("Template.docx", FormatType.Docx, XHTMLValidationType.Strict, "basePath");
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
'Create a new instance of WordDocument class
Dim document As New WordDocument()
'Open an existing document from file system
document.OpenReadOnly("Template.docx", FormatType.Docx, XHTMLValidationType.Strict, basePath)
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an new instance of WordDocument class
WordDocument document = new WordDocument();
//Open an existing document from file system
document.Open("Template.docx");
//Saves the specified document
document.Save("Sample.docx");
//Close the WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an new instance of WordDocument class
Dim document As New WordDocument()
'Open an existing document from file system
document.Open("Template.docx")
'Saves the specified document
document.Save("Sample.docx")
'Close the WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an new instance of WordDocument class
WordDocument document = new WordDocument();
//Open an existing document from file system
document.Open("Template.docx");
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an new instance of WordDocument class
Dim document As New WordDocument()
'Open an existing document from file system
document.Open("Template.docx")
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
MemoryStream stream = new MemoryStream();
//Create the new WPicture for cover page image
WPicture coverImage = new WPicture(document);
coverImage.LoadImage(Image.FromFile("CoverImage.png"));
//Save the document as EPUB
document.SaveAsEpub("sample.epub", coverImage);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
Dim stream As New MemoryStream()
'Create the new WPicture for cover page image
Dim coverImage As New WPicture(document)
coverImage.LoadImage(Image.FromFile("CoverImage.png"))
'Save the document as EPUB
document.SaveAsEpub("sample.epub", coverImage)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an new instance of WordDocument class
WordDocument document = new WordDocument();
//Open an existing document from file system
document.Open("Template.docx");
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx,HttpContext.Current.Response, HttpContentDisposition.Attachment);
//Close the WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an new instance of WordDocument class
Dim document As New WordDocument()
'Open an existing document from file system
document.Open("Template.docx")
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx, Response, HttpContentDisposition.Attachment)
'Close the WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
MemoryStream stream = new MemoryStream();
//Create the new WPicture for cover page image
WPicture coverImage = new WPicture(document);
coverImage.LoadImage(Image.FromFile("CoverImage.png"));
//Save the document as EPUB
document.SaveAsEpub("sample.epub", coverImage, HttpContext.Current.Response, HttpContentDisposition.Attachment);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
Dim stream As New MemoryStream()
'Create the new WPicture for cover page image
Dim coverImage As New WPicture(document)
coverImage.LoadImage(Image.FromFile("CoverImage.png"))
'Save the document as EPUB
document.SaveAsEpub("sample.epub", coverImage, Response, HttpContentDisposition.Attachment)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an new instance of WordDocument class
WordDocument document = new WordDocument();
Stream fileStream = new FileStream("Sample.html", FileMode.Open, FileAccess.Read, FileShare.Read);
//Open an existing document from file system
document.Open(fileStream, FormatType.Docx, XHTMLValidationType.Strict, "basepath");
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an new instance of WordDocument class
Dim document As New WordDocument()
Dim fileStream As Stream = New FileStream("Sample.html", FileMode.Open, FileAccess.Read, FileShare.Read)
'Open an existing document from file system
document.Open(fileStream, FormatType.Docx, XHTMLValidationType.Strict, basepath)
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an new instance of WordDocument class
WordDocument document = new WordDocument();
Stream fileStream = new FileStream("Sample.html", FileMode.Open, FileAccess.Read, FileShare.Read);
//Open an existing document from file system
document.Open(fileStream, FormatType.Docx, XHTMLValidationType.Strict);
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an new instance of WordDocument class
Dim document As New WordDocument()
Dim fileStream As Stream = New FileStream("Sample.html", FileMode.Open, FileAccess.Read, FileShare.Read)
'Open an existing document from file system
document.Open(fileStream, FormatType.Docx, XHTMLValidationType.Strict)
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an new instance of WordDocument class
WordDocument document = new WordDocument();
Stream fileStream = new FileStream("Sample.docx", FileMode.Open, FileAccess.Read, FileShare.Read);
//Open an existing document from file system
document.Open(fileStream, FormatType.Docx);
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an new instance of WordDocument class
Dim document As New WordDocument()
Dim fileStream As Stream = New FileStream("Sample.docx", FileMode.Open, FileAccess.Read, FileShare.Read)
'Open an existing document from file system
document.Open(fileStream, FormatType.Docx)
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an new instance of WordDocument class
WordDocument document = new WordDocument();
Stream fileStream = new FileStream("Sample.docx", FileMode.Open, FileAccess.Read, FileShare.Read);
//Open an existing document from file system
document.Open(fileStream, FormatType.Docx, "password");
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an new instance of WordDocument class
Dim document As New WordDocument()
Dim fileStream As Stream = New FileStream("Sample.docx", FileMode.Open, FileAccess.Read, FileShare.Read)
'Open an existing document from file system
document.Open(fileStream, FormatType.Docx, "password")
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
MemoryStream stream = new MemoryStream();
//Save the document to stream
document.Save(stream, FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
Dim stream As New MemoryStream()
'Save the document to stream
document.Save(stream, FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument wordDocument = new WordDocument("Template.docx", FormatType.Docx);
//Initialize ChartToImageConverter for converting charts during Word to image conversion
wordDocument.ChartToImageConverter = new ChartToImageConverter();
//Set the scaling mode for charts (Normal mode reduces the file size)
wordDocument.ChartToImageConverter.ScalingMode = ScalingMode.Normal;
//Convert word document to image
Image[] images = wordDocument.RenderAsImages(ImageType.Bitmap);
//Close the document
wordDocument.Close();
int i = 0;
foreach (Image image in images)
{
//Save the images as jpeg
image.Save("WordToImage_" + i + ".jpeg", ImageFormat.Jpeg);
i++;
}
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim wordDocument As New WordDocument("Template.docx", FormatType.Docx)
'Initialize ChartToImageConverter for converting charts during Word to image conversion
wordDocument.ChartToImageConverter = New ChartToImageConverter()
'Set the scaling mode for charts (Normal mode reduces the file size)
wordDocument.ChartToImageConverter.ScalingMode = ScalingMode.Normal
'Convert word document to image
Dim images As Image() = wordDocument.RenderAsImages(ImageType.Bitmap)
'Close the document
wordDocument.Close()
Dim i As Integer = 0
For Each image As Image In images
'Save the images as jpeg
image.Save("WordToImage_" & i & ".jpeg", ImageFormat.Jpeg)
i += 1
Next
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument wordDocument = new WordDocument("Template.docx", FormatType.Docx);
//Initialize ChartToImageConverter for converting charts during Word to image conversion
wordDocument.ChartToImageConverter = new ChartToImageConverter();
//Set the scaling mode for charts (Normal mode reduces the file size)
wordDocument.ChartToImageConverter.ScalingMode = ScalingMode.Normal;
//Convert word document to stream
Stream imageStream = wordDocument.RenderAsImages(2, System.Drawing.Imaging.ImageFormat.Bmp);
//Close the document
wordDocument.Close();
//Convert the stream to Image
Image image = Image.FromStream(imageStream);
//Save the image as jpeg
image.Save("WordToImage.jpeg", ImageFormat.Jpeg);
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim wordDocument As New WordDocument("Template.docx", FormatType.Docx)
'Initialize ChartToImageConverter for converting charts during Word to image conversion
wordDocument.ChartToImageConverter = New ChartToImageConverter()
'Set the scaling mode for charts (Normal mode reduces the file size)
wordDocument.ChartToImageConverter.ScalingMode = ScalingMode.Normal
'Convert word document to stream
Dim imageStream As Stream = wordDocument.RenderAsImages(2, System.Drawing.Imaging.ImageFormat.Bmp)
'Close the document
wordDocument.Close()
'Convert the stream to Image
Dim image As Image = Image.FromStream(imageStream)
'Save the image as jpeg
image.Save("WordToImage.jpeg", ImageFormat.Jpeg)
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument wordDocument = new WordDocument("Template.docx", FormatType.Docx);
//Initialize ChartToImageConverter for converting charts during Word to image conversion
wordDocument.ChartToImageConverter = new ChartToImageConverter();
//Set the scaling mode for charts (Normal mode reduces the file size)
wordDocument.ChartToImageConverter.ScalingMode = ScalingMode.Normal;
//Convert word document to image
Image image = wordDocument.RenderAsImages(2, ImageType.Bitmap);
//Close the document
wordDocument.Close();
//Save the image
image.Save("WordToImage.jpeg", ImageFormat.Jpeg);
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim wordDocument As New WordDocument("Template.docx", FormatType.Docx)
'Initialize ChartToImageConverter for converting charts during Word to image conversion
wordDocument.ChartToImageConverter = New ChartToImageConverter()
'Set the scaling mode for charts (Normal mode reduces the file size)
wordDocument.ChartToImageConverter.ScalingMode = ScalingMode.Normal
'Convert word document to image
Dim image As Image = wordDocument.RenderAsImages(2, ImageType.Bitmap)
'Close the document
wordDocument.Close()
'Save the images as jpeg
image.Save("WordToImage_" & i & ".jpeg", ImageFormat.Jpeg)
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument wordDocument = new WordDocument("Template.docx", FormatType.Docx);
//Initialize ChartToImageConverter for converting charts during Word to image conversion
wordDocument.ChartToImageConverter = new ChartToImageConverter();
//Set the scaling mode for charts (Normal mode reduces the file size)
wordDocument.ChartToImageConverter.ScalingMode = ScalingMode.Normal;
//Convert word document to image
Image[] images = wordDocument.RenderAsImages(0, 2, ImageType.Bitmap);
//Close the document
wordDocument.Close();
int i = 0;
foreach (Image image in images)
{
//Save the images as jpeg
image.Save("WordToImage_" + i + ".jpeg", ImageFormat.Jpeg);
i++;
}
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim wordDocument As New WordDocument("Template.docx", FormatType.Docx)
'Initialize ChartToImageConverter for converting charts during Word to image conversion
wordDocument.ChartToImageConverter = New ChartToImageConverter()
'Set the scaling mode for charts (Normal mode reduces the file size)
wordDocument.ChartToImageConverter.ScalingMode = ScalingMode.Normal
'Convert word document to image
Dim images As Image() = wordDocument.RenderAsImages(0, 2, ImageType.Bitmap)
'Close the document
wordDocument.Close()
Dim i As Integer = 0
For Each image As Image In images
'Save the images as jpeg
image.Save("WordToImage_" & i & ".jpeg", ImageFormat.Jpeg)
i += 1
Next
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Find the first occurrence of a particular text in the document
TextSelection textSelection = document.Find(new Regex("panda"));
//Get the found text as single text range
WTextRange textRange = textSelection.GetAsOneRange();
//Modify the text
textRange.Text = "Replaced text";
//Set highlight color
textRange.CharacterFormat.HighlightColor = Color.Yellow;
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Find the first occurrence of a particular text in the document
Dim textSelection As TextSelection = document.Find(New Regex("panda"))
'Get the found text as single text range
Dim textRange As WTextRange = textSelection.GetAsOneRange()
'Modify the text
textRange.Text = "Replaced text"
'Set highlight color
textRange.CharacterFormat.HighlightColor = Color.Yellow
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Find the first occurrence of a particular text extended to several paragraphs in the document
TextSelection[] textSelections = document.FindSingleLine(new Regex("First paragraph Second paragraph"));
WParagraph paragraph = null;
foreach (TextSelection textSelection in textSelections)
{
//Get the found text as single text range and set highlight color
WTextRange textRange = textSelection.GetAsOneRange();
textRange.CharacterFormat.HighlightColor = Color.YellowGreen;
paragraph = textRange.OwnerParagraph;
}
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Find the first occurrence of a particular text extended to several paragraphs in the document
Dim textSelections As TextSelection() = document.FindSingleLine(new Regex("First paragraph Second paragraph"))
Dim paragraph As WParagraph = Nothing
For Each textSelection As TextSelection In textSelections
'Get the found text as single text range and set highlight color
Dim textRange As WTextRange = textSelection.GetAsOneRange()
textRange.CharacterFormat.HighlightColor = Color.YellowGreen
paragraph = textRange.OwnerParagraph
Next
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Find the first occurrence of a particular text in the document
TextSelection textSelection = document.Find("panda", true, true);
//Get the found text as single text range
WTextRange textRange = textSelection.GetAsOneRange();
//Modify the text
textRange.Text = "Replaced text";
//Set highlight color
textRange.CharacterFormat.HighlightColor = Color.Yellow;
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Find the first occurrence of a particular text in the document
Dim textSelection As TextSelection = document.Find("panda", true, true)
'Get the found text as single text range
Dim textRange As WTextRange = textSelection.GetAsOneRange()
'Modify the text
textRange.Text = "Replaced text"
'Set highlight color
textRange.CharacterFormat.HighlightColor = Color.Yellow
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Find the first occurrence of a particular text extended to several paragraphs in the document
TextSelection[] textSelections = document.FindSingleLine("First paragraph Second paragraph", true, false);
WParagraph paragraph = null;
foreach (TextSelection textSelection in textSelections)
{
//Get the found text as single text range and set highlight color
WTextRange textRange = textSelection.GetAsOneRange();
textRange.CharacterFormat.HighlightColor = Color.YellowGreen;
paragraph = textRange.OwnerParagraph;
}
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Find the first occurrence of a particular text extended to several paragraphs in the document
Dim textSelections As TextSelection() = document.FindSingleLine("First paragraph Second paragraph", True, False)
Dim paragraph As WParagraph = Nothing
For Each textSelection As TextSelection In textSelections
'Get the found text as single text range and set highlight color
Dim textRange As WTextRange = textSelection.GetAsOneRange()
textRange.CharacterFormat.HighlightColor = Color.YellowGreen
paragraph = textRange.OwnerParagraph
Next
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Find the occurrence of the Word "panda" in the document
TextSelection[] textSelection = document.FindAll(new Regex("panda"));
//Iterate through each occurrence and highlight it
foreach (TextSelection selection in textSelection)
{
IWTextRange textRange = selection.GetAsOneRange();
textRange.CharacterFormat.HighlightColor = Color.Yellow;
}
//Save and Close the document
document.Save("Result.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Find the occurrence of the word "panda" in the document
Dim textSelection As TextSelection() = document.FindAll(new Regex("panda"))
'Iterate through each occurrence and highlight it
For Each selection As TextSelection In textSelection
Dim textRange As IWTextRange = selection.GetAsOneRange()
textRange.CharacterFormat.HighlightColor = Color.Yellow
Next
document.Save("Result.docx")
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Find the occurrence of the Word "panda" in the document
TextSelection[] textSelection = document.FindAll("panda", false, true);
//Iterate through each occurrence and highlight it
foreach (TextSelection selection in textSelection)
{
IWTextRange textRange = selection.GetAsOneRange();
textRange.CharacterFormat.HighlightColor = Color.Yellow;
}
//Save and Close the document
document.Save("Result.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Find the occurrence of the word "panda" in the document
Dim textSelection As TextSelection() = document.FindAll("panda", false, true)
'Iterate through each occurrence and highlight it
For Each selection As TextSelection In textSelection
Dim textRange As IWTextRange = selection.GetAsOneRange()
textRange.CharacterFormat.HighlightColor = Color.Yellow
Next
document.Save("Result.docx")
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Replace all occurrence of a particular text in the document
document.Replace(new Regex("Paragraph"),"paragraph");
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
'Replace all occurrence of a particular text in the document
document.Replace(New Regex("Paragraph"), "paragraph")
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Replace all occurrence of a particular text in the document
document.Replace("Paragraph","paragraph", false, true);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
'Replace all occurrence of a particular text in the document
document.Replace("Paragraph", "paragraph", False, True)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Find the first occurrence of the regular expression
TextSelection selection = document.Find(new Regex("Panda"));
//Replace all occurrence of a particular regular expression with the text selection in the document
document.Replace("Giant panda", selection, true, false);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
'Find the first occurrence of the regular expression
Dim selection As TextSelection = document.Find(New Regex("Panda"))
'Replace all occurrence of a particular regular expression with the text selection in the document
document.Replace("Giant panda", selection, True, False)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Find the first occurrence of the regular expression
TextSelection selection = document.Find(new Regex("Panda"));
//Replace all occurrence of a particular regular expression with the text selection in the document
document.Replace("Giant panda", selection, true, false, true);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
'Find the first occurrence of the regular expression
Dim selection As TextSelection = document.Find(New Regex("Panda"))
'Replace all occurrence of a particular regular expression with the text selection in the document
document.Replace("Giant panda", selection, True, False, False)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Find the first occurrence of the regular expression
TextSelection selection = document.Find(new Regex("Panda"));
//Replace all occurrence of a particular regular expression with the text selection in the document
document.Replace(new Regex("Giant panda"), selection);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
'Find the first occurrence of the regular expression
Dim selection As TextSelection = document.Find(New Regex("Panda"))
'Replace all occurrence of a particular regular expression with the text selection in the document
document.Replace(New Regex("Giant panda"), selection)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Find the first occurrence of the regular expression
TextSelection selection = document.Find(new Regex("Panda"));
//Replace all occurrence of a particular regular expression with the text selection in the document
document.Replace(new Regex("Giant panda"), selection, true);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
'Find the first occurrence of the regular expression
Dim selection As TextSelection = document.Find(New Regex("Panda"))
'Replace all occurrence of a particular regular expression with the text selection in the document
document.Replace(New Regex("Giant panda"), selection, True)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Find the first occurrence of the regular expression
TextSelection selection = document.Find(new Regex("Panda"));
//Initialize text body part
TextBodyPart bodyPart = new TextBodyPart(selection);
//Replace a particular text with the text body part
document.Replace("Giant panda", bodyPart, true, false);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
'Find the first occurrence of the regular expression
Dim selection As TextSelection = document.Find(New Regex("Panda"))
'Initialize text body part
Dim bodyPart As New TextBodyPart(selection)
'Replace a particular text with the text body part
document.Replace("Giant panda", bodyPart, True, False)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Find the first occurrence of the regular expression
TextSelection selection = document.Find(new Regex("Panda"));
//Initialize text body part
TextBodyPart bodyPart = new TextBodyPart(selection);
//Replace a particular text with the text body part
document.Replace("Giant panda", bodyPart, true, false, true);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
'Find the first occurrence of the regular expression
Dim selection As TextSelection = document.Find(New Regex("Panda"))
'Initialize text body part
Dim bodyPart As New TextBodyPart(selection)
'Replace a particular text with the text body part
document.Replace("Giant panda", bodyPart, True, False, True)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Find the first occurrence of the regular expression
TextSelection selection = document.Find(new Regex("Panda"));
//Initialize text body part
TextBodyPart bodyPart = new TextBodyPart(selection);
//Replace a particular text with the text body part
document.Replace(new Regex("Giant panda"), bodyPart);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
'Find the first occurrence of the regular expression
Dim selection As TextSelection = document.Find(New Regex("Panda"))
'Initialize text body part
Dim bodyPart As New TextBodyPart(selection)
'Replace a particular text with the text body part
document.Replace(New Regex("Giant panda"), bodyPart)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Find the first occurrence of the regular expression
TextSelection selection = document.Find(new Regex("Panda"));
//Initialize text body part
TextBodyPart bodyPart = new TextBodyPart(selection);
//Replace a particular text with the text body part
document.Replace(new Regex("Giant panda"), bodyPart, true);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
'Find the first occurrence of the regular expression
Dim selection As TextSelection = document.Find(New Regex("Panda"))
'Initialize text body part
Dim bodyPart As New TextBodyPart(selection)
'Replace a particular text with the text body part
document.Replace(New Regex("Giant panda"), bodyPart, True)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Load the another existing Word document to replace
WordDocument replaceDocument = new WordDocument("Replace.docx");
//Replace all occurrence of a particular regular expression with the another document and close the document
document.Replace("Giant panda", replaceDocument, true, false);
replaceDocument.Close();
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
'Load the another existing Word document to replace
Dim replaceDocument As New WordDocument("Replace.docx")
'Replace all occurrence of a particular regular expression with the another document and close the document
document.Replace("Giant panda", replaceDocument, True, False)
replaceDocument.Close();
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Load the another existing Word document to replace
WordDocument replaceDocument = new WordDocument("Replace.docx");
//Replace all occurrence of a particular regular expression with the another document and close the document
document.Replace("Giant panda", replaceDocument, true, false, true);
replaceDocument.Close();
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
'Load the another existing Word document to replace
Dim replaceDocument As New WordDocument("Replace.docx")
'Replace all occurrence of a particular regular expression with the another document and close the document
document.Replace("Giant panda", replaceDocument, True, False, True)
replaceDocument.Close();
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
//Load the another existing Word document to replace
WordDocument replaceDocument = new WordDocument("Replace.docx");
//Replace all occurrence of a particular regular expression with the another document and close the document
document.Replace(new Regex("Giant panda"), replaceDocument, true);
replaceDocument.Close();
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
'Load the another existing Word document to replace
Dim replaceDocument As New WordDocument("Replace.docx")
'Replace all occurrence of a particular regular expression with the another document and close the document
document.Replace(New Regex("Giant panda"), replaceDocument, True)
replaceDocument.Close();
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
//Open an input word template
WordDocument document = new WordDocument(@"Template.docx", FormatType.Automatic);
//Update the Paragraphs count, Word count and Character count in the document
document.UpdateWordCount();
//Save and close the Word document instance.
document.Save("Output.docx", FormatType.Docx);
document.Close();
}
'Open an input word template
Dim document As New WordDocument("Template.docx", FormatType.Automatic)
'Update the Paragraphs count, Word count and Character count in the document.
document.UpdateWordCount()
'Save and close the Word document instance.
document.Save("Output.docx", FormatType.Docx)
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Open an input word template
WordDocument document = new WordDocument(@"Template.docx");
//Update the Page count, Paragraphs count, Word count and Character count in the document
document.UpdateWordCount(true);
//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)
'Open an input word template
Dim document As New WordDocument("Template.docx")
'Update the Page count, Paragraphs count, Word count and Character count in the document.
document.UpdateWordCount(True)
'Save and close the Word document instance.
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Input.docx", FormatType.Docx);
//Updates the fields present in a document.
document.UpdateDocumentFields();
document.Save("Result.docx", FormatType.Docx);
document.Close();
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Input.docx", FormatType.Docx)
'Updates the fields present in a document.
document.UpdateDocumentFields()
document.Save("Result.docx", FormatType.Docx)
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Input.docx", FormatType.Docx);
//Updates the Alternate chunks present in a document.
document.UpdateAlternateChunks();
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Input.docx", FormatType.Docx)
'Updates the Alternate chunks present in a document.
document.UpdateAlternateChunks()
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
//Open an input word template
WordDocument document = new WordDocument(@"Template.docx");
//Update the table of contents.
document.UpdateTableOfContents();
//Save and close the Word document instance.
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Open an input word template
Dim document As New WordDocument("Template.docx")
'Update the table of contents.
document.UpdateTableOfContents()
'Save and close the Word document instance.
document.Save("Sample.docx", FormatType.Docx)
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Replace the text extended to two paragraphs with simple text
document.ReplaceSingleLine("First paragraph Second paragraph", "Replaced paragraph", true, false);
//Save and close the document
document.Save("Replace.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Replace the text extended to two paragraphs with simple text
document.ReplaceSingleLine("First paragraph Second paragraph", "Replaced paragraph", True, False)
'Save and close the document
document.Save("Replace.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Replace the text extended to two paragraphs with simple text
document.ReplaceSingleLine(new Regex("First paragraph Second paragraph"), "Replaced paragraph");
//Save and close the document
document.Save("Replace.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Replace the text extended to two paragraphs with simple text
document.ReplaceSingleLine(New Regex("First paragraph Second paragraph"), "Replaced paragraph")
'Save and close the document
document.Save("Replace.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Find the first occurrence of a particular text in the document
TextSelection selection = document.Find("contents", false, false);
//Replace the text extended to two paragraphs with text selection
document.ReplaceSingleLine("First paragraph Second paragraph", selection, true, false);
//Save and close the document
document.Save("Replace.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Find the first occurrence of a particular text in the document
Dim selection As TextSelection = document.Find("contents", False, False)
'Replace the text extended to two paragraphs with text selection
document.ReplaceSingleLine("First paragraph Second paragraph", selection, True, False)
'Save and close the document
document.Save("Replace.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Find the first occurrence of a particular text in the document
TextSelection selection = document.Find("contents", false, false);
//Replace the text extended to two paragraphs with text selection
document.ReplaceSingleLine(new Regex("First paragraph Second paragraph"), selection);
//Save and close the document
document.Save("Replace.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Find the first occurrence of a particular text in the document
Dim selection As TextSelection = document.Find("contents", False, False)
'Replace the text extended to two paragraphs with text selection
document.ReplaceSingleLine(New Regex("First paragraph Second paragraph"), selection)
'Save and close the document
document.Save("Replace.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Find the first occurrence of a particular text in the document
TextSelection selection = document.Find("contents", false, false);
//Initialize text body part
TextBodyPart bodyPart = new TextBodyPart(selection);
//Replace a particular text with the text body part
document.ReplaceSingleLine("First paragraph Second paragraph", bodyPart, true, false);
//Save and close the document
document.Save("Replace.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Find the first occurrence of a particular text in the document
Dim selection As TextSelection = document.Find("contents", False, False)
'Initialize text body part
Dim bodyPart As New TextBodyPart(selection)
'Replace a particular text with the text body part
document.ReplaceSingleLine("First paragraph Second paragraph", bodyPart, True, False)
'Save and close the document
document.Save("Replace.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Find the first occurrence of a particular text in the document
TextSelection selection = document.Find("contents", false, false);
//Initialize text body part
TextBodyPart bodyPart = new TextBodyPart(selection);
//Replace a particular text with the text body part
document.ReplaceSingleLine(new Regex("First paragraph Second paragraph"), bodyPart);
//Save and close the document
document.Save("Replace.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Find the first occurrence of a particular text in the document
Dim selection As TextSelection = document.Find("contents", False, False)
'Initialize text body part
Dim bodyPart As New TextBodyPart(selection)
'Replace a particular text with the text body part
document.ReplaceSingleLine(New Regex("First paragraph Second paragraph"), bodyPart)
'Save and close the document
document.Save("Replace.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Find the first occurrence of a particular text in the document
TextSelection textSelection = document.Find("as graphical contents", false, true);
//Get the found text as single text range
WTextRange textRange = textSelection.GetAsOneRange();
//Modify the text
textRange.Text = "Replaced text";
//Set highlight color
textRange.CharacterFormat.HighlightColor = Color.Yellow;
//Find the next occurrence of a particular text from the previous paragraph
textSelection = document.FindNext(textRange.OwnerParagraph, "paragraph", true, false);
//Get the found text as single text range
WTextRange range = textSelection.GetAsOneRange();
//Set bold formatting
range.CharacterFormat.Bold = true;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Find the first occurrence of a particular text in the document
Dim textSelection As TextSelection = document.Find("as graphical contents", false, true)
'Get the found text as single text range
Dim textRange As WTextRange = textSelection.GetAsOneRange()
'Modify the text
textRange.Text = "Replaced text"
'Set highlight color
textRange.CharacterFormat.HighlightColor = Color.Yellow
'Find the next occurrence of a particular text from the previous paragraph
textSelection = document.FindNext(textRange.OwnerParagraph, "paragraph", true, false)
'Get the found text as single text range
Dim range As WTextRange = textSelection.GetAsOneRange()
'Set bold formatting
range.CharacterFormat.Bold = True
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Find the first occurrence of a particular text in the document
TextSelection textSelection = document.Find(new Regex("as graphical contents"));
//Get the found text as single text range
WTextRange textRange = textSelection.GetAsOneRange();
//Modify the text
textRange.Text = "Replaced text";
//Set highlight color
textRange.CharacterFormat.HighlightColor = Color.Yellow;
//Find the next occurrence of a particular text from the previous paragraph
textSelection = document.FindNext(textRange.OwnerParagraph, new Regex("paragraph"));
//Get the found text as single text range
WTextRange range = textSelection.GetAsOneRange();
//Set bold formatting
range.CharacterFormat.Bold = true;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Find the first occurrence of a particular text in the document
Dim textSelection As TextSelection = document.Find("as graphical contents")
'Get the found text as single text range
Dim textRange As WTextRange = textSelection.GetAsOneRange()
'Modify the text
textRange.Text = "Replaced text"
'Set highlight color
textRange.CharacterFormat.HighlightColor = Color.Yellow
'Find the next occurrence of a particular text from the previous paragraph
textSelection = document.FindNext(textRange.OwnerParagraph, "paragraph")
'Get the found text as single text range
Dim range As WTextRange = textSelection.GetAsOneRange()
'Set bold formatting
range.CharacterFormat.Bold = True
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Find the first occurrence of a particular text extended to several paragraphs in the document
TextSelection[] textSelections = document.FindSingleLine("First paragraph Second paragraph", true, false);
WParagraph paragraph = null;
foreach (TextSelection textSelection in textSelections)
{
//Get the found text as single text range and set highlight color
WTextRange textRange = textSelection.GetAsOneRange();
textRange.CharacterFormat.HighlightColor = Color.YellowGreen;
paragraph = textRange.OwnerParagraph;
}
//Find the next occurrence of a particular text extended to several paragraphs in the document
textSelections = document.FindNextSingleLine(paragraph, "First paragraph Second paragraph", true, false);
foreach (TextSelection textSelection in textSelections)
{
//Get the found text as single text range and set italic formatting
WTextRange text = textSelection.GetAsOneRange();
text.CharacterFormat.Italic = true;
}
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Find the first occurrence of a particular text extended to several paragraphs in the document
Dim textSelections As TextSelection() = document.FindSingleLine("First paragraph Second paragraph", True, False)
Dim paragraph As WParagraph = Nothing
For Each textSelection As TextSelection In textSelections
'Get the found text as single text range and set highlight color
Dim textRange As WTextRange = textSelection.GetAsOneRange()
textRange.CharacterFormat.HighlightColor = Color.YellowGreen
paragraph = textRange.OwnerParagraph
Next
'Find the next occurrence of a particular text extended to several paragraphs in the document
textSelections = document.FindNextSingleLine(paragraph, "First paragraph Second paragraph", True, False)
For Each textSelection As TextSelection In textSelections
'Get the found text as single text range and set italic formatting
Dim text As WTextRange = textSelection.GetAsOneRange()
text.CharacterFormat.Italic = True
Next
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Find the first occurrence of a particular text extended to several paragraphs in the document
TextSelection[] textSelections = document.FindSingleLine("First paragraph Second paragraph", true, false);
WParagraph paragraph = null;
foreach (TextSelection textSelection in textSelections)
{
//Get the found text as single text range and set highlight color
WTextRange textRange = textSelection.GetAsOneRange();
textRange.CharacterFormat.HighlightColor = Color.YellowGreen;
paragraph = textRange.OwnerParagraph;
}
//Find the next occurrence of a particular text extended to several paragraphs in the document
textSelections = document.FindNextSingleLine(paragraph, new Regex("First paragraph Second paragraph"));
foreach (TextSelection textSelection in textSelections)
{
//Get the found text as single text range and set italic formatting
WTextRange text = textSelection.GetAsOneRange();
text.CharacterFormat.Italic = true;
}
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Find the first occurrence of a particular text extended to several paragraphs in the document
Dim textSelections As TextSelection() = document.FindSingleLine("First paragraph Second paragraph", True, False)
Dim paragraph As WParagraph = Nothing
For Each textSelection As TextSelection In textSelections
'Get the found text as single text range and set highlight color
Dim textRange As WTextRange = textSelection.GetAsOneRange()
textRange.CharacterFormat.HighlightColor = Color.YellowGreen
paragraph = textRange.OwnerParagraph
Next
'Find the next occurrence of a particular text extended to several paragraphs in the document
textSelections = document.FindNextSingleLine(paragraph, new Regex("First paragraph Second paragraph"))
For Each textSelection As TextSelection In textSelections
'Get the found text as single text range and set italic formatting
Dim text As WTextRange = textSelection.GetAsOneRange()
text.CharacterFormat.Italic = True
Next
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the document with macros
WordDocument document = new WordDocument("Sample.docm");
//Check whether the document has macros and remove them
if (document.HasMacros)
document.RemoveMacros();
//Save the document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the document with macros
Dim document As New WordDocument("Sample.docm")
'Check whether the document has macros and remove them
If document.HasMacros Then
document.RemoveMacros()
End If
'Save the document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
//Open an existing Word document.
using(WordDocument document = new WordDocument("Template.docx"))
{
//Find picture by alternative text.
WPicture picture = document.FindItemByProperty(EntityType.Picture, "AlternativeText", "Logo") as WPicture;
//Resize the picture.
if (picture != null)
{
picture.Height = 50;
picture.Width = 75;
}
//Save and close the Word document.
document.Save("Sample.docx");
}
'Open an existing Word document.
Dim document As WordDocument = New WordDocument("Template.docx")
'Find picture by alternative text.
Dim picture As WPicture = TryCast(document.FindItemByProperty(EntityType.Picture, "AlternativeText", "Logo"), WPicture)
'Resize the picture.
If picture IsNot Nothing Then
picture.Height = 50
picture.Width = 75
End If
'Save and close the Word document.
document.Save("Sample.docx")
document.Close()
//Open an existing Word document.
using(WordDocument document = new WordDocument("Template.docx"))
{
//Find picture by height and width.
WPicture picture = document.FindItemByProperties(EntityType.Picture, new string[] { "Height", "Width" }, new string[] { "100", "50" }) as WPicture;
//Resize the picture.
if (picture != null)
{
picture.Height = 50;
picture.Width = 75;
}
//Save and close the Word document.
document.Save("Sample.docx");
}
'Open an existing Word document.
Dim document As WordDocument = New WordDocument("Template.docx")
'Find pictures by height and width.
Dim picture As WPicture = TryCast(document.FindItemByProperties(EntityType.Picture, New String() {"Height", "Width"}, New String() {"100", "50"}), WPicture)
'Resize the pictures.
If picture IsNot Nothing Then
picture.Height = 50
picture.Width = 75
End If
'Save and close the Word document.
document.Save("Sample.docx")
document.Close()
//Load an existing Word document into DocIO instance
WordDocument originalDocument = new WordDocument("OriginalDocument.docx", FormatType.Docx);
WordDocument revisedDocument = new WordDocument("RevisedDocument.docx", FormatType.Docx);
//Compares the original document with revised document
originalDocument.Compare(revisedDocument, "Nancy Davolio", DateTime.Now.AddDays(-1));
originalDocument.Save("Result.docx", FormatType.Docx);
revisedDocument.Close();
originalDocument.Close();
'Load an existing Word document into DocIO instance
Dim originalDocument As New WordDocument("OriginalDocument.docx", FormatType.Docx)
Dim revisedDocument As New WordDocument("RevisedDocument.docx", FormatType.Docx)
'Compares the original document with revised document
originalDocument.Compare(revisedDocument, "Nancy Davolio", DateTime.Now.AddDays(-1));
originalDocument.Save("Result.docx", FormatType.Docx)
revisedDocument.Close();
originalDocument.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument wordDocument = new WordDocument("Template.docx", FormatType.Docx);
//Initialize ChartToImageConverter for converting charts during Word to pdf conversion
wordDocument.ChartToImageConverter = new ChartToImageConverter();
//Create an instance of DocToPDFConverter
DocToPDFConverter converter = new DocToPDFConverter();
//Convert Word document into PDF document
PdfDocument pdfDocument = converter.ConvertToPDF(wordDocument);
//Close the instance of Word document object
wordDocument.Close();
//Save the PDF file
pdfDocument.Save("WordtoPDF.pdf");
//Close the instance of PDF document object
pdfDocument.Close(true);
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim wordDocument As New WordDocument("Template.docx", FormatType.Docx)
'Initialize ChartToImageConverter for converting charts during Word to pdf conversion
/// wordDocument.ChartToImageConverter = New ChartToImageConverter()
'Create an instance of DocToPDFConverter
Dim converter As New DocToPDFConverter()
'Convert Word document into PDF document
Dim pdfDocument As PdfDocument = converter.ConvertToPDF(wordDocument)
'Close the instance of Word document object
wordDocument.Close();
'Save the PDF file
pdfDocument.Save("WordtoPDF.pdf")
'Close the instance of document object
pdfDocument.Close(True)
End Sub
// Loads an existing Word document.
WordDocument wordDocument = new WordDocument("template.docx", FormatType.Docx);
// Initializes the SubstituteFont event to perform font substitution during Word to PDF conversion.
wordDocument.FontSettings.SubstituteFont += new SubstituteFontEventHandler(SubstituteFont);
// Creates an instance of DocToPDFConverter.
DocToPDFConverter converter = new DocToPDFConverter();
// Converts the Word document into PDF document.
PdfDocument pdfDocument = converter.ConvertToPDF(wordDocument);
// Closes the instance of Word document object.
wordDocument.Close();
// Saves the PDF file.
pdfDocument.Save("WordtoPDF.pdf");
// Closes the instance of PDF document object.
pdfDocument.Close(true);
private void SubstituteFont(object sender, SubstituteFontEventArgs args)
{
// Sets the alternate font when a specified font is not installed in the production environment.
if (args.OrignalFontName == "Arial Unicode MS")
args.AlternateFontName = "Arial";
else
args.AlternateFontName = "Times New Roman";
}
' Loads an existing Word document.
Dim wordDocument As New WordDocument("template.docx", FormatType.Docx)
' Initializes the SubstituteFont event to perform font substitution during Word to PDF conversion.
AddHandler wordDocument.FontSettings.SubstituteFont, AddressOf SubstituteFont
' Creates an instance of DocToPDFConverter.
Dim converter As New DocToPDFConverter()
' Converts the Word document into PDF document.
Dim pdfDocument As PdfDocument = converter.ConvertToPDF(wordDocument)
' Closes the instance of document object.
wordDocument.Close()
' Saves the PDF file .
pdfDocument.Save("WordtoPDF.pdf")
' Closes the instance of document object.
pdfDocument.Close(True)
Private Sub SubstituteFont(ByVal sender As Object, ByVal args As SubstituteFontEventArgs)
' Sets the alternate font when a specified font is not installed in the production environment.
If args.OrignalFontName = "Arial Unicode MS" Then
args.AlternateFontName = "Arial"
Else
args.AlternateFontName = "Times New Roman"
End If
End Sub
//Creates an new instance of WordDocument class.
WordDocument srcDocument = new WordDocument("SourceTemplate.docx");
// Creates an new instance of WordDocument class.
WordDocument destDocument = new WordDocument("DestinationTemplate.docx");
//Import the contents of source document at the end of destination document with destination styles.
destDocument.ImportOptions = ImportOptions.UseDestinationStyles;
destDocument.Sections.Add(srcDocument.LastSection.Clone());
// Releases the resources occupied by WordDocument instance.
srcDocument.Close();
// Saves the document in the given name and format.
destDocument.Save("Document.docx", FormatType.Docx);
// Releases the resources occupied by WordDocument instance.
destDocument.Close();
'Creates an new instance of WordDocument class.
Dim srcDocument As New WordDocument("SourceTemplate.docx")
' Creates an new instance of WordDocument class.
Dim destDocument As New WordDocument("DestinationTemplate.docx")
'Import the contents of source document at the end of destination document with destination styles.
destDocument.ImportOptions = ImportOptions.UseDestinationStyles
destDocument.Sections.Add(srcDocument.LastSection.Clone())
' Releases the resources occupied by WordDocument instance.
srcDocument.Close()
' Saves the document in the given name and format.
destDocument.Save("Document.docx", FormatType.Docx)
' Releases the resources occupied by WordDocument instance.
destDocument.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Retrieve the last section of the document and add new paragraph
document.LastSection.AddParagraph().AppendText("Adding new paragraph to the document");
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Retrieve the last section of the document and add new paragraph
document.LastSection.AddParagraph().AppendText("Adding new paragraph to the document")
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Set the last paragraph back color as Blue
document.LastParagraph.ParagraphFormat.BackColor = Color.Blue;
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Set the last paragraph back color as Blue
document.LastParagraph.ParagraphFormat.BackColor = Color.Blue
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Set the endnote format
document.EndnoteNumberFormat = FootEndNoteNumberFormat.Arabic;
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Set the endnote format
document.EndnoteNumberFormat = FootEndNoteNumberFormat.Arabic
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Set the footnote number format
document.FootnoteNumberFormat = FootEndNoteNumberFormat.UpperCaseRoman;
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Set the footnote number format
document.FootnoteNumberFormat = FootEndNoteNumberFormat.UpperCaseRoman
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Set the endnote restart index number
document.RestartIndexForEndnote = EndnoteRestartIndex.RestartForEachSection;
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Set the endnote restart index number
document.RestartIndexForEndnote = EndnoteRestartIndex.RestartForEachSection
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Set the endnote position at end of each section
document.EndnotePosition = EndnotePosition.DisplayEndOfSection;
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Set the endnote position at end of each section
document.EndnotePosition = EndnotePosition.DisplayEndOfSection
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Set the footnote restart index number
document.RestartIndexForFootnotes = FootnoteRestartIndex.RestartForEachPage;
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Set the footnote restart index number
document.RestartIndexForFootnotes = FootnoteRestartIndex.RestartForEachPage
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Set the footnote position at immediately beneath text
document.FootnotePosition = FootnotePosition.PrintImmediatelyBeneathText;
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Set the footnote position at immediately beneath text
document.FootnotePosition = FootnotePosition.PrintImmediatelyBeneathText
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//protect the document from editing
document.ProtectionType = Syncfusion.DocIO.ProtectionType.AllowOnlyReading;
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'protect the document from editing
document.ProtectionType = Syncfusion.DocIO.ProtectionType.AllowOnlyReading
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Set the footnote initial number
document.InitialFootnoteNumber = 3;
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Set the footnote initial number
document.InitialFootnoteNumber = 3
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Set the endnote initial number
document.InitialEndnoteNumber = 5;
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Set the endnote initial number
document.InitialEndnoteNumber = 5
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("First Name of the customer: ");
//Add the DocVariable field with Variable name and its type
paragraph.AppendField("FirstName", FieldType.FieldDocVariable);
paragraph = section.AddParagraph();
paragraph.AppendText("Last Name of the customer: ");
//Add the DocVariable field with Variable name and its type
paragraph.AppendField("LastName", FieldType.FieldDocVariable);
//Add the value for variable in WordDocument.Variable collection
document.Variables.Add("FirstName", "Jeff");
document.Variables.Add("LastName", "Smith");
//Update the document fields
document.UpdateDocumentFields();
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument()
Dim section As IWSection = document.AddSection()
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("First Name of the customer: ")
'Add the DocVariable field with Variable name and its type
paragraph.AppendField("FirstName", FieldType.FieldDocVariable)
paragraph = section.AddParagraph()
paragraph.AppendText("Last Name of the customer: ")
'Add the DocVariable field with Variable name and its type
paragraph.AppendField("LastName", FieldType.FieldDocVariable)
'Add the value for variable in WordDocument.Variable collection
document.Variables.Add("FirstName", "Jeff")
document.Variables.Add("LastName", "Smith")
'Update the document fields
document.UpdateDocumentFields()
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Enable the TrackChanges to track the edits as revision
document.TrackChanges = true;
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Enable the TrackChanges to track the edits as revision
document.TrackChanges = True
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Set to replace only the first occurrence of a particular text
document.ReplaceFirst = true;
//Find the first occurrence of a particular text in the document
TextSelection selection = document.Find("contents", false, false);
//Initialize text body part
TextBodyPart bodyPart = new TextBodyPart(selection);
//Replace a particular text with the text body part
document.Replace("paragraph", bodyPart, false, true, true);
//Save and close the document
document.Save("Replace.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Set to replace only the first occurrence of a particular text
document.ReplaceFirst = True
'Find the first occurrence of a particular text in the document
Dim selection As TextSelection = document.Find("contents", False, False)
'Initialize text body part
Dim bodyPart As New TextBodyPart(selection)
'Replace a particular text with the text body part
document.Replace("paragraph", bodyPart, False, True, True)
'Save and close the document
document.Save("Replace.docx", FormatType.Docx)
document.Close()
End Sub
//Loads an existing Word document
WordDocument wordDocument = new WordDocument("Template.docx", FormatType.Docx);
//Sets revision types to preserve track changes in PDF conversion.
wordDocument.RevisionOptions.ShowMarkup = RevisionType.Insertions | RevisionType.Formatting | RevisionType.Deletions;
//Instantiation of DocToPDFConverter for Word to PDF conversion
DocToPDFConverter converter = new DocToPDFConverter();
//Converts Word document into PDF document
PdfDocument pdfDocument = converter.ConvertToPDF(wordDocument);
//Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf");
//Releases all resources used by the object
converter.Dispose();
//Closes the instance of document objects
wordDocument.Close();
pdfDocument.Close(true);
'Loads an existing Word document
Dim wordDocument As WordDocument = New WordDocument("Template.docx", FormatType.Docx)
'Sets revision types to preserve track changes in PDF conversion.
wordDocument.RevisionOptions.ShowMarkup = RevisionType.Insertions Or RevisionType.Formatting Or RevisionType.Deletions
'Instantiation of DocToPDFConverter for Word to PDF conversion
Dim converter As DocToPDFConverter = New DocToPDFConverter
'Converts Word document into PDF document
Dim pdfDocument As PdfDocument = converter.ConvertToPDF(wordDocument)
'Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf")
'Releases all resources used by the object
converter.Dispose()
'Closes the instance of document objects
wordDocument.Close()
pdfDocument.Close(True)
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Apply the Arial font instead of the Arabic font, if the system does not contains Arabic font
document.FontSubstitutionTable.Add("Arabic", "Arial");
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Apply the Arial font instead of the Arabic font, if the system does not contains Arabic font
document.FontSubstitutionTable.Add("Arabic", "Arial");
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
// Creates an new instance of WordDocument class.
WordDocument srcDocument = new WordDocument();
// Adds a section and a paragraph in the empty document.
srcDocument.EnsureMinimal();
// Sets bold to character format of "Normal" style to differentiate source and destination document.
(srcDocument.Styles.FindByName("Normal") as WParagraphStyle).CharacterFormat.Bold = true;
// Creates an new instance of WordDocument class.
WordDocument destDocument = new WordDocument();
// Adds a section and a paragraph in the empty document.
destDocument.EnsureMinimal();
// Sets false value to exclude importing duplicate styles to destination document.
destDocument.ImportStyles = false;
destDocument.Sections.Add(srcDocument.LastSection.Clone());
// Releases the resources occupied by WordDocument instance.
srcDocument.Close();
// Saves the document in the given name and format.
destDocument.Save("Document.docx", FormatType.Docx);
// Releases the resources occupied by WordDocument instance.
destDocument.Close();
' Creates an new instance of WordDocument class.
Dim srcDocument As New WordDocument()
' Adds a section and a paragraph in the empty document.
srcDocument.EnsureMinimal()
' Sets bold to character format of "Normal" style to differentiate source and destination document.
TryCast(srcDocument.Styles.FindByName("Normal"), WParagraphStyle).CharacterFormat.Bold = True
' Creates an new instance of WordDocument class.
Dim destDocument As New WordDocument()
' Adds a section and a paragraph in the empty document.
destDocument.EnsureMinimal()
' Sets false value to exclude importing duplicate styles to destination document.
destDocument.ImportStyles = False
destDocument.Sections.Add(srcDocument.LastSection.Clone())
' Releases the resources occupied by WordDocument instance.
srcDocument.Close()
' Saves the document in the given name and format.
destDocument.Save("Document.docx", FormatType.Docx)
' Releases the resources occupied by WordDocument instance.
destDocument.Close()
// Creates an new instance of WordDocument class.
WordDocument srcDocument = new WordDocument();
// Adds a section and a paragraph in the empty document.
srcDocument.EnsureMinimal();
// Creates a paragraph style (with name "Test") and adds into source document.
WParagraphStyle paragraphStyle = new WParagraphStyle(srcDocument);
paragraphStyle.Name = "Test";
srcDocument.Styles.Add(paragraphStyle);
// Creates an new instance of WordDocument class.
WordDocument destDocument = new WordDocument();
// Adds a section and a paragraph in the empty document.
destDocument.EnsureMinimal();
// Creates a character style (with same paragraph styel name in source) and adds into destination document.
WCharacterStyle characterStyle = new WCharacterStyle(destDocument);
characterStyle.Name = "Test";
destDocument.Styles.Add(characterStyle);
// Sets true value to include importing duplicate styles (mismatched with types) to destination document.
destDocument.ImportStylesOnTypeMismatch = true;
destDocument.Sections.Add(srcDocument.LastSection.Clone());
// Releases the resources occupied by WordDocument instance.
srcDocument.Close();
// Saves the document in the given name and format.
destDocument.Save("Document.docx", FormatType.Docx);
// Releases the resources occupied by WordDocument instance.
destDocument.Close();
' Creates an new instance of WordDocument class.
Dim srcDocument As New WordDocument()
' Adds a section and a paragraph in the empty document.
srcDocument.EnsureMinimal()
' Creates a paragraph style (with name "Test") and adds into source document.
Dim paragraphStyle As New WParagraphStyle(srcDocument)
paragraphStyle.Name = "Test"
srcDocument.Styles.Add(paragraphStyle)
' Creates an new instance of WordDocument class.
Dim destDocument As New WordDocument()
' Adds a section and a paragraph in the empty document.
destDocument.EnsureMinimal()
' Creates a character style (with same paragraph styel name in source) and adds into destination document.
Dim characterStyle As New WCharacterStyle(destDocument)
characterStyle.Name = "Test"
destDocument.Styles.Add(characterStyle)
' Sets true value to include importing duplicate styles (mismatched with types) to destination document.
destDocument.ImportStylesOnTypeMismatch = True
destDocument.Sections.Add(srcDocument.LastSection.Clone())
' Releases the resources occupied by WordDocument instance.
srcDocument.Close()
' Saves the document in the given name and format.
destDocument.Save("Document.docx", FormatType.Docx)
' Releases the resources occupied by WordDocument instance.
destDocument.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument("Template.docx");
//Set the path for the attached template document
document.AttachedTemplate.Path = "../Data/Attachedtemplate.dotm";
//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("Template.docx")
'Set the path for the attached template document
document.AttachedTemplate.Path = "../Data/Attachedtemplate.dotm"
'Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Sets the maintain formatting option to the fields of the Word document
document.Settings.MaintainFormattingOnFieldUpdate = true;
//Updates the document fields
document.UpdateDocumentFields();
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Sets the maintain formatting option to the fields of the Word document
document.Settings.MaintainFormattingOnFieldUpdate = True
'Updates the document fields
document.UpdateDocumentFields()
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Sets whether result code must be updated when field code is modified.
document.Settings.UpdateResultOnFieldCodeChange = true;
//Modifies the merge field code.
(document.LastParagraph.ChildEntities[0] as WMergeField).FieldCode = "MERGEFIELD Employee_ID \\*MERGEFORMAT";
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Sets whether result code must be updated when field code is modified.
document.Settings.UpdateResultOnFieldCodeChange = True
'Modifies the merge field code.
(document.LastParagraph.ChildEntities[0] as WMergeField).FieldCode = "MERGEFIELD Employee_ID \\*MERGEFORMAT"
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Load an existing Word document into DocIO instance.
WordDocument document = new WordDocument("Template.docx");
//Set the background type of the document.
document.Background.Type = BackgroundType.Color;
//Set the background color of the document.
document.Background.Color = Color.Red;
//Sets whether background colors and images are shown when a document is displayed in print layout view.
document.Settings.DisplayBackgrounds = false;
//Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Load an existing Word document into DocIO instance.
Dim document As New WordDocument("Template.docx")
'Set the background type of the document.
document.Background.Type = BackgroundType.Color
'Set the background color of the document.
document.Background.Color = Color.Red
'Sets whether background colors and images are shown when a document is displayed in print layout view.
document.Settings.DisplayBackgrounds = False
'Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Opens the source document
WordDocument sourceDocument = new WordDocument("sourceFileName.docx");
//Opens the destination document
WordDocument destinationDocument = new WordDocument("targetFileName.docx");
//Sets true value to maintain imported list style cache to destination document
destinationDocument.Settings.MaintainImportedListCache = true;
//Processes the body contents for each section in the Word document
foreach (WSection section in sourceDocument.Sections)
{
//Accesses the body of section where all the contents in document are apart
foreach (TextBodyItem bodyItem in section.Body.ChildEntities)
{
destinationDocument.LastSection.Body.ChildEntities.Add(bodyItem.Clone());
}
}
//Closes the source document
sourceDocument.Close();
//Sets false value to exclude imported list style cache to destination document
destinationDocument.Settings.MaintainImportedListCache = false;
//Saves the destination document
destinationDocument.Save("outputFileName.docx", FormatType.Docx);
//Closes the destination document
destinationDocument.Close();
'Opens the source document
Dim sourceDocument As New WordDocument(sourceFileName)
'Opens the destination document
Dim destinationDocument As New WordDocument(targetFileName)
'Sets true value to maintain imported list style cache to destination document
destinationDocument.Settings.MaintainImportedListCache = True
'Processes the body contents for each section in the Word document
For Each section As WSection In sourceDocument.Sections
'Accesses the body of section where all the contents in document are apart
For Each bodyItem As TextBodyItem In section.Body.ChildEntities
destinationDocument.LastSection.Body.ChildEntities.Add(bodyItem.Clone())
Next
Next
'Closes the source document
sourceDocument.Close()
'Sets false value to exclude imported list style cache to destination document
destinationDocument.Settings.MaintainImportedListCache = False
'Saves the destination document
destinationDocument.Save(outputFileName, FormatType.Docx)
'Closes the destination document
destinationDocument.Close()
//Creates new instance of WordDocument class.
WordDocument document = new WordDocument();
//Sets flag to skip old file format exception while opening document.
document.Settings.SkipIncrementalSaveValidation = true;
//Opens an existing document from file system through.
document.Open("Template.docx", FormatType.Automatic);
//Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Creates new instance of WordDocument class.
Dim document As New WordDocument()
'Sets flag to skip old file format exception while opening document.
document.Settings.SkipIncrementalSaveValidation = True
'Opens an existing document from file system through.
document.Open(fileName, FormatType.Automatic)
'Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Creates an empty Word document instance
WordDocument document = new WordDocument();
//Sets flag to preserve embedded Ole images as normal image while opening document
document.Settings.PreserveOleImageAsImage = true;
//Loads or opens an existing Word document
document.Open(fileName, FormatType.Automatic);
//Saves the resultant Word document
document.Save("Sample.docx", FormatType.Docx);
//Closes the Word document
document.Close();
'Creates an empty Word document instance
Dim document As New WordDocument()
'Sets flag to preserve embedded Ole images as normal image while opening document
document.Settings.PreserveOleImageAsImage = True
'Loads or opens an existing Word document
document.Open("Template.docx", FormatType.Automatic)
'Saves the resultant Word document
document.Save("Sample.docx", FormatType.Docx)
'Closes the Word document
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Create a section
IWSection section = document.AddSection();
//Add a paragraph to a section
IWParagraph paragraph = section.AddParagraph();
//Append the text to paragraph
paragraph.AppendText("Working with footnotes");
//Formatting the text
paragraph.ApplyStyle(BuiltinStyle.Heading1);
//Add a paragraph to a section
paragraph = section.AddParagraph();
//Append the footnotes
WFootnote footnote = (WFootnote)paragraph.AppendFootnote(Syncfusion.DocIO.FootnoteType.Footnote);
WTextBody separator = document.Footnotes.Separator;
//Replace the default foot note separate by text
separator.Paragraphs[0].Text = "Footnote separator";
//Set the footnote character format
footnote.MarkerCharacterFormat.SubSuperScript = SubSuperScript.SuperScript;
//Inserts the text into the paragraph
paragraph.AppendText("Sample content for footnotes").CharacterFormat.Bold = true;
//Add footnote text
paragraph = footnote.TextBody.AddParagraph();
paragraph.AppendText("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");
//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)
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Create a section
IWSection section = document.AddSection();
//Add a paragraph to a section
IWParagraph paragraph = section.AddParagraph();
//Append the text to paragraph
paragraph.AppendText("Working with footnotes");
//Formatting the text
paragraph.ApplyStyle(BuiltinStyle.Heading1);
//Add a paragraph to section
paragraph = section.AddParagraph();
//Append the endnote
WFootnote endnote = (WFootnote)paragraph.AppendFootnote(Syncfusion.DocIO.FootnoteType.Endnote);
WTextBody separator = document.Endnotes.Separator;
//Replace the default foot note separate by text
separator.Paragraphs[0].Text = "Endnote separator";
//Set the endnote character format
endnote.MarkerCharacterFormat.SubSuperScript = SubSuperScript.SuperScript;
//Insert the text into the paragraph
paragraph.AppendText("Sample content for endnotes").CharacterFormat.Bold = true;
//Add the footnote text
paragraph = endnote.TextBody.AddParagraph();
paragraph.AppendText("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");
//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()
'Create a section
Dim section As IWSection = document.AddSection()
'Add a paragraph to a section
Dim paragraph As IWParagraph = section.AddParagraph()
'Append the text to paragraph
paragraph.AppendText("Working with footnotes")
'Formatting the text
paragraph.ApplyStyle(BuiltinStyle.Heading1)
'Add a paragraph to section
paragraph = section.AddParagraph()
'Append the endnote
Dim endnote As WFootnote = DirectCast(paragraph.AppendFootnote(Syncfusion.DocIO.FootnoteType.Endnote), WFootnote)
Dim separator As WTextBody = document.Endnotes.Separator
'Replace the default foot note separate by text
separator.Paragraphs(0).Text = "Endnote separator"
'Set the endnote character format
endnote.MarkerCharacterFormat.SubSuperScript = SubSuperScript.SuperScript
'Insert the text into the paragraph
paragraph.AppendText("Sample content for endnotes").CharacterFormat.Bold = True
'Add the footnote text
paragraph = endnote.TextBody.AddParagraph()
paragraph.AppendText("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")
'Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Creates instance for HTML import settings.
HTMLImportSettings hTMLImport = new HTMLImportSettings();
//Enable the IsConsiderListStyleAttribute to consider the list style type.
hTMLImport.IsConsiderListStyleAttribute = true;
//Creates instance for Word document.
WordDocument wordDocument = new WordDocument();
//Sets the HTML import settings for HTML to Word conversion.
wordDocument.HTMLImportSettings = hTMLImport;
//Opens the existing HTML document.
wordDocument.Open(@"InputHTML.html");
//Save the document as Word document.
wordDocument.Save("sample.docx");
//Close the document.
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Creates instance for HTML import settings.
Dim hTMLImport As New HTMLImportSettings()
'Enable the IsConsiderNoneListStyle to consider the list style type.
hTMLImport.IsConsiderListStyleAttribute = True
'Creates instance for Word document.
Dim wordDocument As New WordDocument()
'Sets the HTML import settings for HTML to Word conversion.
WordDocument.HTMLImportSettings = hTMLImport
'Opens the existing HTML document.
WordDocument.Open("InputHTML.html")
'Save the document as Word document.
WordDocument.Save("sample.docx")
'Close the document.
WordDocument.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
//Set page setup options
section.PageSetup.Orientation = PageOrientation.Landscape;
section.PageSetup.Margins.All = 72;
section.PageSetup.Borders.LineWidth = 2;
section.PageSetup.DifferentFirstPage = true;
section.PageSetup.DifferentOddAndEvenPages = true;
section.PageSetup.FooterDistance = 42;
section.PageSetup.HeaderDistance = 52;
section.PageSetup.LineNumberingDistanceFromText = 10;
section.PageSetup.LineNumberingMode = LineNumberingMode.Continuous;
section.PageSetup.LineNumberingStartValue = 5;
section.PageSetup.LineNumberingStep = 2;
section.PageSetup.PageBorderOffsetFrom = PageBorderOffsetFrom.Text;
section.PageSetup.PageBordersApplyType = PageBordersApplyType.AllPages;
section.PageSetup.PageNumberStyle = PageNumberStyle.RomanUpper;
section.PageSetup.PageSize = new SizeF(612, 792);
section.PageSetup.PageStartingNumber = 1;
section.PageSetup.VerticalAlignment = PageAlignment.Top;
//Add the page number field to even footer of the document
IWParagraph paragraph = section.HeadersFooters.EvenFooter.AddParagraph();
paragraph.AppendText("PageNumber_EvenPageFooter ");
paragraph.AppendField("Page", FieldType.FieldPage);
//Add the page number field to odd footer of the document
paragraph = section.HeadersFooters.OddFooter.AddParagraph();
paragraph.AppendText("PageNumber_OddPageFooter ");
paragraph.AppendField("Page", FieldType.FieldPage);
//Add the page number field to first footer of the document
paragraph = section.HeadersFooters.FirstPageFooter.AddParagraph();
//Add page number field to the document
paragraph.AppendText("PageNumber_FirstPageFooter ");
paragraph.AppendField("Page", FieldType.FieldPage);
//Add a paragraph to section
paragraph = section.AddParagraph();
//Append the text to the created paragraph
paragraph.AppendText("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");
paragraph = section.AddParagraph();
//Append the text to the created paragraph
paragraph.AppendText("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");
paragraph.AppendBreak(Syncfusion.DocIO.DLS.BreakType.PageBreak);
paragraph = section.AddParagraph();
//Append the text to the created paragraph
paragraph.AppendText("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");
paragraph = section.AddParagraph();
//Append the text to the created paragraph
paragraph.AppendText("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");
paragraph.AppendBreak(Syncfusion.DocIO.DLS.BreakType.PageBreak);
paragraph = section.AddParagraph();
//Append the text to the created paragraph
paragraph.AppendText("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");
paragraph = section.AddParagraph();
//Append the text to the created paragraph
paragraph.AppendText("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");
//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)
Dim document As New WordDocument()
Dim section As IWSection = document.AddSection()
'Set page setup options
section.PageSetup.Orientation = PageOrientation.Landscape
section.PageSetup.Margins.All = 72
section.PageSetup.Borders.LineWidth = 2
section.PageSetup.DifferentFirstPage = True
section.PageSetup.DifferentOddAndEvenPages = True
section.PageSetup.FooterDistance = 42
section.PageSetup.HeaderDistance = 52
section.PageSetup.LineNumberingDistanceFromText = 10
section.PageSetup.LineNumberingMode = LineNumberingMode.Continuous
section.PageSetup.LineNumberingStartValue = 5
section.PageSetup.LineNumberingStep = 2
section.PageSetup.PageBorderOffsetFrom = PageBorderOffsetFrom.Text
section.PageSetup.PageBordersApplyType = PageBordersApplyType.AllPages
section.PageSetup.PageNumberStyle = PageNumberStyle.RomanUpper
section.PageSetup.PageSize = New SizeF(612, 792)
section.PageSetup.PageStartingNumber = 1
section.PageSetup.VerticalAlignment = PageAlignment.Top
'Add the page number field to even footer of the document
Dim paragraph As IWParagraph = section.HeadersFooters.EvenFooter.AddParagraph()
paragraph.AppendText("PageNumber_EvenPageFooter ")
paragraph.AppendField("Page", FieldType.FieldPage)
'Add the page number field to odd footer of the document
paragraph = section.HeadersFooters.OddFooter.AddParagraph()
paragraph.AppendText("PageNumber_OddPageFooter ")
paragraph.AppendField("Page", FieldType.FieldPage)
'Add the page number field to first footer of the document
paragraph = section.HeadersFooters.FirstPageFooter.AddParagraph()
'Add page number field to the document
paragraph.AppendText("PageNumber_FirstPageFooter ")
paragraph.AppendField("Page", FieldType.FieldPage)
'Add a paragraph to section
paragraph = section.AddParagraph()
'Append the text to the created paragraph
paragraph.AppendText("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")
paragraph = section.AddParagraph()
'Append the text to the created paragraph
paragraph.AppendText("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")
paragraph.AppendBreak(Syncfusion.DocIO.DLS.BreakType.PageBreak)
paragraph = section.AddParagraph()
'Append the text to the created paragraph
paragraph.AppendText("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")
paragraph = section.AddParagraph()
'Append the text to the created paragraph
paragraph.AppendText("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")
paragraph.AppendBreak(Syncfusion.DocIO.DLS.BreakType.PageBreak)
paragraph = section.AddParagraph()
'Append the text to the created paragraph
paragraph.AppendText("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")
paragraph = section.AddParagraph()
'Append the text to the created paragraph
paragraph.AppendText("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")
'Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
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();
section.PageSetup.PageStartingNumber = 1;
section.PageSetup.RestartPageNumbering = true;
section.PageSetup.PageNumberStyle = PageNumberStyle.Arabic;
section.PageSetup.InsertPageNumbers(false, PageNumberAlignment.Center);
//Add the paragraph
IWParagraph paragraph = section.AddParagraph();
//Append the text to the created paragraph
paragraph.AppendText("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");
//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()
section.PageSetup.PageStartingNumber = 1
section.PageSetup.RestartPageNumbering = True
section.PageSetup.PageNumberStyle = PageNumberStyle.Arabic
section.PageSetup.InsertPageNumbers(False, PageNumberAlignment.Center)
'Add the paragraph
Dim paragraph As IWParagraph = section.AddParagraph()
'Append the text to the created paragraph
paragraph.AppendText("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")
'Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
//Open existing Word document.
WordDocument document = new WordDocument("Sample.docx");
//Iterate each section
foreach (WSection section in document.Sections)
{
//Set the Line numbering mode for the Particular Section.
section.PageSetup.LineNumberingMode = LineNumberingMode.Continuous;
}
//Save the resultant Word document.
document.Save("Sample.docx");
//Close the document instance.
document.Close();
//Open existing Word document.
Dim document As New WordDocument("Sample.docx")
//Iterate each section
For Each section As WSection In document.Sections
//Set the Line Numbering Mode for the Particular Section.
section.PageSetup.LineNumberingMode = LineNumberingMode.Continuous
Next
//Save the resultant Word document.
document.Save("Sample.docx")
//Close the document instance.
document.Close()
//Open existing Word document.
WordDocument document = new WordDocument("Sample.docx");
//Iterate each section
foreach (WSection section in document.Sections)
{
//Set the line numbering mode for the Particular section.
section.PageSetup.LineNumberingMode = LineNumberingMode.Continuous;
//Set the Step value for the LineNumberingMode.
section.PageSetup.LineNumberingStep=2;
}
//Save the resultant Word document.
document.Save("Sample.docx");
//Close the document instance.
document.Close();
//Open existing Word document.
Dim document As New WordDocument("Sample.docx")
//Iterate each section
For Each section As WSection In document.Sections
//Set the line numbering mode for the Particular section.
section.PageSetup.LineNumberingMode = LineNumberingMode.Continuous
//Set the Step value for the LineNumberingMode.
section.PageSetup.LineNumberingStep = 2
Next
//Save the resultant Word document.
document.Save("Sample.docx")
//Close the document instance.
document.Close()
//Open existing Word document.
WordDocument document = new WordDocument("Sample.docx");
//Iterate each section
foreach (WSection section in document.Sections)
{
//Set the line numbering mode for the Particular Section.
section.PageSetup.LineNumberingMode = LineNumberingMode.Continuous;
//Set the Starting value for the LineNumberingMode.
section.PageSetup.LineNumberingStartValue = 100;
}
//Save the resultant Word document.
document.Save("Sample.docx");
//Close the document instance.
document.Close();
//Open existing Word document.
Dim document As New WordDocument("Sample.docx")
//Iterate each section
For Each section As WSection In document.Sections
//Set the line numbering mode for the Particular Section.
section.PageSetup.LineNumberingMode = LineNumberingMode.Continuous
//Set the Starting Value for the LineNumbering Mode.
section.PageSetup.LineNumberingStartValue = 100
Next
//Save the resultant Word document.
document.Save("Sample.docx")
//Close the document instance.
document.Close()
//Open existing Word document.
WordDocument document = new WordDocument("Sample.docx");
//Iterate each section
foreach (WSection section in document.Sections)
{
//Set the line numbering mode for the particular section.
section.PageSetup.LineNumberingMode = LineNumberingMode.Continuous;
//Set the Distance value for the LineNumbering Mode.
section.PageSetup.LineNumberingDistanceFromText = 55.7f;
}
//Save the resultant Word document.
document.Save("Sample.docx");
//Close the document instance.
document.Close();
//Open existing Word document.
Dim document As New WordDocument("Sample.docx")
//Iterate each section
For Each section As WSection In document.Sections
//Set the line numbering mode for the particular section.
section.PageSetup.LineNumberingMode = LineNumberingMode.Continuous
//Set the Distance value for the LineNumbering Mode.
section.PageSetup.LineNumberingDistanceFromText = 55.7F
Next
//Save the resultant Word document.
document.Save("Sample.docx")
//Close the document instance.
document.Close()
//Creates an instance of WordDocument.
WordDocument document = new WordDocument();
//Adds a new section into the Word document.
IWSection section= document.AddSection();
//Sets the PrinterPaperTray value for FirstPageTray in pagesetup options.
section.PageSetup.FirstPageTray = PrinterPaperTray.EnvelopeFeed;
//Adds a new simple paragraph into the section.
IWParagraph paragraph = section.AddParagraph();
//Adds new text to the paragraph.
paragraph.AppendText("Added paper source");
//Saves the resultant Word document.
document.Save("Sample.docx");
//Closes the document.
document.Close();
//Creates an instance of WordDocument.
Dim document As WordDocument = New WordDocument()
//Adds a new section into the Word document.
Dim section As IWSection = document.AddSection()
//Sets the PrinterPaperTray value for FirstPageTray in pagesetup options.
section.PageSetup.FirstPageTray = PrinterPaperTray.EnvelopeFeed
//Adds a new simple paragraph into the section.
Dim paragraph As IWParagraph = section.AddParagraph()
//Adds new text to the paragraph.
paragraph.AppendText("Added paper source")
//Saves the resultant Word document.
document.Save("Sample.docx")
//Closes the document.
document.Close()
//Creates an instance of WordDocument.
WordDocument document = new WordDocument();
//Adds a new section into the Word document.
IWSection section= document.AddSection();
//Sets the PrinterPaperTray value for OtherPagesTray in pagesetup options.
section.PageSetup.OtherPagesTray = PrinterPaperTray.MiddleBin;
//Adds a new simple paragraph into the section.
IWParagraph paragraph = section.AddParagraph();
//Adds new text to the paragraph.
paragraph.AppendText("Added paper source");
//Saves the resultant Word document.
document.Save("Sample.docx");
//Closes the document.
document.Close();
//Creates an instance of WordDocument.
Dim document As WordDocument = New WordDocument()
//Adds a new section into the Word document.
Dim section As IWSection = document.AddSection()
//Sets the PrinterPaperTray value for OtherPagesTray in pagesetup options.
section.PageSetup.OtherPagesTray = PrinterPaperTray.MiddleBin
//Adds a new simple paragraph into the section.
Dim paragraph As IWParagraph = section.AddParagraph()
//Adds new text to the paragraph.
paragraph.AppendText("Added paper source")
//Saves the resultant Word document.
document.Save("Sample.docx")
//Closes the document.
document.Close()
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 page number to document
section.PageSetup.PageStartingNumber = 1;
section.PageSetup.RestartPageNumbering = true;
section.PageSetup.PageNumberStyle = PageNumberStyle.Arabic;
//Specify the chapter number for heading 1
section.PageSetup.PageNumbers.HeadingLevelForChapter = HeadingLevel.Heading1;
//SPecify t he chapter number and page number separator
section.PageSetup.PageNumbers.ChapterPageSeparator = ChapterPageSeparatorType.Colon;
//Add a footer paragraph text to the document
IWParagraph paragraph = section.HeadersFooters.Footer.AddParagraph();
paragraph.ParagraphFormat.Tabs.AddTab(523f, TabJustification.Right, Syncfusion.DocIO.DLS.TabLeader.NoLeader);
//Add text for the footer paragraph
paragraph.AppendText("Copyright Northwind Inc. 2001 - 2024");
//Add page number field to the document
paragraph.AppendText("\tPage ");
paragraph.AppendField("Page", FieldType.FieldPage);
//Add the paragraph to the text body of the section
paragraph = section.AddParagraph();
paragraph.AppendText("First Title with Heading 1 Style");
//Apply Heading 1 built-in style
paragraph.ApplyStyle(BuiltinStyle.Heading1);
WParagraphStyle paraStyle = document.Styles.FindByName("Heading 1") as WParagraphStyle;
//Add the number format list for the Heading 1 style
paraStyle.ListFormat.ApplyDefNumberedStyle();
paraStyle.ListFormat.CurrentListLevel.PatternType = ListPatternType.UpLetter;
//Add the paragraph
paragraph = section.AddParagraph();
//Append the text to the created paragraph
paragraph.AppendText("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");
//Add the page break
paragraph.AppendBreak(Syncfusion.DocIO.DLS.BreakType.PageBreak);
//Add the another paragraph to section
paragraph = section.AddParagraph();
paragraph.AppendText("Second Title with Heading 1 Style");
//Apply Heading 1 built-in style
paragraph.ApplyStyle(BuiltinStyle.Heading1);
//Add the paragraph
paragraph = section.AddParagraph();
//Append the text to the created paragraph
paragraph.AppendText("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");
//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 page number to document
section.PageSetup.PageStartingNumber = 1
section.PageSetup.RestartPageNumbering = True
section.PageSetup.PageNumberStyle = PageNumberStyle.Arabic
'Specify the chapter number for heading 1
section.PageSetup.PageNumbers.HeadingLevelForChapter = HeadingLevel.Heading1
'SPecify t he chapter number and page number separator
section.PageSetup.PageNumbers.ChapterPageSeparator = ChapterPageSeparatorType.Colon
'Add a footer paragraph text to the document
Dim paragraph As IWParagraph = section.HeadersFooters.Footer.AddParagraph()
paragraph.ParagraphFormat.Tabs.AddTab(523F, TabJustification.Right, Syncfusion.DocIO.DLS.TabLeader.NoLeader)
'Add text for the footer paragraph
paragraph.AppendText("Copyright Northwind Inc. 2001 - 2024")
'Add page number field to the document
paragraph.AppendText(vbTab & "Page ")
paragraph.AppendField("Page", FieldType.FieldPage)
'Add the paragraph to the text body of the section
paragraph = section.AddParagraph()
paragraph.AppendText("First Title with Heading 1 Style")
'Apply Heading 1 built-in style
paragraph.ApplyStyle(BuiltinStyle.Heading1)
Dim paraStyle As WParagraphStyle = TryCast(document.Styles.FindByName("Heading 1"), WParagraphStyle)
'Add the number format list for the Heading 1 style
paraStyle.ListFormat.ApplyDefNumberedStyle()
paraStyle.ListFormat.CurrentListLevel.PatternType = ListPatternType.UpLetter
'Add the paragraph
paragraph = section.AddParagraph()
'Append the text to the created paragraph
paragraph.AppendText("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")
'Add the page break
paragraph.AppendBreak(Syncfusion.DocIO.DLS.BreakType.PageBreak)
'Add the another paragraph to section
paragraph = section.AddParagraph()
paragraph.AppendText("Second Title with Heading 1 Style")
'Apply Heading 1 built-in style
paragraph.ApplyStyle(BuiltinStyle.Heading1)
'Add the paragraph
paragraph = section.AddParagraph()
'Append the text to the created paragraph
paragraph.AppendText("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")
'Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new text to the paragraph
IWTextRange text = paragraph.AppendText("A new text is added to the paragraph.");
text.CharacterFormat.FontSize = 14;
text.CharacterFormat.Bold = true;
text.CharacterFormat.TextColor = Color.Green;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new text to the paragraph
Dim text As IWTextRange = paragraph.AppendText("A new text is added to the paragraph.")
text.CharacterFormat.FontSize = 14
text.CharacterFormat.Bold = True
text.CharacterFormat.TextColor = Color.Green
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new inline control to the paragraph
IInlineContentControl inlineControl = paragraph.AppendInlineContentControl(ContentControlType.RichText);
WTextRange controlText = new WTextRange(document);
controlText.CharacterFormat.Bold = true;
controlText.CharacterFormat.TextColor = Color.Green;
controlText.Text = "Inline content control inserted.";
//Add text range to the control added
inlineControl.ParagraphItems.Add(controlText);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new inline control to the paragraph
Dim inlineControl As IInlineContentControl = paragraph.AppendInlineContentControl(ContentControlType.RichText)
Dim textRange As New WTextRange(document)
textRange.CharacterFormat.Bold = True
textRange.CharacterFormat.TextColor = Color.Green
textRange.Text = "Inline content control inserted."
'Add text range to the control added
inlineControl.ParagraphItems.Add(textRange)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add image to the paragraph
IWPicture picture = paragraph.AppendPicture(Image.FromFile("Image.png"));
//Set height and width for the image
picture.Height = 100;
picture.Width = 100;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add image to the paragraph
Dim picture As IWPicture = paragraph.AppendPicture(Image.FromFile("Image.png"))
'Set height and width for the image
picture.Height = 100
picture.Width = 100
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph firstParagraph = section.AddParagraph();
//Get the image and convert to byte array.
Image image = Image.FromFile("Image.png");
MemoryStream stream = new MemoryStream();
image.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
byte[] imageBytes = stream.ToArray();
//Add image to the paragraph
IWPicture picture = firstParagraph.AppendPicture(imageBytes);
//Set height and width for the image
picture.Height = 100;
picture.Width = 100;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim firstParagraph As IWParagraph = section.AddParagraph()
'Get the image and convert to byte array.
Dim image__1 As Image = Image.FromFile("Image.png")
Dim stream As New MemoryStream()
image__1.Save(stream, System.Drawing.Imaging.ImageFormat.Png)
Dim imageBytes As Byte() = stream.ToArray()
'Add image to the paragraph
Dim picture As IWPicture = firstParagraph.AppendPicture(imageBytes)
'Set height and width for the image
picture.Height = 100
picture.Width = 100
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph firstParagraph = section.AddParagraph();
//Get the image as byte array.
byte[] imageBytes = File.ReadAllBytes("Image.png");
//Get the SVG image as byte array.
byte[] svgData = File.ReadAllBytes("Image.svg");
//Add SVG image to the paragraph
IWPicture picture = firstParagraph.AppendPicture(svgData, imageBytes);
//Set height and width for the image
picture.Height = 100;
picture.Width = 100;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim firstParagraph As IWParagraph = section.AddParagraph()
'Get the png image as byte array.
Dim imageBytes As Byte() = File.ReadAllBytes("Image.png")
'Get the SVG image as byte array.
Dim svgData As Byte() = File.ReadAllBytes("Image.svg")
'Add SVG image to the paragraph
Dim picture As IWPicture = firstParagraph.AppendPicture(svgData, imageBytes);
'Set height and width for the image
picture.Height = 100
picture.Width = 100
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add section to the document
IWSection sec = document.AddSection();
//Add paragraph to the section
IWParagraph paragraph = sec.AddParagraph();
//Input data for chart
object[][] data = new object[6][];
for (int i = 0; i < 6; i++)
data[i] = new object[3];
data[0][0] = "";
data[1][0] = "Gravad lax";
data[2][0] = "Louisiana Hot spiced Okara";
data[3][0] = "Mascarpone Fabioli";
data[4][0] = "Wimmers gute SemmelKnodel";
data[5][0] = "Maxilaku";
data[0][1] = "Sum of Purchases";
data[1][1] = 286;
data[2][1] = 680;
data[3][1] = 288;
data[4][1] = 200;
data[5][1] = 731;
data[0][2] = "Sum of Future Expenses";
data[1][2] = 1300;
data[2][2] = 700;
data[3][2] = 1280;
data[4][2] = 1200;
data[5][2] = 2660; ///
//Create and Append chart to the paragraph
WChart chart = paragraph.AppendChart(data, 470, 300);
//Set chart type and title
chart.ChartTitle = "Purchase Details";
chart.ChartTitleArea.FontName = "Calibri";
chart.ChartTitleArea.Size = 14;
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None;
//Set series type
chart.Series[0].SerieType = OfficeChartType.Line_Markers;
chart.Series[1].SerieType = OfficeChartType.Bar_Clustered;
chart.PrimaryCategoryAxis.Title = "Products";
chart.PrimaryValueAxis.Title = "In Dollars";
//Set position of legend
chart.Legend.Position = OfficeLegendPosition.Bottom;
//Save the document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Input data for chart
Dim data As Object()() = New Object(5)() {}
For i As Integer = 0 To 5
data(i) = New Object(2) {}
Next
data(0)(0) = ""
data(1)(0) = "Gravad lax"
data(2)(0) = "Louisiana Hot spiced Okara"
data(3)(0) = "Mascarpone Fabioli"
data(4)(0) = "Wimmers gute SemmelKnodel"
data(5)(0) = "Maxilaku"
data(0)(1) = "Sum of Purchases"
data(1)(1) = 286
data(2)(1) = 680
data(3)(1) = 288
data(4)(1) = 200
data(5)(1) = 731
data(0)(2) = "Sum of Future Expenses"
data(1)(2) = 1300
data(2)(2) = 700
data(3)(2) = 1280
data(4)(2) = 1200
data(5)(2) = 2660
'Create and Append chart to the paragraph
Dim chart As WChart = paragraph.AppendChart(data, 470, 300)
'Set chart type and title
chart.ChartTitle = "Purchase Details"
chart.ChartTitleArea.FontName = "Calibri"
chart.ChartTitleArea.Size = 14
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None
'Set series type
chart.Series(0).SerieType = OfficeChartType.Line_Markers
chart.Series(1).SerieType = OfficeChartType.Bar_Clustered
chart.PrimaryCategoryAxis.Title = "Products"
chart.PrimaryValueAxis.Title = "In Dollars"
'Set position of legend
chart.Legend.Position = OfficeLegendPosition.Bottom
'Save the document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add section to the document
IWSection sec = document.AddSection();
//Add paragraph to the section
IWParagraph paragraph = sec.AddParagraph();
//Create and Append chart to the paragraph
WChart chart = paragraph.AppendChart(446, 270);
//Set chart type
chart.ChartType = OfficeChartType.Pie;
//Set chart title
chart.ChartTitle = "Best Selling Products";
chart.ChartTitleArea.FontName = "Calibri";
chart.ChartTitleArea.Size = 14;
//Set data for chart
chart.ChartData.SetValue(1, 1, "");
chart.ChartData.SetValue(1, 2, "Sales");
chart.ChartData.SetValue(2, 1, "Cote de Blaye");
chart.ChartData.SetValue(2, 2, 141.396);
chart.ChartData.SetValue(3, 1, "Thuringer Rostbratwurst");
chart.ChartData.SetValue(3, 2, 80.368);
chart.ChartData.SetValue(4, 1, "Raclette Courdavault");
chart.ChartData.SetValue(4, 2, 71.155);
chart.ChartData.SetValue(5, 1, "Tarte au sucre");
chart.ChartData.SetValue(5, 2, 47.234);
chart.ChartData.SetValue(6, 1, "Camembert Pierrot");
chart.ChartData.SetValue(6, 2, 46.825);
chart.ChartData.SetValue(7, 1, "Gnocchi di nonna Alice");
chart.ChartData.SetValue(7, 2, 42.593);
chart.ChartData.SetValue(8, 1, "Manjimup Dried Apples");
chart.ChartData.SetValue(8, 2, 41.819);
chart.ChartData.SetValue(9, 1, "Alice Mutton");
chart.ChartData.SetValue(9, 2, 32.698);
chart.ChartData.SetValue(10, 1, "Carnarvon Tigers");
chart.ChartData.SetValue(10, 2, 29.171);
chart.ChartData.SetValue(11, 1, "R�ssle Sauerkraut.");
chart.ChartData.SetValue(11, 2, 25.696);
//Create a new chart series with the name �Sales�
IOfficeChartSerie pieSeries = chart.Series.Add("Sales");
pieSeries.Values = chart.ChartData[2, 2, 11, 2];
//Set data label
pieSeries.DataPoints.DefaultDataPoint.DataLabels.IsValue = true;
pieSeries.DataPoints.DefaultDataPoint.DataLabels.Position = OfficeDataLabelPosition.Outside;
//Set background color
chart.ChartArea.Fill.ForeColor = Color.FromArgb(242, 242, 242);
chart.PlotArea.Fill.ForeColor = Color.FromArgb(242, 242, 242);
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None;
//Set category labels
chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 11, 1];
//Save the document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Create and Append chart to the paragraph
Dim chart As WChart = paragraph.AppendChart(446, 270)
'Set chart type
chart.ChartType = OfficeChartType.Pie
'Set chart title
chart.ChartTitle = "Best Selling Products"
chart.ChartTitleArea.FontName = "Calibri"
chart.ChartTitleArea.Size = 14
'Set data for chart
chart.ChartData.SetValue(1, 1, "")
chart.ChartData.SetValue(1, 2, "Sales")
chart.ChartData.SetValue(2, 1, "Cote de Blaye")
chart.ChartData.SetValue(2, 2, 141.396)
chart.ChartData.SetValue(3, 1, "Thuringer Rostbratwurst")
chart.ChartData.SetValue(3, 2, 80.368)
chart.ChartData.SetValue(4, 1, "Raclette Courdavault")
chart.ChartData.SetValue(4, 2, 71.155)
chart.ChartData.SetValue(5, 1, "Tarte au sucre")
chart.ChartData.SetValue(5, 2, 47.234)
chart.ChartData.SetValue(6, 1, "Camembert Pierrot")
chart.ChartData.SetValue(6, 2, 46.825)
chart.ChartData.SetValue(7, 1, "Gnocchi di nonna Alice")
chart.ChartData.SetValue(7, 2, 42.593)
chart.ChartData.SetValue(8, 1, "Manjimup Dried Apples")
chart.ChartData.SetValue(8, 2, 41.819)
chart.ChartData.SetValue(9, 1, "Alice Mutton")
chart.ChartData.SetValue(9, 2, 32.698)
chart.ChartData.SetValue(10, 1, "Carnarvon Tigers")
chart.ChartData.SetValue(10, 2, 29.171)
chart.ChartData.SetValue(11, 1, "R�ssle Sauerkraut.")
'Create a new chart series with the name �Sales�
Dim pieSeries As IOfficeChartSerie = chart.Series.Add("Sales")
pieSeries.Values = chart.ChartData(2, 2, 11, 2)
'Set data label
pieSeries.DataPoints.DefaultDataPoint.DataLabels.IsValue = True
pieSeries.DataPoints.DefaultDataPoint.DataLabels.Position = OfficeDataLabelPosition.Outside
'Set background color
chart.ChartArea.Fill.ForeColor = Color.FromArgb(242, 242, 242)
chart.PlotArea.Fill.ForeColor = Color.FromArgb(242, 242, 242)
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None
'Set category labels
chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData(2, 1, 11, 1)
'Save the document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add section to the document
IWSection sec = document.AddSection();
//Add paragraph to the section
IWParagraph paragraph = sec.AddParagraph();
//Load the excel file as stream
Stream excelStream = File.OpenRead("Excel_Template.xlsx");
//Create and Append chart to the paragraph with excel stream as parameter
WChart chart = paragraph.AppendChart(excelStream, 1, "B2:C6", 470, 300);
//Set chart type and title
chart.ChartType = OfficeChartType.Column_Clustered;
chart.ChartTitle = "Purchase Details";
chart.ChartTitleArea.FontName = "Calibri";
chart.ChartTitleArea.Size = 14;
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None;
//Set name to chart series
chart.Series[0].Name = "Sum of Purchases";
chart.Series[1].Name = "Sum of Future Expenses";
chart.PrimaryCategoryAxis.Title = "Products";
chart.PrimaryValueAxis.Title = "In Dollars";
//Set position of legend
chart.Legend.Position = OfficeLegendPosition.Bottom;
//Save the document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Load the excel file as stream
Dim excelStream As Stream = File.OpenRead("Excel_Template.xlsx")
'Create and Append chart to the paragraph with excel stream as parameter
Dim chart As WChart = paragraph.AppendChart(excelStream, 1, "B2:C6", 470, 300)
'Set chart type and title
chart.ChartType = OfficeChartType.Column_Clustered
chart.ChartTitle = "Purchase Details"
chart.ChartTitleArea.FontName = "Calibri"
chart.ChartTitleArea.Size = 14
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None
'Set name to chart series
chart.Series(0).Name = "Sum of Purchases"
chart.Series(1).Name = "Sum of Future Expenses"
chart.PrimaryCategoryAxis.Title = "Products"
chart.PrimaryValueAxis.Title = "In Dollars"
'Set position of legend
chart.Legend.Position = OfficeLegendPosition.Bottom
'Save the document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an instance of WordDocument class (Empty Word Document)
WordDocument document = new WordDocument();
//Add a new section into the Word Document
IWSection section = document.AddSection();
//Add a new paragraph into Word document and append text into paragraph
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("Today's Date: ");
//Add the new Date field in Word document with field name and its type.
WField field = paragraph.AppendField("Date", FieldType.FieldDate) as WField;
//Field code used to describe how to display the date
field.FieldCode = @"DATE \@" + "\"MMMM d, yyyy\"";
//Save the document in the given name and format
document.Save("Sample.docx", FormatType.Docx);
//Release the resources occupied by WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an instance of WordDocument class (Empty Word Document)
Dim document As New WordDocument()
'Add a new section into the Word Document
Dim section As IWSection = document.AddSection()
'Add a new paragraph into Word document and append text into paragraph
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("Today's Date: ")
'Add the new Date field in Word document with field name and its type.
Dim field As WField = TryCast(paragraph.AppendField("Date", FieldType.FieldDate), WField)
'Field code used to describe how to display the date
field.FieldCode = "DATE \@" + """MMMM d, yyyy"""
'Save the document in the given name and format
document.Save("Sample.docx", FormatType.Docx)
'Release the resources occupied by WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an instance of WordDocument class (Empty Word Document)
WordDocument document = new WordDocument();
//Add a new section into the Word Document
IWSection section = document.AddSection();
//Add a new paragraph into Word document and append text into paragraph
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("Northwind Database");
paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
//Add a paragraph into section
paragraph = section.AddParagraph();
//Add a new bookmark start into paragraph with name "Northwind"
paragraph.AppendBookmarkStart("Northwind");
//Add a text between the bookmark start and end into paragraph
paragraph.AppendText("The Northwind sample database (Northwind.mdb) is included with all versions of Access. It provides data you can experiment with and database objects that demonstrate features you might want to implement in your own databases.");
//Add a new bookmark end into paragraph with name " Northwind "
paragraph.AppendBookmarkEnd("Northwind");
//Add a text after the bookmark end
paragraph.AppendText(" Using Northwind, you can become familiar with how a relational database is structured and how the database objects work together to help you enter, store, manipulate, and print your data.");
//Save the document in the given name and format
document.Save("Bookmarks.docx", FormatType.Docx);
//Release the resources occupied by WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an instance of WordDocument class (Empty Word Document)
Dim document As New WordDocument()
'Add a new section into the Word Document
Dim section As IWSection = document.AddSection()
'Add a new paragraph into Word document and append text into paragraph
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("Northwind Database")
paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center
'Add a paragraph into section
paragraph = section.AddParagraph()
'Add a new bookmark start into paragraph with name "Northwind"
paragraph.AppendBookmarkStart("Northwind")
'Add a text between the bookmark start and end into paragraph
paragraph.AppendText("The Northwind sample database (Northwind.mdb) is included with all versions of Access. It provides data you can experiment with and database objects that demonstrate features you might want to implement in your own databases.")
'Add a new bookmark end into paragraph with name " Northwind "
paragraph.AppendBookmarkEnd("Northwind")
'Add a text after the bookmark end
paragraph.AppendText(" Using Northwind, you can become familiar with how a relational database is structured and how the database objects work together to help you enter, store, manipulate, and print your data.")
'Save the document in the given name and format
document.Save("Bookmarks.docx", FormatType.Docx)
'Release the resources occupied by WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an instance of WordDocument class (Empty Word Document)
WordDocument document = new WordDocument();
//Add a new section into the Word Document
IWSection section = document.AddSection();
//Add a new paragraph into Word document and append text into paragraph
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("Northwind Database");
paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
//Add a paragraph into section
paragraph = section.AddParagraph();
//Add a new bookmark start into paragraph with name "Northwind"
paragraph.AppendBookmarkStart("Northwind");
//Add a text between the bookmark start and end into paragraph
paragraph.AppendText("The Northwind sample database (Northwind.mdb) is included with all versions of Access. It provides data you can experiment with and database objects that demonstrate features you might want to implement in your own databases.");
//Add a new bookmark end into paragraph with name " Northwind "
paragraph.AppendBookmarkEnd("Northwind");
//Add a text after the bookmark end
paragraph.AppendText(" Using Northwind, you can become familiar with how a relational database is structured and how the database objects work together to help you enter, store, manipulate, and print your data.");
//Save the document in the given name and format
document.Save("Bookmarks.docx", FormatType.Docx);
//Release the resources occupied by WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an instance of WordDocument class (Empty Word Document)
Dim document As New WordDocument()
'Add a new section into the Word Document
Dim section As IWSection = document.AddSection()
'Add a new paragraph into Word document and append text into paragraph
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("Northwind Database")
paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center
'Add a paragraph into section
paragraph = section.AddParagraph()
'Add a new bookmark start into paragraph with name "Northwind"
paragraph.AppendBookmarkStart("Northwind")
'Add a text between the bookmark start and end into paragraph
paragraph.AppendText("The Northwind sample database (Northwind.mdb) is included with all versions of Access. It provides data you can experiment with and database objects that demonstrate features you might want to implement in your own databases.")
'Add a new bookmark end into paragraph with name " Northwind "
paragraph.AppendBookmarkEnd("Northwind")
'Add a text after the bookmark end
paragraph.AppendText(" Using Northwind, you can become familiar with how a relational database is structured and how the database objects work together to help you enter, store, manipulate, and print your data.")
'Save the document in the given name and format
document.Save("Bookmarks.docx", FormatType.Docx)
'Release the resources occupied by WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Creates a new Word document.
WordDocument document = new WordDocument();
//Add a section and a paragraph in the document
document.EnsureMinimal();
IWParagraph paragraph = document.LastParagraph;
//Append text to the paragraph
paragraph.AppendText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua");
//Add comment to a paragraph
WComment comment = paragraph.AppendComment("comment test");
//Specify the author of the comment
comment.Format.User = "Peter";
//Specify the initial of the author
comment.Format.UserInitials = "St";
//Save and close the Word document
document.Save("Comment.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Creates a new Word document.
Dim document As New WordDocument()
'Add a section and a paragraph in the document
document.EnsureMinimal()
Dim paragraph As IWParagraph = document.LastParagraph
'Append text to the paragraph
paragraph.AppendText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua")
'Add comment to a paragraph
Dim comment As WComment = paragraph.AppendComment("comment test")
'Specify the author of the comment
comment.Format.User = "Peter"
'Specify the initial of the author
comment.Format.UserInitials = "St"
'Save and close the Word document
document.Save("Comment.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Create a section
IWSection section = document.AddSection();
//Add a paragraph to a section
IWParagraph paragraph = section.AddParagraph();
//Append the text to paragraph
paragraph.AppendText("Working with footnotes");
//Formatting the text
paragraph.ApplyStyle(BuiltinStyle.Heading1);
//Add a paragraph to a section
paragraph = section.AddParagraph();
//Append the footnotes
WFootnote footnote = (WFootnote) paragraph.AppendFootnote(Syncfusion.DocIO.FootnoteType.Footnote);
//Set the footnote character format
footnote.MarkerCharacterFormat.SubSuperScript = SubSuperScript.SuperScript;
//Inserts the text into the paragraph
paragraph.AppendText("Sample content for footnotes").CharacterFormat.Bold = true;
//Add footnote text
paragraph = footnote.TextBody.AddParagraph();
paragraph.AppendText("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");
//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()
'Create a section
Dim section As IWSection = document.AddSection()
'Add a paragraph to a section
Dim paragraph As IWParagraph = section.AddParagraph()
'Append the text to paragraph
paragraph.AppendText("Working with footnotes")
'Formatting the text
paragraph.ApplyStyle(BuiltinStyle.Heading1)
'Add a paragraph to a section
paragraph = section.AddParagraph()
'Append the footnotes
Dim footnote As WFootnote = DirectCast(paragraph.AppendFootnote(Syncfusion.DocIO.FootnoteType.Footnote), WFootnote)
'Set the footnote character format
footnote.MarkerCharacterFormat.SubSuperScript = SubSuperScript.SuperScript
'Inserts the text into the paragraph
paragraph.AppendText("Sample content for footnotes").CharacterFormat.Bold = True
'Add footnote text
paragraph = footnote.TextBody.AddParagraph()
paragraph.AppendText("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")
�Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new document
WordDocument document = new WordDocument();
//Create a section
IWSection section = document.AddSection();
//Add a paragraph to a section
IWParagraph paragraph = section.AddParagraph();
//Append the text to paragraph
paragraph.AppendText("Working with endnotes");
//Formatting the text
paragraph.ApplyStyle(BuiltinStyle.Heading1);
//Add a paragraph to a section
paragraph = section.AddParagraph();
//Append the endnote
WFootnote endnote = (WFootnote) paragraph.AppendFootnote(Syncfusion.DocIO.FootnoteType.Endnote);
//Set the endnote character format
endnote.MarkerCharacterFormat.SubSuperScript = SubSuperScript.SuperScript;
//Insert the text into the paragraph
paragraph.AppendText("Sample content for endnotes").CharacterFormat.Bold = true;
//Add footnote text
paragraph = endnote.TextBody.AddParagraph();
paragraph.AppendText("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");
//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 document
Dim document As New WordDocument()
'Create a section
Dim section As IWSection = document.AddSection()
'Add a paragraph to a section
Dim paragraph As IWParagraph = section.AddParagraph()
'Append the text to paragraph
paragraph.AppendText("Working with endnotes")
'Formatting the text
paragraph.ApplyStyle(BuiltinStyle.Heading1)
'Add a paragraph to a section
paragraph = section.AddParagraph()
'Append the endnote
Dim endnote As WFootnote = DirectCast(paragraph.AppendFootnote(Syncfusion.DocIO.FootnoteType.Endnote), WFootnote)
'Set the endnote character format
endnote.MarkerCharacterFormat.SubSuperScript = SubSuperScript.SuperScript
'Insert the text into the paragraph
paragraph.AppendText("Sample content for endnotes").CharacterFormat.Bold = True
'Add footnote text
paragraph = endnote.TextBody.AddParagraph()
paragraph.AppendText("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")
�Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Append new textbox to the paragraph
IWTextBox textbox = paragraph.AppendTextBox(150, 75);
//Add new text to the textbox body
IWParagraph textboxParagraph = textbox.TextBoxBody.AddParagraph();
textboxParagraph.AppendText("Text inside text box");
//Save and close the Word 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()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Append new textbox to the paragraph
Dim textbox As IWTextBox = paragraph.AppendTextBox(150, 75)
'Add new text to the textbox body
Dim textboxParagraph As IWParagraph = textbox.TextBoxBody.AddParagraph()
textboxParagraph.AppendText("Text inside text box")
'Save and close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("Example of adding symbols to the paragraph: ");
//Insert symbol with character code 100
paragraph.AppendSymbol(100);
//Save and close the Word 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()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("Example of adding symbols to the paragraph: ")
'Insert symbol with character code 100
paragraph.AppendSymbol(100)
'Save and close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("Before line break");
//Add line break to the paragraph
paragraph.AppendBreak(BreakType.LineBreak);
paragraph.AppendText("After line break");
IWParagraph pageBreakPara = section.AddParagraph();
pageBreakPara.AppendText("Before page break");
//Add page break to the paragraph
pageBreakPara.AppendBreak(BreakType.PageBreak);
pageBreakPara.AppendText("After page break");
IWSection secondSection = document.AddSection();
//Add columns to the section
secondSection.AddColumn(100, 2);
secondSection.AddColumn(100, 2);
IWParagraph columnBreakPara = secondSection.AddParagraph();
columnBreakPara.AppendText("Before column break");
//Add column break to the paragraph
columnBreakPara.AppendBreak(BreakType.ColumnBreak);
columnBreakPara.AppendText("After column break");
//Save and Close the 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 new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("Before line break")
'Add line break to the paragraph
paragraph.AppendBreak(BreakType.LineBreak)
paragraph.AppendText("After line break")
Dim pageBreakPara As IWParagraph = section.AddParagraph()
pageBreakPara.AppendText("Before page break")
'Add page break to the paragraph
pageBreakPara.AppendBreak(BreakType.PageBreak)
pageBreakPara.AppendText("After page break")
Dim secondSection As IWSection = document.AddSection()
'Add columns to the section
secondSection.AddColumn(100, 2)
secondSection.AddColumn(100, 2)
Dim columnBreakPara As IWParagraph = secondSection.AddParagraph()
columnBreakPara.AppendText("Before column break")
'Add column break to the paragraph
columnBreakPara.AppendBreak(BreakType.ColumnBreak)
columnBreakPara.AppendText("After column break")
'Save and Close the document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
WParagraph paragraph = section.AddParagraph() as WParagraph;
//Add new shape to the document
Shape rectangle = paragraph.AppendShape(AutoShapeType.RoundedRectangle, 150, 100);
//Set position for shape
rectangle.VerticalPosition = 72;
rectangle.HorizontalPosition = 72;
paragraph = section.AddParagraph() as WParagraph;
//Add text body contents to the shape
paragraph = rectangle.TextBody.AddParagraph() as WParagraph;
IWTextRange text = paragraph.AppendText("This text is in rounded rectangle shape");
text.CharacterFormat.TextColor = Color.Green;
text.CharacterFormat.Bold = true;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As WParagraph = TryCast(section.AddParagraph(), WParagraph)
'Add new shape to the document
Dim rectangle As Shape = paragraph.AppendShape(AutoShapeType.RoundedRectangle, 150, 100)
'Set position for shape
rectangle.VerticalPosition = 72
rectangle.HorizontalPosition = 72
paragraph = TryCast(section.AddParagraph(), WParagraph)
'Add text body contents to the shape
paragraph = TryCast(rectangle.TextBody.AddParagraph(), WParagraph)
Dim text As IWTextRange = paragraph.AppendText("This text is in rounded rectangle shape")
text.CharacterFormat.TextColor = Color.Green
text.CharacterFormat.Bold = True
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the template document
WordDocument document = new WordDocument("Template.docx");
//Html string to be inserted
string htmlstring = "This text is inserted as HTML string.
";
IWParagraph paragraph = document.Sections[0].Body.Paragraphs[0];
//Append the Html string to first paragraph in the document
paragraph.AppendHTML(htmlstring);
//Save and close the document
document.Save("Sample.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document
Dim document As New WordDocument("Template.docx")
'Html string to be inserted
Dim htmlstring As String = "This text is inserted as HTML string.
"
Dim paragraph As IWParagraph = document.Sections(0).Body.Paragraphs(0)
'Append the Html string to first paragraph in the document
paragraph.AppendHTML(htmlstring)
'Save and close the document
document.Save("Sample.docx")
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
WParagraph paragraph = document.Sections[0].Paragraphs[1];
//Find the first occurrence of a particular text in the paragraph
TextSelection textSelection = paragraph.Find("panda", true, true);
//Get the found text as single text range
WTextRange textRange = textSelection.GetAsOneRange();
//Modify the text
textRange.Text = "Replaced text";
//Set highlight color
textRange.CharacterFormat.HighlightColor = Color.Yellow;
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
Dim paragraph As WParagraph = document.Sections(0).Paragraphs(1)
'Find the first occurrence of a particular text in the paragraph
Dim textSelection As TextSelection = paragraph.Find("panda", true, true)
'Get the found text as single text range
Dim textRange As WTextRange = textSelection.GetAsOneRange()
'Modify the text
textRange.Text = "Replaced text"
'Set highlight color
textRange.CharacterFormat.HighlightColor = Color.Yellow
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
WParagraph paragraph = document.Sections[0].Paragraphs[1];
//Find the first occurrence of the regular expression
TextSelection selection = paragraph.Find(new Regex("Panda"));
//Replace all occurrence of a particular regular expression with the text selection in the paragraph
paragraph.Replace("Giant panda", selection, true, false);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
Dim paragraph As WParagraph = document.Sections(0).Paragraphs(1)
'Find the first occurrence of the regular expression
Dim selection As TextSelection = paragraph.Find(New Regex("Panda"))
'Replace all occurrence of a particular regular expression with the text selection in the paragraph
paragraph.Replace("Giant panda", selection, True, False)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
WParagraph paragraph = document.Sections[0].Paragraphs[1];
//Find the first occurrence of the regular expression
TextSelection selection = paragraph.Find(new Regex("Panda"));
//Replace all occurrence of a particular regular expression with the text selection in the paragraph
paragraph.Replace("Giant panda", selection, true, false, true);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
Dim paragraph As WParagraph = document.Sections(0).Paragraphs(1)
'Find the first occurrence of the regular expression
Dim selection As TextSelection = paragraph.Find(New Regex("Panda"))
'Replace all occurrence of a particular regular expression with the text selection in the paragraph
paragraph.Replace("Giant panda", selection, True, False, False)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
WParagraph paragraph = section.AddParagraph() as WParagraph;
paragraph.AppendText("Gender\t");
//Append new Checkbox
WCheckBox checkbox = paragraph.AppendCheckBox();
checkbox.Checked = false;
//Set Checkbox size
checkbox.CheckBoxSize = 10;
checkbox.CalculateOnExit = true;
//Set help text
checkbox.Help = "Help text";
paragraph.AppendText("Male\t");
checkbox = paragraph.AppendCheckBox();
checkbox.Checked = false;
checkbox.CheckBoxSize = 10;
checkbox.CalculateOnExit = true;
paragraph.AppendText("Female");
//Save the Word document
document.Save("Checkbox.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As WParagraph = TryCast(section.AddParagraph(), WParagraph)
paragraph.AppendText("Gender" & vbTab)
'Append new Checkbox
Dim checkbox As WCheckBox = paragraph.AppendCheckBox()
checkbox.Checked = False
'Set Checkbox size
checkbox.CheckBoxSize = 10
checkbox.CalculateOnExit = True
'Set help text
checkbox.Help = "Help text"
paragraph.AppendText("Male" & vbTab)
checkbox = paragraph.AppendCheckBox()
checkbox.Checked = False
checkbox.CheckBoxSize = 10
checkbox.CalculateOnExit = True
paragraph.AppendText("Female")
'Save the Word document
document.Save("Checkbox.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
WParagraph paragraph = section.AddParagraph() as WParagraph;
paragraph.AppendText("General Information");
section.AddParagraph();
paragraph = section.AddParagraph() as WParagraph;
IWTextRange text = paragraph.AppendText("Name\t");
text.CharacterFormat.Bold = true;
//Append Text form field
WTextFormField textfield = paragraph.AppendTextFormField(null);
//Set type of Text form field
textfield.Type = TextFormFieldType.RegularText;
textfield.CharacterFormat.FontName = "Calibri";
textfield.CalculateOnExit = true;
//Save the Word document
document.Save("Textfield.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As WParagraph = TryCast(section.AddParagraph(), WParagraph)
paragraph.AppendText("General Information")
section.AddParagraph()
paragraph = TryCast(section.AddParagraph(), WParagraph)
Dim text As IWTextRange = paragraph.AppendText("Name" & vbTab)
text.CharacterFormat.Bold = True
'Append Text form field
Dim textfield As WTextFormField = paragraph.AppendTextFormField(Nothing)
'Set type of Text form field
textfield.Type = TextFormFieldType.RegularText
textfield.CharacterFormat.FontName = "Calibri"
textfield.CalculateOnExit = True
'Save the Word document
document.Save("Textfield.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
WParagraph paragraph = section.AddParagraph() as WParagraph;
paragraph.AppendText("Gender\t");
//Append new Checkbox
WCheckBox checkbox = paragraph.AppendCheckBox("CheckBox1", true);
//checkbox.Checked = false;
//Set Checkbox size
checkbox.CheckBoxSize = 10;
checkbox.CalculateOnExit = true;
//Set help text
checkbox.Help = "Help text";
paragraph.AppendText("Male\t");
checkbox = paragraph.AppendCheckBox("CheckBox2",false);
//checkbox.Checked = false;
checkbox.CheckBoxSize = 10;
checkbox.CalculateOnExit = true;
paragraph.AppendText("Female");
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As WParagraph = TryCast(section.AddParagraph(), WParagraph)
paragraph.AppendText("Gender" & vbTab)
'Append new Checkbox
Dim checkbox As WCheckBox = paragraph.AppendCheckBox("CheckBox1", True)
'checkbox.Checked = false;
'Set Checkbox size
checkbox.CheckBoxSize = 10
checkbox.CalculateOnExit = True
'Set help text
checkbox.Help = "Help text"
paragraph.AppendText("Male" & vbTab)
checkbox = paragraph.AppendCheckBox("CheckBox2", False)
'checkbox.Checked = false;
checkbox.CheckBoxSize = 10
checkbox.CalculateOnExit = True
paragraph.AppendText("Female")
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
WParagraph paragraph = section.AddParagraph() as WParagraph;
paragraph.AppendText("General Information");
section.AddParagraph();
paragraph = section.AddParagraph() as WParagraph;
IWTextRange text = paragraph.AppendText("Date of Birth\t");
text.CharacterFormat.Bold = true;
//Append Text form field
WTextFormField textfield = paragraph.AppendTextFormField("Date field", DateTime.Now.ToString("MM/DD/YY"));
textfield.StringFormat = "MM/DD/YY";
//Set Text form field type
textfield.Type = TextFormFieldType.DateText;
textfield.CalculateOnExit = true;
//Save the Word document
document.Save("Textfield.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As WParagraph = TryCast(section.AddParagraph(), WParagraph)
paragraph.AppendText("General Information")
section.AddParagraph()
paragraph = TryCast(section.AddParagraph(), WParagraph)
Dim text As IWTextRange = paragraph.AppendText("Date of Birth" & vbTab)
text.CharacterFormat.Bold = True
'Append Text form field
Dim textfield As WTextFormField = paragraph.AppendTextFormField("Date field", DateTime.Now.ToString("MM/DD/YY"))
textfield.StringFormat = "MM/DD/YY"
'Set Text form field type
textfield.Type = TextFormFieldType.DateText
textfield.CalculateOnExit = True
'Save the Word document
document.Save("Textfield.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
WParagraph paragraph = section.AddParagraph() as WParagraph;
paragraph.AppendText("Educational Qualification\t");
//Append Dropdown field
WDropDownFormField dropdownfield = paragraph.AppendDropDownFormField("FieldName");
//Add items to the dropdown items collection
dropdownfield.DropDownItems.Add("Higher");
dropdownfield.DropDownItems.Add("Vocational");
dropdownfield.DropDownItems.Add("Universal");
dropdownfield.Enabled = true;
//Set the item index for default value
dropdownfield.DropDownSelectedIndex = 1;
dropdownfield.CalculateOnExit = true;
//Save the Word document
document.Save("Dropdown.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As WParagraph = TryCast(section.AddParagraph(), WParagraph)
paragraph.AppendText("Educational Qualification" & vbTab)
'Append Dropdown field
Dim dropdownfield As WDropDownFormField = paragraph.AppendDropDownFormField("FieldName")
'Add items to the dropdown items collection
dropdownfield.DropDownItems.Add("Higher")
dropdownfield.DropDownItems.Add("Vocational")
dropdownfield.DropDownItems.Add("Universal")
dropdownfield.Enabled = True
'Set the item index for default value
dropdownfield.DropDownSelectedIndex = 1
dropdownfield.CalculateOnExit = True
'Save the Word document
document.Save("Dropdown.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("Web Hyperlink: ");
paragraph = section.AddParagraph();
//Append web hyperlink to the paragraph
IWField field = paragraph.AppendHyperlink("http://www.syncfusion.com", "Syncfusion", HyperlinkType.WebLink);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("Web Hyperlink: ")
paragraph = section.AddParagraph()
'Append web hyperlink to the paragraph
Dim field As IWField = paragraph.AppendHyperlink("http://www.syncfusion.com", "Syncfusion", HyperlinkType.WebLink)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("Image Hyperlink");
paragraph = section.AddParagraph();
//Create a new image instance and load image
WPicture picture = new WPicture(document);
picture.LoadImage(Image.FromFile("Image.png"));
//Append new image hyperlink to the paragraph
paragraph.AppendHyperlink("http://www.syncfusion.com", picture, HyperlinkType.WebLink);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("Image Hyperlink")
paragraph = section.AddParagraph()
'Create a new image instance and load image
Dim picture As New WPicture(document)
picture.LoadImage(Image.FromFile("Image.png"))
'Append new image hyperlink to the paragraph
paragraph.AppendHyperlink("http://www.syncfusion.com", picture, HyperlinkType.WebLink)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add the section into the Word document
IWSection section = document.AddSection();
string paraText = "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";
//Add the paragraph into the created section
IWParagraph paragraph = section.AddParagraph();
//Append the TOC field with LowerHeadingLevel and UpperHeadingLevel to determines the TOC entries
paragraph.AppendTOC(1, 3);
//Add the section into the Word document
section = document.AddSection();
//Add the paragraph into the created section
paragraph = section.AddParagraph();
//Add the text for the headings
paragraph.AppendText("First Chapter");
//Set a build in heading style.
paragraph.ApplyStyle(BuiltinStyle.Heading1);
//Add the text into the paragraph
section.AddParagraph().AppendText(paraText);
//Add the section into the Word document
section = document.AddSection();
//Add the paragraph into the created section
paragraph = section.AddParagraph();
//Add the text for the headings
paragraph.AppendText("Second Chapter");
//Set a build in heading style.
paragraph.ApplyStyle(BuiltinStyle.Heading2);
//Add the text into the paragraph
section.AddParagraph().AppendText(paraText);
//Add the section into the Word document
section = document.AddSection();
//Add the paragraph into the created section
paragraph = section.AddParagraph();
//Add the text into the headings
paragraph.AppendText("Third Chapter");
//Set a build in heading style
paragraph.ApplyStyle(BuiltinStyle.Heading3);
//Add the text into the paragraph.
section.AddParagraph().AppendText(paraText);
//Update the table of contents
document.UpdateTableOfContents();
//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 the Word document
Dim section As IWSection = document.AddSection()
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"
'Add the paragraph into the created section
Dim paragraph As IWParagraph = section.AddParagraph()
'Append the TOC field with LowerHeadingLevel and UpperHeadingLevel to determines the TOC entries
paragraph.AppendTOC(1, 3)
'Add the section into the Word document
section = document.AddSection()
'Add the paragraph into the created section
paragraph = section.AddParagraph()
'Add the text for the headings
paragraph.AppendText("First Chapter")
'Set a build in heading style
paragraph.ApplyStyle(BuiltinStyle.Heading1)
'Add the text into the paragraph.
section.AddParagraph().AppendText(paraText)
'Add the section into the Word document
section = document.AddSection()
'Add the paragraph into the created section
paragraph = section.AddParagraph()
'Add the text for the headings
paragraph.AppendText("Second Chapter")
'Set a build in heading style
paragraph.ApplyStyle(BuiltinStyle.Heading2)
'Add the text into the paragraph
section.AddParagraph().AppendText(paraText)
'Add the section into the Word document
section = document.AddSection()
'Add the paragraph into the created section
paragraph = section.AddParagraph()
'Add the text into the headings
paragraph.AppendText("Third Chapter")
'Set a build in heading style
paragraph.ApplyStyle(BuiltinStyle.Heading3)
'Add the text into the paragraph
section.AddParagraph().AppendText(paraText)
'Update the table of contents
document.UpdateTableOfContents()
�Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
IWParagraph paragraph = section.AddParagraph();
//Add text, bookmark start and end in the paragraph
paragraph.AppendBookmarkStart("Title");
paragraph.AppendText("Northwind Database");
paragraph.AppendBookmarkEnd("Title");
paragraph = section.AddParagraph();
paragraph.AppendText("The Northwind sample database (Northwind.mdb) is included with all versions of Access. It provides data you can experiment with and database objects that demonstrate features you might want to implement in your own databases.");
section = document.AddSection();
section.AddParagraph();
paragraph = section.AddParagraph() as WParagraph;
//Get the collection of bookmark start in the word document
List<Entity> items = document.GetCrossReferenceItems(ReferenceType.Bookmark);
paragraph.AppendText("Bookmark Cross Reference starts here ");
//Append the cross reference for bookmark �Title� with ContentText as reference kind
paragraph.AppendCrossReference(ReferenceType.Bookmark, ReferenceKind.ContentText, items[0], true, false, false, string.Empty);
//Update the document Fields
document.UpdateDocumentFields();
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()
Dim section As IWSection = document.AddSection()
Dim paragraph As IWParagraph = section.AddParagraph()
'Add text, bookmark start and end in the paragraph
paragraph.AppendBookmarkStart("Title")
paragraph.AppendText("Northwind Database")
paragraph.AppendBookmarkEnd("Title")
paragraph = section.AddParagraph()
paragraph.AppendText("The Northwind sample database (Northwind.mdb) is included with all versions of Access. It provides data you can experiment with and database objects that demonstrate features you might want to implement in your own databases.")
section = document.AddSection()
section.AddParagraph()
paragraph = TryCast(section.AddParagraph(), WParagraph)
'Get the collection of bookmark start in the word document
Dim items As List(Of Entity) = document.GetCrossReferenceItems(ReferenceType.Bookmark)
paragraph.AppendText("Bookmark Cross Reference starts here ")
'Append the cross reference for bookmark �Title� with ContentText as reference kind
paragraph.AppendCrossReference(ReferenceType.Bookmark, ReferenceKind.ContentText, items(0), True, False, False, String.Empty)
'Update the document Fields
document.UpdateDocumentFields()
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Open the file to be embedded
FileStream stream = new FileStream("Book1.xlsx", FileMode.Open);
//Load the picture instance with the image need to be displayed
WPicture picture = new WPicture(document);
picture.LoadImage(Image.FromFile("Image.png"));
//Append the Ole object to the paragraph
WOleObject ole = paragraph.AppendOleObject(stream, picture, OleObjectType.ExcelWorksheet);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Open the file to be embedded
Dim stream As New FileStream("Book1.xlsx", FileMode.Open)
'Load the picture instance with the image need to be displayed
Dim picture As New WPicture(document)
picture.LoadImage(Image.FromFile("Image.png"))
'Append the Ole object to the paragraph
Dim ole As WOleObject = paragraph.AppendOleObject(stream, picture, OleObjectType.ExcelWorksheet)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add section to the document
IWSection sec = document.AddSection();
//Add paragraph to the section
IWParagraph paragraph = sec.AddParagraph();
//Load the picture instance with the image need to be displayed
WPicture picture = new WPicture(document);
picture.LoadImage(Image.FromFile("Image.png"));
//Get the file as byte array
byte[] olebytes = File.ReadAllBytes("Excel_Template.xlsx");
paragraph = sec.AddParagraph();
//Append OLE object
paragraph.AppendOleObject(olebytes, picture, OleObjectType.ExcelWorksheet);
//Save the Word document
document.Save("Sample.docx", FormatType.Word2010);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Load the picture instance with the image need to be displayed
Dim picture As New WPicture(document)
picture.LoadImage(Image.FromFile("Image.png"))
'Get the file as byte array
Dim olebytes As Byte() = File.ReadAllBytes("Excel_Template.xlsx")
paragraph = sec.AddParagraph()
'Append OLE object
paragraph.AppendOleObject(olebytes, picture, OleObjectType.ExcelWorksheet)
'Save the Word document
document.Save("Sample.docx", FormatType.Word2010)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add section to the document
IWSection sec = document.AddSection();
//Add paragraph to the section
IWParagraph paragraph = sec.AddParagraph();
//Load the picture instance with the image need to be displayed
WPicture picture = new WPicture(document);
picture.LoadImage(Image.FromFile("Image.png"));
FileStream stream = new FileStream("Excel_Template.xlsx", FileMode.Open);
WOleObject ole = paragraph.AppendOleObject(stream, picture, OleLinkType.Embed);
ole.ObjectType = "Excel Worksheet";
//Save the Word document
document.Save("Sample.docx", FormatType.Word2010);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Load the picture instance with the image need to be displayed
Dim picture As New WPicture(document)
picture.LoadImage(Image.FromFile("Image.png"))
Dim stream As New FileStream("Excel_Template.xlsx", FileMode.Open)
Dim ole As WOleObject = paragraph.AppendOleObject(stream, picture, OleLinkType.Embed)
ole.ObjectType = "Excel Worksheet"
'Save the Word document
document.Save("Sample.docx", FormatType.Word2010)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add section to the document
IWSection sec = document.AddSection();
//Add paragraph to the section
IWParagraph paragraph = sec.AddParagraph();
//Load the picture instance with the image need to be displayed
WPicture picture = new WPicture(document);
picture.LoadImage(Image.FromFile("Image.png"));
//Get the file as byte array
byte[] olebytes = File.ReadAllBytes("Excel_Template.xlsx");
WOleObject ole = paragraph.AppendOleObject(olebytes, picture, OleLinkType.Embed);
ole.ObjectType = "Excel Worksheet";
//Save the Word document
document.Save("Sample.docx", FormatType.Word2010);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Load the picture instance with the image need to be displayed
Dim picture As New WPicture(document)
picture.LoadImage(Image.FromFile("Image.png"))
'Get the file as byte array
Dim olebytes As Byte() = File.ReadAllBytes("Excel_Template.xlsx")
Dim ole As WOleObject = paragraph.AppendOleObject(olebytes, picture, OleLinkType.Embed)
ole.ObjectType = "Excel Worksheet"
'Save the Word document
document.Save("Sample.docx", FormatType.Word2010)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add section to the document
IWSection sec = document.AddSection();
//Add paragraph to the section
IWParagraph paragraph = sec.AddParagraph();
//Load the picture instance with the image need to be displayed
WPicture picture = new WPicture(document);
picture.LoadImage(Image.FromFile("Image.png"));
//Get the file as byte array
byte[] olebytes = File.ReadAllBytes("Excel_Template.xlsx");
paragraph = sec.AddParagraph();
//Append OLE object
paragraph.AppendOleObject(olebytes, picture, ".xlsx");
//Save the Word document
document.Save("Sample.docx", FormatType.Word2010);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Load the picture instance with the image need to be displayed
Dim picture As New WPicture(document)
picture.LoadImage(Image.FromFile("Image.png"))
'Get the file as byte array
Dim olebytes As Byte() = File.ReadAllBytes("Excel_Template.xlsx")
paragraph = sec.AddParagraph()
'Append OLE object
paragraph.AppendOleObject(olebytes, picture, ".xlsx")
'Save the Word document
document.Save("Sample.docx", FormatType.Word2010)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Open the file to be embedded
FileStream stream = new FileStream("Excel_Template.xlsx", FileMode.Open);
//Load the picture instance with the image need to be displayed
WPicture picture = new WPicture(document);
picture.LoadImage(Image.FromFile("Image.png"));
//Append the Ole object to the paragraph
WOleObject ole = paragraph.AppendOleObject(stream, picture, "xlsx");
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Open the file to be embedded
Dim stream As New FileStream("Excel_Template.xlsx", FileMode.Open)
'Load the picture instance with the image need to be displayed
Dim picture As New WPicture(document)
picture.LoadImage(Image.FromFile("Image.png"))
'Append the Ole object to the paragraph
Dim ole As WOleObject = paragraph.AppendOleObject(stream, picture, "xlsx")
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add section to the document
IWSection sec = document.AddSection();
//Add paragraph to the section
IWParagraph paragraph = sec.AddParagraph();
//Load the picture instance with the image need to be displayed
WPicture picture = new WPicture(document);
picture.LoadImage(Image.FromFile("Image.png"));
paragraph = sec.AddParagraph();
paragraph.AppendOleObject(@"..\..\Data\Excel_Template.xlsx", picture, OleObjectType.ExcelWorksheet);
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 section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Load the picture instance with the image need to be displayed
Dim picture As New WPicture(document)
picture.LoadImage(Image.FromFile("Image.png"))
paragraph = sec.AddParagraph()
paragraph.AppendOleObject("..\..\Data\Excel_Template.xlsx", picture, OleObjectType.ExcelWorksheet)
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add section to the document
IWSection sec = document.AddSection();
//Add paragraph to the section
IWParagraph paragraph = sec.AddParagraph();
//Load the picture instance with the image need to be displayed
WPicture picture = new WPicture(document);
picture.LoadImage(Image.FromFile("Image.png"));
WOleObject ole = paragraph.AppendOleObject(@"..\..\Data\Excel_Template.xlsx", picture);
//Set how to display the Ole object
ole.DisplayAsIcon = false;
//Save and close the document
document.Save("Sample.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Load the picture instance with the image need to be displayed
Dim picture As New WPicture(document)
picture.LoadImage(Image.FromFile("Image.png"))
Dim ole As WOleObject = paragraph.AppendOleObject("..\..\Data\Excel_Template.xlsx", picture)
'Set how to display the Ole object
ole.DisplayAsIcon = False
'Save and close the document
document.Save("Sample.docx")
document.Close()
End Sub
//Create a new Word document
using(WordDocument wordDocument = new WordDocument())
{
//Adds one section and one paragraph to the document
wordDocument.EnsureMinimal();
//Appends a new mathematical equation to the paragraph using LaTeX syntax.
wordDocument.LastParagraph.AppendMath(@"\dot{a}");
//Saves the Word document
wordDocument.Save("Result.docx", FormatType.Docx);
}
'Create a new Word document
Dim wordDocument As New WordDocument()
'Adds one section and one paragraph to the document
wordDocument.EnsureMinimal()
'Appends a new mathematical equation to the paragraph using LaTeX syntax.
wordDocument.LastParagraph.AppendMath("\dot{a}")
'Saves the Word document
wordDocument.Save("Result.docx", FormatType.Docx)
'Close the document
wordDocument.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
document.EnsureMinimal();
//Add text to the first section
document.LastParagraph.AppendText("First section");
//Insert section break
WSection newsection = document.LastParagraph.InsertSectionBreak();
//Add new paragraph to the second section
IWParagraph paragraph = newsection.AddParagraph();
paragraph.AppendText("Second 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()
document.EnsureMinimal()
'Add text to the first section
document.LastParagraph.AppendText("First section")
'Insert section break
Dim newsection As WSection = document.LastParagraph.InsertSectionBreak()
'Add new paragraph to the second section
Dim paragraph As IWParagraph = newsection.AddParagraph()
paragraph.AppendText("Second section")
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
document.EnsureMinimal();
//Add text to the first section
document.LastParagraph.AppendText("First section");
//Insert section break
WSection newsection = document.LastParagraph.InsertSectionBreak(SectionBreakCode.Oddpage);
//Add new paragraph to the second section
IWParagraph paragraph = newsection.AddParagraph();
paragraph.AppendText("Second 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()
document.EnsureMinimal()
'Add text to the first section
document.LastParagraph.AppendText("First section")
'Insert section break
Dim newsection As WSection = document.LastParagraph.InsertSectionBreak(SectionBreakCode.Oddpage)
'Add new paragraph to the second section
Dim paragraph As IWParagraph = newsection.AddParagraph()
paragraph.AppendText("Second section")
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
// Loads an existing Word document into DocIO instance.
WordDocument document = new WordDocument("Template.docx");
//Gets the document text
document.GetText();
// Gets a numeric string value of the numbering list paragraph.
String listString = document.LastParagraph.ListString;
// Saves the document in the given name and format.
document.Save("Document.docx", FormatType.Docx);
// Releases the resources occupied by WordDocument instance.
document.Close();
' Loads an existing Word document into DocIO instance.
Dim document As WordDocument = New WordDocument("Template.docx")
' Gets the document text.
document.GetText()
' Gets a numeric string value of the numbering list paragraph
Dim listString As String = document.LastParagraph.ListString
' Saves the document in the given name and format.
document.Save("Document.docx", FormatType.Docx)
' Releases the resources occupied by WordDocument instance.
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new text to the paragraph
IWTextRange text = paragraph.AppendText("A new text is added to the paragraph.");
text.CharacterFormat.FontSize = 14;
text.CharacterFormat.Bold = true;
text.CharacterFormat.TextColor = Color.Green;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new text to the paragraph
Dim text As IWTextRange = paragraph.AppendText("A new text is added to the paragraph.")
text.CharacterFormat.FontSize = 14
text.CharacterFormat.Bold = True
text.CharacterFormat.TextColor = Color.Green
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new inline control to the paragraph
IInlineContentControl inlineControl = paragraph.AppendInlineContentControl(ContentControlType.RichText);
WTextRange controlText = new WTextRange(document);
controlText.CharacterFormat.Bold = true;
controlText.CharacterFormat.TextColor = Color.Green;
controlText.Text = "Inline content control inserted.";
//Add text range to the control added
inlineControl.ParagraphItems.Add(controlText);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new inline control to the paragraph
Dim inlineControl As IInlineContentControl = paragraph.AppendInlineContentControl(ContentControlType.RichText)
Dim textRange As New WTextRange(document)
textRange.CharacterFormat.Bold = True
textRange.CharacterFormat.TextColor = Color.Green
textRange.Text = "Inline content control inserted."
'Add text range to the control added
inlineControl.ParagraphItems.Add(textRange)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph firstParagraph = section.AddParagraph();
//Get the image and convert to byte array.
Image image = Image.FromFile("Image.png");
MemoryStream stream = new MemoryStream();
image.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
byte[] imageBytes = stream.ToArray();
//Add image to the paragraph
IWPicture picture = firstParagraph.AppendPicture(imageBytes);
//Set height and width for the image
picture.Height = 100;
picture.Width = 100;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim firstParagraph As IWParagraph = section.AddParagraph()
'Get the image and convert to byte array.
Dim image__1 As Image = Image.FromFile("Image.png")
Dim stream As New MemoryStream()
image__1.Save(stream, System.Drawing.Imaging.ImageFormat.Png)
Dim imageBytes As Byte() = stream.ToArray()
'Add image to the paragraph
Dim picture As IWPicture = firstParagraph.AppendPicture(imageBytes)
'Set height and width for the image
picture.Height = 100
picture.Width = 100
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph firstParagraph = section.AddParagraph();
//Get the image as byte array.
byte[] imageBytes = File.ReadAllBytes("Image.png");
//Get the SVG image as byte array.
byte[] svgData = File.ReadAllBytes("Image.svg");
//Add SVG image to the paragraph
IWPicture picture = firstParagraph.AppendPicture(svgData, imageBytes);
//Set height and width for the image
picture.Height = 100;
picture.Width = 100;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim firstParagraph As IWParagraph = section.AddParagraph()
'Get the png image as byte array.
Dim imageBytes As Byte() = File.ReadAllBytes("Image.png")
'Get the SVG image as byte array.
Dim svgData As Byte() = File.ReadAllBytes("Image.svg")
'Add SVG image to the paragraph
Dim picture As IWPicture = firstParagraph.AppendPicture(svgData, imageBytes);
'Set height and width for the image
picture.Height = 100
picture.Width = 100
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add section to the document
IWSection sec = document.AddSection();
//Add paragraph to the section
IWParagraph paragraph = sec.AddParagraph();
//Input data for chart
object[][] data = new object[6][];
for (int i = 0; i < 6; i++)
data[i] = new object[3];
data[0][0] = "";
data[1][0] = "Gravad lax";
data[2][0] = "Louisiana Hot spiced Okara";
data[3][0] = "Mascarpone Fabioli";
data[4][0] = "Wimmers gute SemmelKnodel";
data[5][0] = "Maxilaku";
data[0][1] = "Sum of Purchases";
data[1][1] = 286;
data[2][1] = 680;
data[3][1] = 288;
data[4][1] = 200;
data[5][1] = 731;
data[0][2] = "Sum of Future Expenses";
data[1][2] = 1300;
data[2][2] = 700;
data[3][2] = 1280;
data[4][2] = 1200;
data[5][2] = 2660; ///
//Create and Append chart to the paragraph
WChart chart = paragraph.AppendChart(data, 470, 300);
//Set chart type and title
chart.ChartTitle = "Purchase Details";
chart.ChartTitleArea.FontName = "Calibri";
chart.ChartTitleArea.Size = 14;
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None;
//Set series type
chart.Series[0].SerieType = OfficeChartType.Line_Markers;
chart.Series[1].SerieType = OfficeChartType.Bar_Clustered;
chart.PrimaryCategoryAxis.Title = "Products";
chart.PrimaryValueAxis.Title = "In Dollars";
//Set position of legend
chart.Legend.Position = OfficeLegendPosition.Bottom;
//Save the document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Input data for chart
Dim data As Object()() = New Object(5)() {}
For i As Integer = 0 To 5
data(i) = New Object(2) {}
Next
data(0)(0) = ""
data(1)(0) = "Gravad lax"
data(2)(0) = "Louisiana Hot spiced Okara"
data(3)(0) = "Mascarpone Fabioli"
data(4)(0) = "Wimmers gute SemmelKnodel"
data(5)(0) = "Maxilaku"
data(0)(1) = "Sum of Purchases"
data(1)(1) = 286
data(2)(1) = 680
data(3)(1) = 288
data(4)(1) = 200
data(5)(1) = 731
data(0)(2) = "Sum of Future Expenses"
data(1)(2) = 1300
data(2)(2) = 700
data(3)(2) = 1280
data(4)(2) = 1200
data(5)(2) = 2660
'Create and Append chart to the paragraph
Dim chart As WChart = paragraph.AppendChart(data, 470, 300)
'Set chart type and title
chart.ChartTitle = "Purchase Details"
chart.ChartTitleArea.FontName = "Calibri"
chart.ChartTitleArea.Size = 14
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None
'Set series type
chart.Series(0).SerieType = OfficeChartType.Line_Markers
chart.Series(1).SerieType = OfficeChartType.Bar_Clustered
chart.PrimaryCategoryAxis.Title = "Products"
chart.PrimaryValueAxis.Title = "In Dollars"
'Set position of legend
chart.Legend.Position = OfficeLegendPosition.Bottom
'Save the document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add section to the document
IWSection sec = document.AddSection();
//Add paragraph to the section
IWParagraph paragraph = sec.AddParagraph();
//Create and Append chart to the paragraph
WChart chart = paragraph.AppendChart(446, 270);
//Set chart type
chart.ChartType = OfficeChartType.Pie;
//Set chart title
chart.ChartTitle = "Best Selling Products";
chart.ChartTitleArea.FontName = "Calibri";
chart.ChartTitleArea.Size = 14;
//Set data for chart
chart.ChartData.SetValue(1, 1, "");
chart.ChartData.SetValue(1, 2, "Sales");
chart.ChartData.SetValue(2, 1, "Cote de Blaye");
chart.ChartData.SetValue(2, 2, 141.396);
chart.ChartData.SetValue(3, 1, "Thuringer Rostbratwurst");
chart.ChartData.SetValue(3, 2, 80.368);
chart.ChartData.SetValue(4, 1, "Raclette Courdavault");
chart.ChartData.SetValue(4, 2, 71.155);
chart.ChartData.SetValue(5, 1, "Tarte au sucre");
chart.ChartData.SetValue(5, 2, 47.234);
chart.ChartData.SetValue(6, 1, "Camembert Pierrot");
chart.ChartData.SetValue(6, 2, 46.825);
chart.ChartData.SetValue(7, 1, "Gnocchi di nonna Alice");
chart.ChartData.SetValue(7, 2, 42.593);
chart.ChartData.SetValue(8, 1, "Manjimup Dried Apples");
chart.ChartData.SetValue(8, 2, 41.819);
chart.ChartData.SetValue(9, 1, "Alice Mutton");
chart.ChartData.SetValue(9, 2, 32.698);
chart.ChartData.SetValue(10, 1, "Carnarvon Tigers");
chart.ChartData.SetValue(10, 2, 29.171);
chart.ChartData.SetValue(11, 1, "Rössle Sauerkraut.");
chart.ChartData.SetValue(11, 2, 25.696);
//Create a new chart series with the name Sales
IOfficeChartSerie pieSeries = chart.Series.Add("Sales");
pieSeries.Values = chart.ChartData[2, 2, 11, 2];
//Set data label
pieSeries.DataPoints.DefaultDataPoint.DataLabels.IsValue = true;
pieSeries.DataPoints.DefaultDataPoint.DataLabels.Position = OfficeDataLabelPosition.Outside;
//Set background color
chart.ChartArea.Fill.ForeColor = Color.FromArgb(242, 242, 242);
chart.PlotArea.Fill.ForeColor = Color.FromArgb(242, 242, 242);
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None;
//Set category labels
chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 11, 1];
//Save the document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Create and Append chart to the paragraph
Dim chart As WChart = paragraph.AppendChart(446, 270)
'Set chart type
chart.ChartType = OfficeChartType.Pie
'Set chart title
chart.ChartTitle = "Best Selling Products"
chart.ChartTitleArea.FontName = "Calibri"
chart.ChartTitleArea.Size = 14
'Set data for chart
chart.ChartData.SetValue(1, 1, "")
chart.ChartData.SetValue(1, 2, "Sales")
chart.ChartData.SetValue(2, 1, "Cote de Blaye")
chart.ChartData.SetValue(2, 2, 141.396)
chart.ChartData.SetValue(3, 1, "Thuringer Rostbratwurst")
chart.ChartData.SetValue(3, 2, 80.368)
chart.ChartData.SetValue(4, 1, "Raclette Courdavault")
chart.ChartData.SetValue(4, 2, 71.155)
chart.ChartData.SetValue(5, 1, "Tarte au sucre")
chart.ChartData.SetValue(5, 2, 47.234)
chart.ChartData.SetValue(6, 1, "Camembert Pierrot")
chart.ChartData.SetValue(6, 2, 46.825)
chart.ChartData.SetValue(7, 1, "Gnocchi di nonna Alice")
chart.ChartData.SetValue(7, 2, 42.593)
chart.ChartData.SetValue(8, 1, "Manjimup Dried Apples")
chart.ChartData.SetValue(8, 2, 41.819)
chart.ChartData.SetValue(9, 1, "Alice Mutton")
chart.ChartData.SetValue(9, 2, 32.698)
chart.ChartData.SetValue(10, 1, "Carnarvon Tigers")
chart.ChartData.SetValue(10, 2, 29.171)
chart.ChartData.SetValue(11, 1, "Rössle Sauerkraut.")
'Create a new chart series with the name Sales
Dim pieSeries As IOfficeChartSerie = chart.Series.Add("Sales")
pieSeries.Values = chart.ChartData(2, 2, 11, 2)
'Set data label
pieSeries.DataPoints.DefaultDataPoint.DataLabels.IsValue = True
pieSeries.DataPoints.DefaultDataPoint.DataLabels.Position = OfficeDataLabelPosition.Outside
'Set background color
chart.ChartArea.Fill.ForeColor = Color.FromArgb(242, 242, 242)
chart.PlotArea.Fill.ForeColor = Color.FromArgb(242, 242, 242)
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None
'Set category labels
chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData(2, 1, 11, 1)
'Save the document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add section to the document
IWSection sec = document.AddSection();
//Add paragraph to the section
IWParagraph paragraph = sec.AddParagraph();
//Load the excel file as stream
Stream excelStream = File.OpenRead("Excel_Template.xlsx");
//Create and Append chart to the paragraph with excel stream as parameter
WChart chart = paragraph.AppendChart(excelStream, 1, "B2:C6", 470, 300);
//Set chart type and title
chart.ChartType = OfficeChartType.Column_Clustered;
chart.ChartTitle = "Purchase Details";
chart.ChartTitleArea.FontName = "Calibri";
chart.ChartTitleArea.Size = 14;
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None;
//Set name to chart series
chart.Series[0].Name = "Sum of Purchases";
chart.Series[1].Name = "Sum of Future Expenses";
chart.PrimaryCategoryAxis.Title = "Products";
chart.PrimaryValueAxis.Title = "In Dollars";
//Set position of legend
chart.Legend.Position = OfficeLegendPosition.Bottom;
//Save the document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Load the excel file as stream
Dim excelStream As Stream = File.OpenRead("Excel_Template.xlsx")
'Create and Append chart to the paragraph with excel stream as parameter
Dim chart As WChart = paragraph.AppendChart(excelStream, 1, "B2:C6", 470, 300)
'Set chart type and title
chart.ChartType = OfficeChartType.Column_Clustered
chart.ChartTitle = "Purchase Details"
chart.ChartTitleArea.FontName = "Calibri"
chart.ChartTitleArea.Size = 14
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None
'Set name to chart series
chart.Series(0).Name = "Sum of Purchases"
chart.Series(1).Name = "Sum of Future Expenses"
chart.PrimaryCategoryAxis.Title = "Products"
chart.PrimaryValueAxis.Title = "In Dollars"
'Set position of legend
chart.Legend.Position = OfficeLegendPosition.Bottom
'Save the document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an instance of WordDocument class (Empty Word Document)
WordDocument document = new WordDocument();
//Add a new section into the Word Document
IWSection section = document.AddSection();
//Add a new paragraph into Word document and append text into paragraph
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("Today's Date: ");
//Add the new Date field in Word document with field name and its type.
WField field = paragraph.AppendField("Date", FieldType.FieldDate) as WField;
//Field code used to describe how to display the date
field.FieldCode = @"DATE \@" + "\"MMMM d, yyyy\"";
//Save the document in the given name and format
document.Save("Sample.docx", FormatType.Docx);
//Release the resources occupied by WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an instance of WordDocument class (Empty Word Document)
Dim document As New WordDocument()
'Add a new section into the Word Document
Dim section As IWSection = document.AddSection()
'Add a new paragraph into Word document and append text into paragraph
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("Today's Date: ")
'Add the new Date field in Word document with field name and its type.
Dim field As WField = TryCast(paragraph.AppendField("Date", FieldType.FieldDate), WField)
'Field code used to describe how to display the date
field.FieldCode = "DATE \@" + """MMMM d, yyyy"""
'Save the document in the given name and format
document.Save("Sample.docx", FormatType.Docx)
'Release the resources occupied by WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("Web Hyperlink: ");
paragraph = section.AddParagraph();
//Append web hyperlink to the paragraph
IWField field = paragraph.AppendHyperlink("http://www.syncfusion.com", "Syncfusion", HyperlinkType.WebLink);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("Web Hyperlink: ")
paragraph = section.AddParagraph()
'Append web hyperlink to the paragraph
Dim field As IWField = paragraph.AppendHyperlink("http://www.syncfusion.com", "Syncfusion", HyperlinkType.WebLink)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("Image Hyperlink");
paragraph = section.AddParagraph();
//Create a new image instance and load image
WPicture picture = new WPicture(document);
picture.LoadImage(Image.FromFile("Image.png"));
//Append new image hyperlink to the paragraph
paragraph.AppendHyperlink("http://www.syncfusion.com", picture, HyperlinkType.WebLink);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("Image Hyperlink")
paragraph = section.AddParagraph()
'Create a new image instance and load image
Dim picture As New WPicture(document)
picture.LoadImage(Image.FromFile("Image.png"))
'Append new image hyperlink to the paragraph
paragraph.AppendHyperlink("http://www.syncfusion.com", picture, HyperlinkType.WebLink)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an instance of WordDocument class (Empty Word Document)
WordDocument document = new WordDocument();
//Add a new section into the Word Document
IWSection section = document.AddSection();
//Add a new paragraph into Word document and append text into paragraph
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("Northwind Database");
paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
//Add a paragraph into section
paragraph = section.AddParagraph();
//Add a new bookmark start into paragraph with name "Northwind"
paragraph.AppendBookmarkStart("Northwind");
//Add a text between the bookmark start and end into paragraph
paragraph.AppendText("The Northwind sample database (Northwind.mdb) is included with all versions of Access. It provides data you can experiment with and database objects that demonstrate features you might want to implement in your own databases.");
//Add a new bookmark end into paragraph with name " Northwind "
paragraph.AppendBookmarkEnd("Northwind");
//Add a text after the bookmark end
paragraph.AppendText(" Using Northwind, you can become familiar with how a relational database is structured and how the database objects work together to help you enter, store, manipulate, and print your data.");
//Save the document in the given name and format
document.Save("Bookmarks.docx", FormatType.Docx);
//Release the resources occupied by WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an instance of WordDocument class (Empty Word Document)
Dim document As New WordDocument()
'Add a new section into the Word Document
Dim section As IWSection = document.AddSection()
'Add a new paragraph into Word document and append text into paragraph
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("Northwind Database")
paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center
'Add a paragraph into section
paragraph = section.AddParagraph()
'Add a new bookmark start into paragraph with name "Northwind"
paragraph.AppendBookmarkStart("Northwind")
'Add a text between the bookmark start and end into paragraph
paragraph.AppendText("The Northwind sample database (Northwind.mdb) is included with all versions of Access. It provides data you can experiment with and database objects that demonstrate features you might want to implement in your own databases.")
'Add a new bookmark end into paragraph with name " Northwind "
paragraph.AppendBookmarkEnd("Northwind")
'Add a text after the bookmark end
paragraph.AppendText(" Using Northwind, you can become familiar with how a relational database is structured and how the database objects work together to help you enter, store, manipulate, and print your data.")
'Save the document in the given name and format
document.Save("Bookmarks.docx", FormatType.Docx)
'Release the resources occupied by WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an instance of WordDocument class (Empty Word Document)
WordDocument document = new WordDocument();
//Add a new section into the Word Document
IWSection section = document.AddSection();
//Add a new paragraph into Word document and append text into paragraph
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("Northwind Database");
paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center;
//Add a paragraph into section
paragraph = section.AddParagraph();
//Add a new bookmark start into paragraph with name "Northwind"
paragraph.AppendBookmarkStart("Northwind");
//Add a text between the bookmark start and end into paragraph
paragraph.AppendText("The Northwind sample database (Northwind.mdb) is included with all versions of Access. It provides data you can experiment with and database objects that demonstrate features you might want to implement in your own databases.");
//Add a new bookmark end into paragraph with name " Northwind "
paragraph.AppendBookmarkEnd("Northwind");
//Add a text after the bookmark end
paragraph.AppendText(" Using Northwind, you can become familiar with how a relational database is structured and how the database objects work together to help you enter, store, manipulate, and print your data.");
//Save the document in the given name and format
document.Save("Bookmarks.docx", FormatType.Docx);
//Release the resources occupied by WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an instance of WordDocument class (Empty Word Document)
Dim document As New WordDocument()
'Add a new section into the Word Document
Dim section As IWSection = document.AddSection()
'Add a new paragraph into Word document and append text into paragraph
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("Northwind Database")
paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center
'Add a paragraph into section
paragraph = section.AddParagraph()
'Add a new bookmark start into paragraph with name "Northwind"
paragraph.AppendBookmarkStart("Northwind")
'Add a text between the bookmark start and end into paragraph
paragraph.AppendText("The Northwind sample database (Northwind.mdb) is included with all versions of Access. It provides data you can experiment with and database objects that demonstrate features you might want to implement in your own databases.")
'Add a new bookmark end into paragraph with name " Northwind "
paragraph.AppendBookmarkEnd("Northwind")
'Add a text after the bookmark end
paragraph.AppendText(" Using Northwind, you can become familiar with how a relational database is structured and how the database objects work together to help you enter, store, manipulate, and print your data.")
'Save the document in the given name and format
document.Save("Bookmarks.docx", FormatType.Docx)
'Release the resources occupied by WordDocument instance
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Creates a new Word document.
WordDocument document = new WordDocument();
//Add a section and a paragraph in the document
document.EnsureMinimal();
IWParagraph paragraph = document.LastParagraph;
//Append text to the paragraph
paragraph.AppendText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua");
//Add comment to a paragraph
WComment comment = paragraph.AppendComment("comment test");
//Specify the author of the comment
comment.Format.User = "Peter";
//Specify the initial of the author
comment.Format.UserInitials = "St";
//Save and close the Word document
document.Save("Comment.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Creates a new Word document.
Dim document As New WordDocument()
'Add a section and a paragraph in the document
document.EnsureMinimal()
Dim paragraph As IWParagraph = document.LastParagraph
'Append text to the paragraph
paragraph.AppendText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua")
'Add comment to a paragraph
Dim comment As WComment = paragraph.AppendComment("comment test")
'Specify the author of the comment
comment.Format.User = "Peter"
'Specify the initial of the author
comment.Format.UserInitials = "St"
'Save and close the Word document
document.Save("Comment.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Create a section
IWSection section = document.AddSection();
//Add a paragraph to a section
IWParagraph paragraph = section.AddParagraph();
//Append the text to paragraph
paragraph.AppendText("Working with footnotes");
//Formatting the text
paragraph.ApplyStyle(BuiltinStyle.Heading1);
//Add a paragraph to a section
paragraph = section.AddParagraph();
//Append the footnotes
WFootnote footnote = (WFootnote) paragraph.AppendFootnote(Syncfusion.DocIO.FootnoteType.Footnote);
//Set the footnote character format
footnote.MarkerCharacterFormat.SubSuperScript = SubSuperScript.SuperScript;
//Inserts the text into the paragraph
paragraph.AppendText("Sample content for footnotes").CharacterFormat.Bold = true;
//Add footnote text
paragraph = footnote.TextBody.AddParagraph();
paragraph.AppendText("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");
//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()
'Create a section
Dim section As IWSection = document.AddSection()
'Add a paragraph to a section
Dim paragraph As IWParagraph = section.AddParagraph()
'Append the text to paragraph
paragraph.AppendText("Working with footnotes")
'Formatting the text
paragraph.ApplyStyle(BuiltinStyle.Heading1)
'Add a paragraph to a section
paragraph = section.AddParagraph()
'Append the footnotes
Dim footnote As WFootnote = DirectCast(paragraph.AppendFootnote(Syncfusion.DocIO.FootnoteType.Footnote), WFootnote)
'Set the footnote character format
footnote.MarkerCharacterFormat.SubSuperScript = SubSuperScript.SuperScript
'Inserts the text into the paragraph
paragraph.AppendText("Sample content for footnotes").CharacterFormat.Bold = True
'Add footnote text
paragraph = footnote.TextBody.AddParagraph()
paragraph.AppendText("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")
Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new document
WordDocument document = new WordDocument();
//Create a section
IWSection section = document.AddSection();
//Add a paragraph to a section
IWParagraph paragraph = section.AddParagraph();
//Append the text to paragraph
paragraph.AppendText("Working with endnotes");
//Formatting the text
paragraph.ApplyStyle(BuiltinStyle.Heading1);
//Add a paragraph to a section
paragraph = section.AddParagraph();
//Append the endnote
WFootnote endnote = (WFootnote) paragraph.AppendFootnote(Syncfusion.DocIO.FootnoteType.Endnote);
//Set the endnote character format
endnote.MarkerCharacterFormat.SubSuperScript = SubSuperScript.SuperScript;
//Insert the text into the paragraph
paragraph.AppendText("Sample content for endnotes").CharacterFormat.Bold = true;
//Add footnote text
paragraph = endnote.TextBody.AddParagraph();
paragraph.AppendText("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");
//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 document
Dim document As New WordDocument()
'Create a section
Dim section As IWSection = document.AddSection()
'Add a paragraph to a section
Dim paragraph As IWParagraph = section.AddParagraph()
'Append the text to paragraph
paragraph.AppendText("Working with endnotes")
'Formatting the text
paragraph.ApplyStyle(BuiltinStyle.Heading1)
'Add a paragraph to a section
paragraph = section.AddParagraph()
'Append the endnote
Dim endnote As WFootnote = DirectCast(paragraph.AppendFootnote(Syncfusion.DocIO.FootnoteType.Endnote), WFootnote)
'Set the endnote character format
endnote.MarkerCharacterFormat.SubSuperScript = SubSuperScript.SuperScript
'Insert the text into the paragraph
paragraph.AppendText("Sample content for endnotes").CharacterFormat.Bold = True
'Add footnote text
paragraph = endnote.TextBody.AddParagraph()
paragraph.AppendText("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")
Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Append new textbox to the paragraph
IWTextBox textbox = paragraph.AppendTextBox(150, 75);
//Add new text to the textbox body
IWParagraph textboxParagraph = textbox.TextBoxBody.AddParagraph();
textboxParagraph.AppendText("Text inside text box");
//Save and close the Word 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()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Append new textbox to the paragraph
Dim textbox As IWTextBox = paragraph.AppendTextBox(150, 75)
'Add new text to the textbox body
Dim textboxParagraph As IWParagraph = textbox.TextBoxBody.AddParagraph()
textboxParagraph.AppendText("Text inside text box")
'Save and close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
WParagraph paragraph = section.AddParagraph() as WParagraph;
paragraph.AppendText("Gender\t");
//Append new Checkbox
WCheckBox checkbox = paragraph.AppendCheckBox();
checkbox.Checked = false;
//Set Checkbox size
checkbox.CheckBoxSize = 10;
checkbox.CalculateOnExit = true;
//Set help text
checkbox.Help = "Help text";
paragraph.AppendText("Male\t");
checkbox = paragraph.AppendCheckBox();
checkbox.Checked = false;
checkbox.CheckBoxSize = 10;
checkbox.CalculateOnExit = true;
paragraph.AppendText("Female");
//Save the Word document
document.Save("Checkbox.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As WParagraph = TryCast(section.AddParagraph(), WParagraph)
paragraph.AppendText("Gender" & vbTab)
'Append new Checkbox
Dim checkbox As WCheckBox = paragraph.AppendCheckBox()
checkbox.Checked = False
'Set Checkbox size
checkbox.CheckBoxSize = 10
checkbox.CalculateOnExit = True
'Set help text
checkbox.Help = "Help text"
paragraph.AppendText("Male" & vbTab)
checkbox = paragraph.AppendCheckBox()
checkbox.Checked = False
checkbox.CheckBoxSize = 10
checkbox.CalculateOnExit = True
paragraph.AppendText("Female")
'Save the Word document
document.Save("Checkbox.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
WParagraph paragraph = section.AddParagraph() as WParagraph;
paragraph.AppendText("Gender\t");
//Append new Checkbox
WCheckBox checkbox = paragraph.AppendCheckBox("CheckBox1", true);
//checkbox.Checked = false;
//Set Checkbox size
checkbox.CheckBoxSize = 10;
checkbox.CalculateOnExit = true;
//Set help text
checkbox.Help = "Help text";
paragraph.AppendText("Male\t");
checkbox = paragraph.AppendCheckBox("CheckBox2",false);
//checkbox.Checked = false;
checkbox.CheckBoxSize = 10;
checkbox.CalculateOnExit = true;
paragraph.AppendText("Female");
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As WParagraph = TryCast(section.AddParagraph(), WParagraph)
paragraph.AppendText("Gender" & vbTab)
'Append new Checkbox
Dim checkbox As WCheckBox = paragraph.AppendCheckBox("CheckBox1", True)
'checkbox.Checked = false;
'Set Checkbox size
checkbox.CheckBoxSize = 10
checkbox.CalculateOnExit = True
'Set help text
checkbox.Help = "Help text"
paragraph.AppendText("Male" & vbTab)
checkbox = paragraph.AppendCheckBox("CheckBox2", False)
'checkbox.Checked = false;
checkbox.CheckBoxSize = 10
checkbox.CalculateOnExit = True
paragraph.AppendText("Female")
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
WParagraph paragraph = section.AddParagraph() as WParagraph;
paragraph.AppendText("General Information");
section.AddParagraph();
paragraph = section.AddParagraph() as WParagraph;
IWTextRange text = paragraph.AppendText("Name\t");
text.CharacterFormat.Bold = true;
//Append Text form field
WTextFormField textfield = paragraph.AppendTextFormField(null);
//Set type of Text form field
textfield.Type = TextFormFieldType.RegularText;
textfield.CharacterFormat.FontName = "Calibri";
textfield.CalculateOnExit = true;
//Save the Word document
document.Save("Textfield.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As WParagraph = TryCast(section.AddParagraph(), WParagraph)
paragraph.AppendText("General Information")
section.AddParagraph()
paragraph = TryCast(section.AddParagraph(), WParagraph)
Dim text As IWTextRange = paragraph.AppendText("Name" & vbTab)
text.CharacterFormat.Bold = True
'Append Text form field
Dim textfield As WTextFormField = paragraph.AppendTextFormField(Nothing)
'Set type of Text form field
textfield.Type = TextFormFieldType.RegularText
textfield.CharacterFormat.FontName = "Calibri"
textfield.CalculateOnExit = True
'Save the Word document
document.Save("Textfield.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
WParagraph paragraph = section.AddParagraph() as WParagraph;
paragraph.AppendText("General Information");
section.AddParagraph();
paragraph = section.AddParagraph() as WParagraph;
IWTextRange text = paragraph.AppendText("Date of Birth\t");
text.CharacterFormat.Bold = true;
//Append Text form field
WTextFormField textfield = paragraph.AppendTextFormField("Date field", DateTime.Now.ToString("MM/DD/YY"));
textfield.StringFormat = "MM/DD/YY";
//Set Text form field type
textfield.Type = TextFormFieldType.DateText;
textfield.CalculateOnExit = true;
//Save the Word document
document.Save("Textfield.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As WParagraph = TryCast(section.AddParagraph(), WParagraph)
paragraph.AppendText("General Information")
section.AddParagraph()
paragraph = TryCast(section.AddParagraph(), WParagraph)
Dim text As IWTextRange = paragraph.AppendText("Date of Birth" & vbTab)
text.CharacterFormat.Bold = True
'Append Text form field
Dim textfield As WTextFormField = paragraph.AppendTextFormField("Date field", DateTime.Now.ToString("MM/DD/YY"))
textfield.StringFormat = "MM/DD/YY"
'Set Text form field type
textfield.Type = TextFormFieldType.DateText
textfield.CalculateOnExit = True
'Save the Word document
document.Save("Textfield.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
WParagraph paragraph = section.AddParagraph() as WParagraph;
paragraph.AppendText("Educational Qualification\t");
//Append Dropdown field
WDropDownFormField dropdownfield = paragraph.AppendDropDownFormField("FieldName");
//Add items to the dropdown items collection
dropdownfield.DropDownItems.Add("Higher");
dropdownfield.DropDownItems.Add("Vocational");
dropdownfield.DropDownItems.Add("Universal");
dropdownfield.Enabled = true;
//Set the item index for default value
dropdownfield.DropDownSelectedIndex = 1;
dropdownfield.CalculateOnExit = true;
//Save the Word document
document.Save("Dropdown.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As WParagraph = TryCast(section.AddParagraph(), WParagraph)
paragraph.AppendText("Educational Qualification" & vbTab)
'Append Dropdown field
Dim dropdownfield As WDropDownFormField = paragraph.AppendDropDownFormField("FieldName")
'Add items to the dropdown items collection
dropdownfield.DropDownItems.Add("Higher")
dropdownfield.DropDownItems.Add("Vocational")
dropdownfield.DropDownItems.Add("Universal")
dropdownfield.Enabled = True
'Set the item index for default value
dropdownfield.DropDownSelectedIndex = 1
dropdownfield.CalculateOnExit = True
'Save the Word document
document.Save("Dropdown.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("Example of adding symbols to the paragraph: ");
//Insert symbol with character code 100
paragraph.AppendSymbol(100);
//Save and close the Word 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()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("Example of adding symbols to the paragraph: ")
'Insert symbol with character code 100
paragraph.AppendSymbol(100)
'Save and close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("Before line break");
//Add line break to the paragraph
paragraph.AppendBreak(BreakType.LineBreak);
paragraph.AppendText("After line break");
IWParagraph pageBreakPara = section.AddParagraph();
pageBreakPara.AppendText("Before page break");
//Add page break to the paragraph
pageBreakPara.AppendBreak(BreakType.PageBreak);
pageBreakPara.AppendText("After page break");
IWSection secondSection = document.AddSection();
//Add columns to the section
secondSection.AddColumn(100, 2);
secondSection.AddColumn(100, 2);
IWParagraph columnBreakPara = secondSection.AddParagraph();
columnBreakPara.AppendText("Before column break");
//Add column break to the paragraph
columnBreakPara.AppendBreak(BreakType.ColumnBreak);
columnBreakPara.AppendText("After column break");
//Save and Close the 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 new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("Before line break")
'Add line break to the paragraph
paragraph.AppendBreak(BreakType.LineBreak)
paragraph.AppendText("After line break")
Dim pageBreakPara As IWParagraph = section.AddParagraph()
pageBreakPara.AppendText("Before page break")
'Add page break to the paragraph
pageBreakPara.AppendBreak(BreakType.PageBreak)
pageBreakPara.AppendText("After page break")
Dim secondSection As IWSection = document.AddSection()
'Add columns to the section
secondSection.AddColumn(100, 2)
secondSection.AddColumn(100, 2)
Dim columnBreakPara As IWParagraph = secondSection.AddParagraph()
columnBreakPara.AppendText("Before column break")
'Add column break to the paragraph
columnBreakPara.AppendBreak(BreakType.ColumnBreak)
columnBreakPara.AppendText("After column break")
'Save and Close the document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
WParagraph paragraph = section.AddParagraph() as WParagraph;
//Add new shape to the document
Shape rectangle = paragraph.AppendShape(AutoShapeType.RoundedRectangle, 150, 100);
//Set position for shape
rectangle.VerticalPosition = 72;
rectangle.HorizontalPosition = 72;
paragraph = section.AddParagraph() as WParagraph;
//Add text body contents to the shape
paragraph = rectangle.TextBody.AddParagraph() as WParagraph;
IWTextRange text = paragraph.AppendText("This text is in rounded rectangle shape");
text.CharacterFormat.TextColor = Color.Green;
text.CharacterFormat.Bold = true;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As WParagraph = TryCast(section.AddParagraph(), WParagraph)
'Add new shape to the document
Dim rectangle As Shape = paragraph.AppendShape(AutoShapeType.RoundedRectangle, 150, 100)
'Set position for shape
rectangle.VerticalPosition = 72
rectangle.HorizontalPosition = 72
paragraph = TryCast(section.AddParagraph(), WParagraph)
'Add text body contents to the shape
paragraph = TryCast(rectangle.TextBody.AddParagraph(), WParagraph)
Dim text As IWTextRange = paragraph.AppendText("This text is in rounded rectangle shape")
text.CharacterFormat.TextColor = Color.Green
text.CharacterFormat.Bold = True
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add the section into the Word document
IWSection section = document.AddSection();
string paraText = "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";
//Add the paragraph into the created section
IWParagraph paragraph = section.AddParagraph();
//Append the TOC field with LowerHeadingLevel and UpperHeadingLevel to determines the TOC entries
paragraph.AppendTOC(1, 3);
//Add the section into the Word document
section = document.AddSection();
//Add the paragraph into the created section
paragraph = section.AddParagraph();
//Add the text for the headings
paragraph.AppendText("First Chapter");
//Set a build in heading style.
paragraph.ApplyStyle(BuiltinStyle.Heading1);
//Add the text into the paragraph
section.AddParagraph().AppendText(paraText);
//Add the section into the Word document
section = document.AddSection();
//Add the paragraph into the created section
paragraph = section.AddParagraph();
//Add the text for the headings
paragraph.AppendText("Second Chapter");
//Set a build in heading style.
paragraph.ApplyStyle(BuiltinStyle.Heading2);
//Add the text into the paragraph
section.AddParagraph().AppendText(paraText);
//Add the section into the Word document
section = document.AddSection();
//Add the paragraph into the created section
paragraph = section.AddParagraph();
//Add the text into the headings
paragraph.AppendText("Third Chapter");
//Set a build in heading style
paragraph.ApplyStyle(BuiltinStyle.Heading3);
//Add the text into the paragraph.
section.AddParagraph().AppendText(paraText);
//Update the table of contents
document.UpdateTableOfContents();
//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 the Word document
Dim section As IWSection = document.AddSection()
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"
'Add the paragraph into the created section
Dim paragraph As IWParagraph = section.AddParagraph()
'Append the TOC field with LowerHeadingLevel and UpperHeadingLevel to determines the TOC entries
paragraph.AppendTOC(1, 3)
'Add the section into the Word document
section = document.AddSection()
'Add the paragraph into the created section
paragraph = section.AddParagraph()
'Add the text for the headings
paragraph.AppendText("First Chapter")
'Set a build in heading style
paragraph.ApplyStyle(BuiltinStyle.Heading1)
'Add the text into the paragraph.
section.AddParagraph().AppendText(paraText)
'Add the section into the Word document
section = document.AddSection()
'Add the paragraph into the created section
paragraph = section.AddParagraph()
'Add the text for the headings
paragraph.AppendText("Second Chapter")
'Set a build in heading style
paragraph.ApplyStyle(BuiltinStyle.Heading2)
'Add the text into the paragraph
section.AddParagraph().AppendText(paraText)
'Add the section into the Word document
section = document.AddSection()
'Add the paragraph into the created section
paragraph = section.AddParagraph()
'Add the text into the headings
paragraph.AppendText("Third Chapter")
'Set a build in heading style
paragraph.ApplyStyle(BuiltinStyle.Heading3)
'Add the text into the paragraph
section.AddParagraph().AppendText(paraText)
'Update the table of contents
document.UpdateTableOfContents()
Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
IWParagraph paragraph = section.AddParagraph();
//Add text, bookmark start and end in the paragraph
paragraph.AppendBookmarkStart("Title");
paragraph.AppendText("Northwind Database");
paragraph.AppendBookmarkEnd("Title");
paragraph = section.AddParagraph();
paragraph.AppendText("The Northwind sample database (Northwind.mdb) is included with all versions of Access. It provides data you can experiment with and database objects that demonstrate features you might want to implement in your own databases.");
section = document.AddSection();
section.AddParagraph();
paragraph = section.AddParagraph() as WParagraph;
//Get the collection of bookmark start in the word document
List<Entity> items = document.GetCrossReferenceItems(ReferenceType.Bookmark);
paragraph.AppendText("Bookmark Cross Reference starts here ");
//Append the cross reference for bookmark Title with ContentText as reference kind
paragraph.AppendCrossReference(ReferenceType.Bookmark, ReferenceKind.ContentText, items[0], true, false, false, string.Empty);
//Update the document Fields
document.UpdateDocumentFields();
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()
Dim section As IWSection = document.AddSection()
Dim paragraph As IWParagraph = section.AddParagraph()
'Add text, bookmark start and end in the paragraph
paragraph.AppendBookmarkStart("Title")
paragraph.AppendText("Northwind Database")
paragraph.AppendBookmarkEnd("Title")
paragraph = section.AddParagraph()
paragraph.AppendText("The Northwind sample database (Northwind.mdb) is included with all versions of Access. It provides data you can experiment with and database objects that demonstrate features you might want to implement in your own databases.")
section = document.AddSection()
section.AddParagraph()
paragraph = TryCast(section.AddParagraph(), WParagraph)
'Get the collection of bookmark start in the word document
Dim items As List(Of Entity) = document.GetCrossReferenceItems(ReferenceType.Bookmark)
paragraph.AppendText("Bookmark Cross Reference starts here ")
'Append the cross reference for bookmark Title with ContentText as reference kind
paragraph.AppendCrossReference(ReferenceType.Bookmark, ReferenceKind.ContentText, items(0), True, False, False, String.Empty)
'Update the document Fields
document.UpdateDocumentFields()
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add image to the paragraph
IWPicture picture = paragraph.AppendPicture(Image.FromFile("Image.png"));
//Set height and width for the image
picture.Height = 100;
picture.Width = 100;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add image to the paragraph
Dim picture As IWPicture = paragraph.AppendPicture(Image.FromFile("Image.png"))
'Set height and width for the image
picture.Height = 100
picture.Width = 100
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the template document
WordDocument document = new WordDocument("Template.docx");
//Html string to be inserted
string htmlstring = "This text is inserted as HTML string.
";
IWParagraph paragraph = document.Sections[0].Body.Paragraphs[0];
//Append the Html string to first paragraph in the document
paragraph.AppendHTML(htmlstring);
//Save and close the document
document.Save("Sample.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document
Dim document As New WordDocument("Template.docx")
'Html string to be inserted
Dim htmlstring As String = "This text is inserted as HTML string.
"
Dim paragraph As IWParagraph = document.Sections(0).Body.Paragraphs(0)
'Append the Html string to first paragraph in the document
paragraph.AppendHTML(htmlstring)
'Save and close the document
document.Save("Sample.docx")
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add section to the document
IWSection sec = document.AddSection();
//Add paragraph to the section
IWParagraph paragraph = sec.AddParagraph();
//Load the picture instance with the image need to be displayed
WPicture picture = new WPicture(document);
picture.LoadImage(Image.FromFile("Image.png"));
paragraph = sec.AddParagraph();
paragraph.AppendOleObject(@"..\..\Data\Excel_Template.xlsx", picture, OleObjectType.ExcelWorksheet);
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 section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Load the picture instance with the image need to be displayed
Dim picture As New WPicture(document)
picture.LoadImage(Image.FromFile("Image.png"))
paragraph = sec.AddParagraph()
paragraph.AppendOleObject("..\..\Data\Excel_Template.xlsx", picture, OleObjectType.ExcelWorksheet)
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add section to the document
IWSection sec = document.AddSection();
//Add paragraph to the section
IWParagraph paragraph = sec.AddParagraph();
//Load the picture instance with the image need to be displayed
WPicture picture = new WPicture(document);
picture.LoadImage(Image.FromFile("Image.png"));
WOleObject ole = paragraph.AppendOleObject(@"..\..\Data\Excel_Template.xlsx", picture);
//Set how to display the Ole object
ole.DisplayAsIcon = false;
//Save and close the document
document.Save("Sample.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Load the picture instance with the image need to be displayed
Dim picture As New WPicture(document)
picture.LoadImage(Image.FromFile("Image.png"))
Dim ole As WOleObject = paragraph.AppendOleObject("..\..\Data\Excel_Template.xlsx", picture)
'Set how to display the Ole object
ole.DisplayAsIcon = False
'Save and close the document
document.Save("Sample.docx")
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Open the file to be embedded
FileStream stream = new FileStream("Book1.xlsx", FileMode.Open);
//Load the picture instance with the image need to be displayed
WPicture picture = new WPicture(document);
picture.LoadImage(Image.FromFile("Image.png"));
//Append the Ole object to the paragraph
WOleObject ole = paragraph.AppendOleObject(stream, picture, OleObjectType.ExcelWorksheet);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Open the file to be embedded
Dim stream As New FileStream("Book1.xlsx", FileMode.Open)
'Load the picture instance with the image need to be displayed
Dim picture As New WPicture(document)
picture.LoadImage(Image.FromFile("Image.png"))
'Append the Ole object to the paragraph
Dim ole As WOleObject = paragraph.AppendOleObject(stream, picture, OleObjectType.ExcelWorksheet)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add section to the document
IWSection sec = document.AddSection();
//Add paragraph to the section
IWParagraph paragraph = sec.AddParagraph();
//Load the picture instance with the image need to be displayed
WPicture picture = new WPicture(document);
picture.LoadImage(Image.FromFile("Image.png"));
//Get the file as byte array
byte[] olebytes = File.ReadAllBytes("Excel_Template.xlsx");
paragraph = sec.AddParagraph();
//Append OLE object
paragraph.AppendOleObject(olebytes, picture, OleObjectType.ExcelWorksheet);
//Save the Word document
document.Save("Sample.docx", FormatType.Word2010);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Load the picture instance with the image need to be displayed
Dim picture As New WPicture(document)
picture.LoadImage(Image.FromFile("Image.png"))
'Get the file as byte array
Dim olebytes As Byte() = File.ReadAllBytes("Excel_Template.xlsx")
paragraph = sec.AddParagraph()
'Append OLE object
paragraph.AppendOleObject(olebytes, picture, OleObjectType.ExcelWorksheet)
'Save the Word document
document.Save("Sample.docx", FormatType.Word2010)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add section to the document
IWSection sec = document.AddSection();
//Add paragraph to the section
IWParagraph paragraph = sec.AddParagraph();
//Load the picture instance with the image need to be displayed
WPicture picture = new WPicture(document);
picture.LoadImage(Image.FromFile("Image.png"));
FileStream stream = new FileStream("Excel_Template.xlsx", FileMode.Open);
WOleObject ole = paragraph.AppendOleObject(stream, picture, OleLinkType.Embed);
ole.ObjectType = "Excel Worksheet";
//Save the Word document
document.Save("Sample.docx", FormatType.Word2010);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Load the picture instance with the image need to be displayed
Dim picture As New WPicture(document)
picture.LoadImage(Image.FromFile("Image.png"))
Dim stream As New FileStream("Excel_Template.xlsx", FileMode.Open)
Dim ole As WOleObject = paragraph.AppendOleObject(stream, picture, OleLinkType.Embed)
ole.ObjectType = "Excel Worksheet"
'Save the Word document
document.Save("Sample.docx", FormatType.Word2010)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add section to the document
IWSection sec = document.AddSection();
//Add paragraph to the section
IWParagraph paragraph = sec.AddParagraph();
//Load the picture instance with the image need to be displayed
WPicture picture = new WPicture(document);
picture.LoadImage(Image.FromFile("Image.png"));
//Get the file as byte array
byte[] olebytes = File.ReadAllBytes("Excel_Template.xlsx");
WOleObject ole = paragraph.AppendOleObject(olebytes, picture, OleLinkType.Embed);
ole.ObjectType = "Excel Worksheet";
//Save the Word document
document.Save("Sample.docx", FormatType.Word2010);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Load the picture instance with the image need to be displayed
Dim picture As New WPicture(document)
picture.LoadImage(Image.FromFile("Image.png"))
'Get the file as byte array
Dim olebytes As Byte() = File.ReadAllBytes("Excel_Template.xlsx")
Dim ole As WOleObject = paragraph.AppendOleObject(olebytes, picture, OleLinkType.Embed)
ole.ObjectType = "Excel Worksheet"
'Save the Word document
document.Save("Sample.docx", FormatType.Word2010)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add section to the document
IWSection sec = document.AddSection();
//Add paragraph to the section
IWParagraph paragraph = sec.AddParagraph();
//Load the picture instance with the image need to be displayed
WPicture picture = new WPicture(document);
picture.LoadImage(Image.FromFile("Image.png"));
//Get the file as byte array
byte[] olebytes = File.ReadAllBytes("Excel_Template.xlsx");
paragraph = sec.AddParagraph();
//Append OLE object
paragraph.AppendOleObject(olebytes, picture, ".xlsx");
//Save the Word document
document.Save("Sample.docx", FormatType.Word2010);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Load the picture instance with the image need to be displayed
Dim picture As New WPicture(document)
picture.LoadImage(Image.FromFile("Image.png"))
'Get the file as byte array
Dim olebytes As Byte() = File.ReadAllBytes("Excel_Template.xlsx")
paragraph = sec.AddParagraph()
'Append OLE object
paragraph.AppendOleObject(olebytes, picture, ".xlsx")
'Save the Word document
document.Save("Sample.docx", FormatType.Word2010)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Open the file to be embedded
FileStream stream = new FileStream("Excel_Template.xlsx", FileMode.Open);
//Load the picture instance with the image need to be displayed
WPicture picture = new WPicture(document);
picture.LoadImage(Image.FromFile("Image.png"));
//Append the Ole object to the paragraph
WOleObject ole = paragraph.AppendOleObject(stream, picture, "xlsx");
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Open the file to be embedded
Dim stream As New FileStream("Excel_Template.xlsx", FileMode.Open)
'Load the picture instance with the image need to be displayed
Dim picture As New WPicture(document)
picture.LoadImage(Image.FromFile("Image.png"))
'Append the Ole object to the paragraph
Dim ole As WOleObject = paragraph.AppendOleObject(stream, picture, "xlsx")
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
//Create a new Word document
using(WordDocument wordDocument = new WordDocument())
{
//Adds one section and one paragraph to the document
wordDocument.EnsureMinimal();
//Appends a new mathematical equation to the paragraph using LaTeX syntax.
wordDocument.LastParagraph.AppendMath(@"\dot{a}");
//Saves the Word document
wordDocument.Save("Result.docx", FormatType.Docx);
}
'Create a new Word document
Dim wordDocument As New WordDocument()
'Adds one section and one paragraph to the document
wordDocument.EnsureMinimal()
'Appends a new mathematical equation to the paragraph using LaTeX syntax.
wordDocument.LastParagraph.AppendMath("\dot{a}")
'Saves the Word document
wordDocument.Save("Result.docx", FormatType.Docx)
'Close the document
wordDocument.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
WParagraph paragraph = document.Sections[0].Paragraphs[1];
//Find the first occurrence of a particular text in the paragraph
TextSelection textSelection = paragraph.Find(new Regex("Panda"));
//Get the found text as single text range
WTextRange textRange = textSelection.GetAsOneRange();
//Modify the text
textRange.Text = "Replaced text";
//Set highlight color
textRange.CharacterFormat.HighlightColor = Color.Yellow;
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
Dim paragraph As WParagraph = document.Sections(0).Paragraphs(1)
'Find the first occurrence of a particular text in the paragraph
Dim textSelection As TextSelection = paragraph.Find(New Regex("Panda"))
'Get the found text as single text range
Dim textRange As WTextRange = textSelection.GetAsOneRange()
'Modify the text
textRange.Text = "Replaced text"
'Set highlight color
textRange.CharacterFormat.HighlightColor = Color.Yellow
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
WParagraph paragraph = document.Sections[0].Paragraphs[1];
//Find the first occurrence of a particular text in the paragraph
TextSelection textSelection = paragraph.Find("panda", true, true);
//Get the found text as single text range
WTextRange textRange = textSelection.GetAsOneRange();
//Modify the text
textRange.Text = "Replaced text";
//Set highlight color
textRange.CharacterFormat.HighlightColor = Color.Yellow;
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
Dim paragraph As WParagraph = document.Sections(0).Paragraphs(1)
'Find the first occurrence of a particular text in the paragraph
Dim textSelection As TextSelection = paragraph.Find("panda", true, true)
'Get the found text as single text range
Dim textRange As WTextRange = textSelection.GetAsOneRange()
'Modify the text
textRange.Text = "Replaced text"
'Set highlight color
textRange.CharacterFormat.HighlightColor = Color.Yellow
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
WParagraph paragraph = document.Sections[0].Paragraphs[1];
//Replace all occurrence of a particular text in the paragraph
paragraph.Replace(new Regex("Paragraph"),"paragraph");
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
Dim paragraph As WParagraph = document.Sections(0).Paragraphs(1)
'Replace all occurrence of a particular text in the paragraph
paragraph.Replace(New Regex("Paragraph"), "paragraph")
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
WParagraph paragraph = document.Sections[0].Paragraphs[1];
//Replace all occurrence of a particular text in the paragraph
paragraph.Replace("Paragraph","paragraph", false, true);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
Dim paragraph As WParagraph = document.Sections(0).Paragraphs(1)
'Replace all occurrence of a particular text in the paragraph
paragraph.Replace("Paragraph", "paragraph", False, True)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
WParagraph paragraph = document.Sections[0].Paragraphs[1];
//Find the first occurrence of the regular expression
TextSelection selection = paragraph.Find(new Regex("Panda"));
//Replace all occurrence of a particular regular expression with the text selection in the paragraph
paragraph.Replace(new Regex("Giant panda"), selection);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
Dim paragraph As WParagraph = document.Sections(0).Paragraphs(1)
'Find the first occurrence of the regular expression
Dim selection As TextSelection = paragraph.Find(New Regex("Panda"))
'Replace all occurrence of a particular regular expression with the text selection in the paragraph
paragraph.Replace(New Regex("Giant panda"), selection)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
WParagraph paragraph = document.Sections[0].Paragraphs[1];
//Find the first occurrence of the regular expression
TextSelection selection = paragraph.Find(new Regex("Panda"));
//Replace all occurrence of a particular regular expression with the text selection in the paragraph
paragraph.Replace(new Regex("Giant panda"), selection, true);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
Dim paragraph As WParagraph = document.Sections(0).Paragraphs(1)
'Find the first occurrence of the regular expression
Dim selection As TextSelection = paragraph.Find(New Regex("Panda"))
'Replace all occurrence of a particular regular expression with the text selection in the paragraph
paragraph.Replace(New Regex("Giant panda"), selection, True)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
WParagraph paragraph = document.Sections[0].Paragraphs[1];
//Find the first occurrence of the regular expression
TextSelection selection = paragraph.Find(new Regex("Panda"));
//Replace all occurrence of a particular regular expression with the text selection in the paragraph
paragraph.Replace("Giant panda", selection, true, false);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
Dim paragraph As WParagraph = document.Sections(0).Paragraphs(1)
'Find the first occurrence of the regular expression
Dim selection As TextSelection = paragraph.Find(New Regex("Panda"))
'Replace all occurrence of a particular regular expression with the text selection in the paragraph
paragraph.Replace("Giant panda", selection, True, False)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Template.docx");
WParagraph paragraph = document.Sections[0].Paragraphs[1];
//Find the first occurrence of the regular expression
TextSelection selection = paragraph.Find(new Regex("Panda"));
//Replace all occurrence of a particular regular expression with the text selection in the paragraph
paragraph.Replace("Giant panda", selection, true, false, true);
//Save and Close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Template.docx")
Dim paragraph As WParagraph = document.Sections(0).Paragraphs(1)
'Find the first occurrence of the regular expression
Dim selection As TextSelection = paragraph.Find(New Regex("Panda"))
'Replace all occurrence of a particular regular expression with the text selection in the paragraph
paragraph.Replace("Giant panda", selection, True, False, False)
'Save and Close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
document.EnsureMinimal();
//Add text to the first section
document.LastParagraph.AppendText("First section");
//Insert section break
WSection newsection = document.LastParagraph.InsertSectionBreak();
//Add new paragraph to the second section
IWParagraph paragraph = newsection.AddParagraph();
paragraph.AppendText("Second 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()
document.EnsureMinimal()
'Add text to the first section
document.LastParagraph.AppendText("First section")
'Insert section break
Dim newsection As WSection = document.LastParagraph.InsertSectionBreak()
'Add new paragraph to the second section
Dim paragraph As IWParagraph = newsection.AddParagraph()
paragraph.AppendText("Second section")
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
document.EnsureMinimal();
//Add text to the first section
document.LastParagraph.AppendText("First section");
//Insert section break
WSection newsection = document.LastParagraph.InsertSectionBreak(SectionBreakCode.Oddpage);
//Add new paragraph to the second section
IWParagraph paragraph = newsection.AddParagraph();
paragraph.AppendText("Second 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()
document.EnsureMinimal()
'Add text to the first section
document.LastParagraph.AppendText("First section")
'Insert section break
Dim newsection As WSection = document.LastParagraph.InsertSectionBreak(SectionBreakCode.Oddpage)
'Add new paragraph to the second section
Dim paragraph As IWParagraph = newsection.AddParagraph()
paragraph.AppendText("Second section")
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
// Loads an existing Word document into DocIO instance.
WordDocument document = new WordDocument("Template.docx");
//Gets the document text
document.GetText();
// Gets a numeric string value of the numbering list paragraph.
String listString = document.LastParagraph.ListString;
// Saves the document in the given name and format.
document.Save("Document.docx", FormatType.Docx);
// Releases the resources occupied by WordDocument instance.
document.Close();
' Loads an existing Word document into DocIO instance.
Dim document As WordDocument = New WordDocument("Template.docx")
' Gets the document text.
document.GetText()
' Gets a numeric string value of the numbering list paragraph
Dim listString As String = document.LastParagraph.ListString
' Saves the document in the given name and format.
document.Save("Document.docx", FormatType.Docx)
' Releases the resources occupied by WordDocument instance.
document.Close()
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
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
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
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
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
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
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
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
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
section.AddParagraph().AppendText("Price Details");
section.AddParagraph();
//Add a new table into Word document
IWTable table = section.AddTable();
//Add the first row to table
WTableRow row = table.AddRow();
//Add the first cell into first row
WTableCell cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("Apple");
//Add the second cell into first row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("$40");
//Add second row to table
row = table.AddRow(false);
//Add the first cell into first row
cell = row.Cells[0];
cell.AddParagraph().AppendText("Orange");
//Add the second cell into first row
cell = row.Cells[1];
cell.AddParagraph().AppendText("$30");
//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()
Dim section As IWSection = document.AddSection()
section.AddParagraph().AppendText("Price Details")
section.AddParagraph()
'Add a new table into Word document
Dim table As IWTable = section.AddTable()
'Add the first row to table
Dim row As WTableRow = table.AddRow()
'Add the first cell into first row
Dim cell As WTableCell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("Apple")
'Add the second cell into first row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("$40")
'Add second row to table
row = table.AddRow(False)
'Add the first cell into first row
cell = row.Cells(0)
cell.AddParagraph().AppendText("Orange")
'Add the second cell into first row
cell = row.Cells(1)
cell.AddParagraph().AppendText("$30")
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
section.AddParagraph().AppendText("Price Details");
section.AddParagraph();
//Add a new table into Word document
IWTable table = section.AddTable();
//Add the first row to table
WTableRow row = table.AddRow();
//Add the first cell into first row
WTableCell cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("Apple");
//Add the second cell into first row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("$40");
//Add second row to table
row = table.AddRow(false);
//Add the first cell into first row
cell = row.Cells[0];
cell.AddParagraph().AppendText("Orange");
//Add the second cell into first row
cell = row.Cells[1];
cell.AddParagraph().AppendText("$30");
//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()
Dim section As IWSection = document.AddSection()
section.AddParagraph().AppendText("Price Details")
section.AddParagraph()
'Add a new table into Word document
Dim table As IWTable = section.AddTable()
'Add the first row to table
Dim row As WTableRow = table.AddRow()
'Add the first cell into first row
Dim cell As WTableCell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("Apple")
'Add the second cell into first row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("$40")
'Add second row to table
row = table.AddRow(False)
'Add the first cell into first row
cell = row.Cells(0)
cell.AddParagraph().AppendText("Orange")
'Add the second cell into first row
cell = row.Cells(1)
cell.AddParagraph().AppendText("$30")
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
section.AddParagraph().AppendText("Price Details");
section.AddParagraph();
//Add a new table into Word document
IWTable table = section.AddTable();
//Add the first row into table
WTableRow row = table.AddRow();
//Add the first cell into first row
WTableCell cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("Item");
//Add the second cell into first row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("Price($)");
//Add the second row into table
row = table.AddRow(true, false);
//Add the first cell into second row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("Apple");
//Add the second cell into second row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("50");
//Add the third row into table
row = table.AddRow(true, false);
//Add the first cell into third row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("Orange");
//Add the second cell into third row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("30");
document.Save("Table.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()
Dim section As IWSection = document.AddSection()
section.AddParagraph().AppendText("Price Details")
section.AddParagraph()
'Add a new table into Word document
Dim table As IWTable = section.AddTable()
'Add the first row into table
Dim row As WTableRow = table.AddRow()
'Add the first cell into first row
Dim cell As WTableCell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("Item")
'Add the second cell into first row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("Price($)")
'Add the second row into table
row = table.AddRow(True, False)
'Add the first cell into second row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("Apple")
'Add the second cell into second row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("50")
'Add the third row into table
row = table.AddRow(True, False)
'Add the first cell into third row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("Orange")
'Add the second cell into third row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("30")
document.Save("Table.docx", FormatType.Docx)
document.Close()
End Sub
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
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
//Add a new table into Word document
IWTable table = section.AddTable();
RowFormat format = new RowFormat();
format.BackColor = Color.LightGray;
format.CellSpacing = 2;
format.Paddings.All = 2;
//Set number of rows and columns
table.ResetCells(2, 2, format, 200);
//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()
Dim section As IWSection = document.AddSection()
'Add a new table into Word document
Dim table As IWTable = section.AddTable()
Dim format As New RowFormat()
format.BackColor = Color.LightGray
format.CellSpacing = 2
format.Paddings.All = 2
'Set number of rows and columns
table.ResetCells(2, 2, format, 200)
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
section.AddParagraph().AppendText("Vertical merging of Table cells");
IWTable table = section.AddTable();
table.ResetCells(5, 5);
//Specify the vertical merge to the third cell, from second row to fifth row
table.ApplyVerticalMerge(2, 1, 4);
document.Save("VerticalMerge.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument()
Dim section As IWSection = document.AddSection()
section.AddParagraph().AppendText("Vertical merging of Table cells")
Dim table As IWTable = section.AddTable()
table.ResetCells(5, 5)
'Specify the vertical merge to the third cell, from second row to fifth row
table.ApplyVerticalMerge(2, 1, 4)
document.Save("VerticalMerge.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
section.AddParagraph().AppendText("Vertical merging of Table cells");
IWTable table = section.AddTable();
table.ResetCells(5, 5);
//Specify the horizontal merge from second cell to fifth cell in third row
table.ApplyHorizontalMerge(2, 1, 4);
document.Save("HorizontalMerge.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument()
Dim section As IWSection = document.AddSection()
section.AddParagraph().AppendText("Vertical merging of Table cells")
Dim table As IWTable = section.AddTable()
table.ResetCells(5, 5)
'Specify the horizontal merge from second cell to fifth cell in third row
table.ApplyHorizontalMerge(2, 1, 4)
document.Save("HorizontalMerge.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Table.docx", FormatType.Docx);
WSection section = document.Sections[0];
//Get the table
WTable table = section.Tables[0] as WTable;
//Apply "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading);
document.Save("TableStyle.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Table.docx", FormatType.Docx)
Dim section As WSection = document.Sections(0)
'Get the table
Dim table As WTable = TryCast(section.Tables(0), WTable)
'Apply "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading)
document.Save("TableStyle.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx");
//Get the table
WTable table = document.Sections[0].Tables[0] as WTable;
//Get the last cell
WTableCell cell = table.LastCell;
//Apply text direction to the last cell
cell.CellFormat.TextDirection = Syncfusion.DocIO.DLS.TextDirection.Vertical;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx")
'Get the table
Dim table As WTable = TryCast(document.Sections(0).Tables(0), WTable)
'Get the last cell
Dim cell As WTableCell = table.LastCell
'Apply text direction to the last cell
cell.CellFormat.TextDirection = Syncfusion.DocIO.DLS.TextDirection.Vertical
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx");
//Get the table
WTable table = document.Sections[0].Tables[0] as WTable;
//Get the last cell
WTableRow row = table.FirstRow;
//Apply text direction to the last cell
row.RowFormat.BackColor = Color.LightGray;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx")
'Get the table
Dim table As WTable = TryCast(document.Sections(0).Tables(0), WTable)
'Get the last cell
Dim row As WTableRow = table.FirstRow
'Apply text direction to the last cell
row.RowFormat.BackColor = Color.LightGray
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx");
//Get the table
WTable table = document.Sections[0].Tables[0] as WTable;
//Get the last cell
WTableRow row = table.LastRow;
//Apply text direction to the last cell
row.RowFormat.BackColor = Color.LightGray;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx")
'Get the table
Dim table As WTable = TryCast(document.Sections(0).Tables(0), WTable)
'Get the last cell
Dim row As WTableRow = table.LastRow
'Apply text direction to the last cell
row.RowFormat.BackColor = Color.LightGray
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a Word document
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
//Add new table.
IWTable table = section.AddTable();
table.ResetCells(2, 2);
//Add content to table cell
table[0, 0].AddParagraph().AppendText("First row, First cell");
table[0, 1].AddParagraph().AppendText("First row, Second cell");
table[1, 0].AddParagraph().AppendText("Second row, First cell");
table[1, 1].AddParagraph().AppendText("Second row, Second cell");
//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 Word document
Dim document As New WordDocument()
Dim section As IWSection = document.AddSection()
section.AddParagraph().AppendText("Horizontal merging of Table cells")
'Add new table.
Dim table As IWTable = section.AddTable()
table.ResetCells(2, 2)
'Add content to table cell
table(0, 0).AddParagraph().AppendText("First row, First cell")
table(0, 1).AddParagraph().AppendText("First row, Second cell")
table(1, 0).AddParagraph().AppendText("Second row, First cell")
table(1, 1).AddParagraph().AppendText("Second row, Second cell")
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument("Table.docx", FormatType.Docx);
WSection section = document.Sections[0];
WTable table = section.Tables[0] as WTable;
//Applies "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading);
//Disable special formatting for header row of the table
table.ApplyStyleForHeaderRow = false;
//Save and close the document
document.Save("TableStyle.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument("Table.docx", FormatType.Docx)
Dim section As WSection = document.Sections(0)
Dim table As WTable = TryCast(section.Tables(0), WTable)
'Applies "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading)
'Disable special formatting for header row of the table
table.ApplyStyleForHeaderRow = False
'Save and close the document
document.Save("TableStyle.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument("Table.docx", FormatType.Docx);
WSection section = document.Sections[0];
WTable table = section.Tables[0] as WTable;
//Applies "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading);
//Enable special formatting for last row of the table
table.ApplyStyleForLastRow = false;
//Save and close the document
document.Save("TableStyle.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument("Table.docx", FormatType.Docx)
Dim section As WSection = document.Sections(0)
Dim table As WTable = TryCast(section.Tables(0), WTable)
'Applies "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading)
'Enable special formatting for last row of the table
table.ApplyStyleForLastRow = True
'Save and close the document
document.Save("TableStyle.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument("Table.docx", FormatType.Docx);
WSection section = document.Sections[0];
WTable table = section.Tables[0] as WTable;
//Applies "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading);
//Disable special formatting for first column of the table
table.ApplyStyleForFirstColumn = false;
//Save and close the document
document.Save("TableStyle.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument("Table.docx", FormatType.Docx)
Dim section As WSection = document.Sections(0)
Dim table As WTable = TryCast(section.Tables(0), WTable)
'Applies "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading)
'Disable special formatting for first column of the table
table.ApplyStyleForFirstColumn = False
'Save and close the document
document.Save("TableStyle.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument("Table.docx", FormatType.Docx);
WSection section = document.Sections[0];
WTable table = section.Tables[0] as WTable;
//Applies "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading);
//Enable special formatting for last column of the table
table.ApplyStyleForLastColumn = true;
//Save and close the document
document.Save("TableStyle.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument("Table.docx", FormatType.Docx)
Dim section As WSection = document.Sections(0)
Dim table As WTable = TryCast(section.Tables(0), WTable)
'Applies "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading)
'Enable special formatting for last column of the table
table.ApplyStyleForLastColumn = True
'Save and close the document
document.Save("TableStyle.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument("Table.docx", FormatType.Docx);
WSection section = document.Sections[0];
WTable table = section.Tables[0] as WTable;
//Applies "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading);
//Disable special formatting for banded rows of the table
table.ApplyStyleForBandedRows = false;
//Save and close the document
document.Save("TableStyle.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument("Table.docx", FormatType.Docx)
Dim section As WSection = document.Sections(0)
Dim table As WTable = TryCast(section.Tables(0), WTable)
'Applies "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading)
'Enable special formatting for banded rows of the table
table.ApplyStyleForBandedRows = False
'Save and close the document
document.Save("TableStyle.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument("Table.docx", FormatType.Docx);
WSection section = document.Sections[0];
WTable table = section.Tables[0] as WTable;
//Applies "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading);
//Enable special formatting for banded columns of the table
table.ApplyStyleForBandedColumns = true;
//Save and close the document
document.Save("TableStyle.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument("Table.docx", FormatType.Docx)
Dim section As WSection = document.Sections(0)
Dim table As WTable = TryCast(section.Tables(0), WTable)
'Applies "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading)
'Enable special formatting for banded columns of the table
table.ApplyStyleForBandedColumns = True
'Save and close the document
document.Save("TableStyle.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
//Add a new table into Word document
IWTable table = section.AddTable();
//Set number of rows and columns
table.ResetCells(2, 2);
//Set left indent for table.
table.IndentFromLeft = 10;
//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()
Dim section As IWSection = document.AddSection()
'Add a new table into Word document
Dim table As IWTable = section.AddTable()
'Set number of rows and columns
table.ResetCells(2, 2)
'Set left indent for table.
table.IndentFromLeft = 10
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
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
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
//Add a new table into Word document
IWTable table = section.AddTable();
RowFormat format = new RowFormat();
format.BackColor = Color.LightGray;
format.CellSpacing = 2;
format.Paddings.All = 2;
//Set number of rows and columns
table.ResetCells(2, 2, format, 200);
//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()
Dim section As IWSection = document.AddSection()
'Add a new table into Word document
Dim table As IWTable = section.AddTable()
Dim format As New RowFormat()
format.BackColor = Color.LightGray
format.CellSpacing = 2
format.Paddings.All = 2
'Set number of rows and columns
table.ResetCells(2, 2, format, 200)
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document
WordDocument document = new WordDocument("Table.docx", FormatType.Docx);
WSection section = document.Sections[0];
//Get the table
WTable table = section.Tables[0] as WTable;
//Apply "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading);
document.Save("TableStyle.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document
Dim document As New WordDocument("Table.docx", FormatType.Docx)
Dim section As WSection = document.Sections(0)
'Get the table
Dim table As WTable = TryCast(section.Tables(0), WTable)
'Apply "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading)
document.Save("TableStyle.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
section.AddParagraph().AppendText("Price Details");
section.AddParagraph();
//Add a new table into Word document
IWTable table = section.AddTable();
//Add the first row to table
WTableRow row = table.AddRow();
//Add the first cell into first row
WTableCell cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("Apple");
//Add the second cell into first row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("$40");
//Add second row to table
row = table.AddRow(false);
//Add the first cell into first row
cell = row.Cells[0];
cell.AddParagraph().AppendText("Orange");
//Add the second cell into first row
cell = row.Cells[1];
cell.AddParagraph().AppendText("$30");
//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()
Dim section As IWSection = document.AddSection()
section.AddParagraph().AppendText("Price Details")
section.AddParagraph()
'Add a new table into Word document
Dim table As IWTable = section.AddTable()
'Add the first row to table
Dim row As WTableRow = table.AddRow()
'Add the first cell into first row
Dim cell As WTableCell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("Apple")
'Add the second cell into first row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("$40")
'Add second row to table
row = table.AddRow(False)
'Add the first cell into first row
cell = row.Cells(0)
cell.AddParagraph().AppendText("Orange")
'Add the second cell into first row
cell = row.Cells(1)
cell.AddParagraph().AppendText("$30")
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
section.AddParagraph().AppendText("Price Details");
section.AddParagraph();
//Add a new table into Word document
IWTable table = section.AddTable();
//Add the first row to table
WTableRow row = table.AddRow();
//Add the first cell into first row
WTableCell cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("Apple");
//Add the second cell into first row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("$40");
//Add second row to table
row = table.AddRow(false);
//Add the first cell into first row
cell = row.Cells[0];
cell.AddParagraph().AppendText("Orange");
//Add the second cell into first row
cell = row.Cells[1];
cell.AddParagraph().AppendText("$30");
//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()
Dim section As IWSection = document.AddSection()
section.AddParagraph().AppendText("Price Details")
section.AddParagraph()
'Add a new table into Word document
Dim table As IWTable = section.AddTable()
'Add the first row to table
Dim row As WTableRow = table.AddRow()
'Add the first cell into first row
Dim cell As WTableCell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("Apple")
'Add the second cell into first row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("$40")
'Add second row to table
row = table.AddRow(False)
'Add the first cell into first row
cell = row.Cells(0)
cell.AddParagraph().AppendText("Orange")
'Add the second cell into first row
cell = row.Cells(1)
cell.AddParagraph().AppendText("$30")
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
section.AddParagraph().AppendText("Price Details");
section.AddParagraph();
//Add a new table into Word document
IWTable table = section.AddTable();
//Add the first row into table
WTableRow row = table.AddRow();
//Add the first cell into first row
WTableCell cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("Item");
//Add the second cell into first row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("Price($)");
//Add the second row into table
row = table.AddRow(true, false);
//Add the first cell into second row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("Apple");
//Add the second cell into second row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("50");
//Add the third row into table
row = table.AddRow(true, false);
//Add the first cell into third row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("Orange");
//Add the second cell into third row
cell = row.AddCell();
//Specify the cell width
cell.Width = 200;
cell.AddParagraph().AppendText("30");
document.Save("Table.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()
Dim section As IWSection = document.AddSection()
section.AddParagraph().AppendText("Price Details")
section.AddParagraph()
'Add a new table into Word document
Dim table As IWTable = section.AddTable()
'Add the first row into table
Dim row As WTableRow = table.AddRow()
'Add the first cell into first row
Dim cell As WTableCell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("Item")
'Add the second cell into first row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("Price($)")
'Add the second row into table
row = table.AddRow(True, False)
'Add the first cell into second row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("Apple")
'Add the second cell into second row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("50")
'Add the third row into table
row = table.AddRow(True, False)
'Add the first cell into third row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("Orange")
'Add the second cell into third row
cell = row.AddCell()
'Specify the cell width
cell.Width = 200
cell.AddParagraph().AppendText("30")
document.Save("Table.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx");
//Get the table
WTable table = document.Sections[0].Tables[0] as WTable;
//Replace the text
table.Replace(new Regex("illustrates"), "describes");
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx")
'Get the table
Dim table As WTable = TryCast(document.Sections(0).Tables(0), WTable)
'Replace the text
table.Replace(New Regex("illustrates"), "describes")
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx");
//Get the table
WTable table = document.Sections[0].Tables[0] as WTable;
//Replace the text
table.Replace("illustrates", "describes", true, true);
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx")
'Get the table
Dim table As WTable = TryCast(document.Sections(0).Tables(0), WTable)
'Replace the text
table.Replace("illustrates", "describes", True, True)
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx");
//Get the table
WTable table = document.Sections[0].Tables[0] as WTable;
//Get first paragraph
WParagraph paragraph = document.Sections[0].Paragraphs[0];
//Get the text using text selection
TextSelection selection = new TextSelection(paragraph, 0, 20);
//Replace the text
table.Replace(new Regex("illustrates"), selection);
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx")
'Get the table
Dim table As WTable = TryCast(document.Sections(0).Tables(0), WTable)
'Get first paragraph
Dim paragraph As WParagraph = document.Sections(0).Paragraphs(0)
'Get the text using text selection
Dim selection As New TextSelection(paragraph, 0, 20)
'Replace the text
table.Replace(New Regex("illustrates"), selection)
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx");
//Get the table
WTable table = document.Sections[0].Tables[0] as WTable;
//Get first paragraph
WParagraph paragraph = document.Sections[0].Paragraphs[0];
//Get the text using text selection
TextSelection selection = new TextSelection(paragraph, 0, 20);
//Replace the text
table.Replace(new Regex("illustrates"), selection, true);
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx")
'Get the table
Dim table As WTable = TryCast(document.Sections(0).Tables(0), WTable)
'Get first paragraph
Dim paragraph As WParagraph = document.Sections(0).Paragraphs(0)
'Get the text using text selection
Dim selection As New TextSelection(paragraph, 0, 20)
'Replace the text
table.Replace(New Regex("illustrates"), selection, True)
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx");
//Get the table
WTable table = document.Sections[0].Tables[0] as WTable;
//Find the text in the table
TextSelection selection = table.Find(new Regex("content"));
WTextRange text = selection.GetAsOneRange();
//Set the character format of the text found
text.CharacterFormat.AllCaps = true;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx")
'Get the table
Dim table As WTable = TryCast(document.Sections(0).Tables(0), WTable)
'Find the text in the table
Dim selection As TextSelection = table.Find(New Regex("content"))
Dim text As WTextRange = selection.GetAsOneRange()
'Set the character format of the text found
text.CharacterFormat.AllCaps = True
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
section.AddParagraph().AppendText("Vertical merging of Table cells");
IWTable table = section.AddTable();
table.ResetCells(5, 5);
//Specify the vertical merge to the third cell, from second row to fifth row
table.ApplyVerticalMerge(2, 1, 4);
document.Save("VerticalMerge.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument()
Dim section As IWSection = document.AddSection()
section.AddParagraph().AppendText("Vertical merging of Table cells")
Dim table As IWTable = section.AddTable()
table.ResetCells(5, 5)
'Specify the vertical merge to the third cell, from second row to fifth row
table.ApplyVerticalMerge(2, 1, 4)
document.Save("VerticalMerge.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
section.AddParagraph().AppendText("Vertical merging of Table cells");
IWTable table = section.AddTable();
table.ResetCells(5, 5);
//Specify the horizontal merge from second cell to fifth cell in third row
table.ApplyHorizontalMerge(2, 1, 4);
document.Save("HorizontalMerge.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument()
Dim section As IWSection = document.AddSection()
section.AddParagraph().AppendText("Vertical merging of Table cells")
Dim table As IWTable = section.AddTable()
table.ResetCells(5, 5)
'Specify the horizontal merge from second cell to fifth cell in third row
table.ApplyHorizontalMerge(2, 1, 4)
document.Save("HorizontalMerge.docx", FormatType.Docx)
document.Close()
End Sub
//Loads the template document
WordDocument document = new WordDocument("Sample.docx");
//Accesses the instance of the first section in the Word document
WSection section = document.Sections[0];
//Accesses the instance of the first table in the section
WTable table = section.Tables[0] as WTable;
//Auto fits the table with respect to window.
table.AutoFit(AutoFitType.FitToWindow);
//Saves and closes the document instance
document.Save("TableAutoFit.docx");
document.Close();
Private Sub SurroundingSub()
Dim document As WordDocument = New WordDocument("Sample.docx")
Dim section As WSection = document.Sections(0)
Dim table As WTable = TryCast(section.Tables(0), WTable)
table.AutoFit(AutoFitType.FitToWindow)
document.Save("TableAutoFit.docx")
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx");
//Get the table
WTable table = document.Sections[0].Tables[0] as WTable;
//Get the last cell
WTableCell cell = table.LastCell;
//Apply text direction to the last cell
cell.CellFormat.TextDirection = Syncfusion.DocIO.DLS.TextDirection.Vertical;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx")
'Get the table
Dim table As WTable = TryCast(document.Sections(0).Tables(0), WTable)
'Get the last cell
Dim cell As WTableCell = table.LastCell
'Apply text direction to the last cell
cell.CellFormat.TextDirection = Syncfusion.DocIO.DLS.TextDirection.Vertical
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx");
//Get the table
WTable table = document.Sections[0].Tables[0] as WTable;
//Get the last cell
WTableRow row = table.FirstRow;
//Apply text direction to the last cell
row.RowFormat.BackColor = Color.LightGray;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx")
'Get the table
Dim table As WTable = TryCast(document.Sections(0).Tables(0), WTable)
'Get the last cell
Dim row As WTableRow = table.FirstRow
'Apply text direction to the last cell
row.RowFormat.BackColor = Color.LightGray
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx");
//Get the table
WTable table = document.Sections[0].Tables[0] as WTable;
//Get the last cell
WTableRow row = table.LastRow;
//Apply text direction to the last cell
row.RowFormat.BackColor = Color.LightGray;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx")
'Get the table
Dim table As WTable = TryCast(document.Sections(0).Tables(0), WTable)
'Get the last cell
Dim row As WTableRow = table.LastRow
'Apply text direction to the last cell
row.RowFormat.BackColor = Color.LightGray
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a Word document
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
//Add new table.
IWTable table = section.AddTable();
table.ResetCells(2, 2);
//Add content to table cell
table[0, 0].AddParagraph().AppendText("First row, First cell");
table[0, 1].AddParagraph().AppendText("First row, Second cell");
table[1, 0].AddParagraph().AppendText("Second row, First cell");
table[1, 1].AddParagraph().AppendText("Second row, Second cell");
//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 Word document
Dim document As New WordDocument()
Dim section As IWSection = document.AddSection()
section.AddParagraph().AppendText("Horizontal merging of Table cells")
'Add new table.
Dim table As IWTable = section.AddTable()
table.ResetCells(2, 2)
'Add content to table cell
table(0, 0).AddParagraph().AppendText("First row, First cell")
table(0, 1).AddParagraph().AppendText("First row, Second cell")
table(1, 0).AddParagraph().AppendText("Second row, First cell")
table(1, 1).AddParagraph().AppendText("Second row, Second cell")
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
//Add a new table into Word document
IWTable table = section.AddTable();
//Set number of rows and columns
table.ResetCells(2, 2);
//Set left indent for table.
table.IndentFromLeft = 10;
//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()
Dim section As IWSection = document.AddSection()
'Add a new table into Word document
Dim table As IWTable = section.AddTable()
'Set number of rows and columns
table.ResetCells(2, 2)
'Set left indent for table.
table.IndentFromLeft = 10
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument("Table.docx", FormatType.Docx);
WSection section = document.Sections[0];
WTable table = section.Tables[0] as WTable;
//Applies "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading);
//Disable special formatting for header row of the table
table.ApplyStyleForHeaderRow = false;
//Save and close the document
document.Save("TableStyle.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument("Table.docx", FormatType.Docx)
Dim section As WSection = document.Sections(0)
Dim table As WTable = TryCast(section.Tables(0), WTable)
'Applies "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading)
'Disable special formatting for header row of the table
table.ApplyStyleForHeaderRow = False
'Save and close the document
document.Save("TableStyle.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument("Table.docx", FormatType.Docx);
WSection section = document.Sections[0];
WTable table = section.Tables[0] as WTable;
//Applies "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading);
//Enable special formatting for last row of the table
table.ApplyStyleForLastRow = false;
//Save and close the document
document.Save("TableStyle.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument("Table.docx", FormatType.Docx)
Dim section As WSection = document.Sections(0)
Dim table As WTable = TryCast(section.Tables(0), WTable)
'Applies "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading)
'Enable special formatting for last row of the table
table.ApplyStyleForLastRow = True
'Save and close the document
document.Save("TableStyle.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument("Table.docx", FormatType.Docx);
WSection section = document.Sections[0];
WTable table = section.Tables[0] as WTable;
//Applies "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading);
//Disable special formatting for first column of the table
table.ApplyStyleForFirstColumn = false;
//Save and close the document
document.Save("TableStyle.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument("Table.docx", FormatType.Docx)
Dim section As WSection = document.Sections(0)
Dim table As WTable = TryCast(section.Tables(0), WTable)
'Applies "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading)
'Disable special formatting for first column of the table
table.ApplyStyleForFirstColumn = False
'Save and close the document
document.Save("TableStyle.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument("Table.docx", FormatType.Docx);
WSection section = document.Sections[0];
WTable table = section.Tables[0] as WTable;
//Applies "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading);
//Enable special formatting for last column of the table
table.ApplyStyleForLastColumn = true;
//Save and close the document
document.Save("TableStyle.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument("Table.docx", FormatType.Docx)
Dim section As WSection = document.Sections(0)
Dim table As WTable = TryCast(section.Tables(0), WTable)
'Applies "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading)
'Enable special formatting for last column of the table
table.ApplyStyleForLastColumn = True
'Save and close the document
document.Save("TableStyle.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument("Table.docx", FormatType.Docx);
WSection section = document.Sections[0];
WTable table = section.Tables[0] as WTable;
//Applies "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading);
//Disable special formatting for banded rows of the table
table.ApplyStyleForBandedRows = false;
//Save and close the document
document.Save("TableStyle.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument("Table.docx", FormatType.Docx)
Dim section As WSection = document.Sections(0)
Dim table As WTable = TryCast(section.Tables(0), WTable)
'Applies "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading)
'Enable special formatting for banded rows of the table
table.ApplyStyleForBandedRows = False
'Save and close the document
document.Save("TableStyle.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument("Table.docx", FormatType.Docx);
WSection section = document.Sections[0];
WTable table = section.Tables[0] as WTable;
//Applies "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading);
//Enable special formatting for banded columns of the table
table.ApplyStyleForBandedColumns = true;
//Save and close the document
document.Save("TableStyle.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument("Table.docx", FormatType.Docx)
Dim section As WSection = document.Sections(0)
Dim table As WTable = TryCast(section.Tables(0), WTable)
'Applies "LightShading" built-in style to table
table.ApplyStyle(BuiltinTableStyle.LightShading)
'Enable special formatting for banded columns of the table
table.ApplyStyleForBandedColumns = True
'Save and close the document
document.Save("TableStyle.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx");
//Get the table
WTable table = document.Sections[0].Tables[0] as WTable;
//Find the text in the table
TextSelection selection = table.Find(new Regex("Cell"));
WTextRange text = selection.GetAsOneRange();
//Get the owner paragraph
WParagraph paragraph = text.OwnerParagraph;
//Get the owner cell
WTableCell cell = paragraph.OwnerTextBody as WTableCell;
//Get the index of the cell
int index = cell.GetCellIndex();
//Apply text direction to the next cell
cell = cell.OwnerRow.Cells[index + 1];
cell.CellFormat.TextDirection = Syncfusion.DocIO.DLS.TextDirection.Vertical;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx")
'Get the table
Dim table As WTable = TryCast(document.Sections(0).Tables(0), WTable)
'Find the text in the table
Dim selection As TextSelection = table.Find(New Regex("Cell"))
Dim text As WTextRange = selection.GetAsOneRange()
'Get the owner paragraph
Dim paragraph As WParagraph = text.OwnerParagraph
'Get the owner cell
Dim cell As WTableCell = TryCast(paragraph.OwnerTextBody, WTableCell)
'Get the index of the cell
Dim index As Integer = cell.GetCellIndex()
'Apply text direction to the next cell
cell = cell.OwnerRow.Cells(index + 1)
cell.CellFormat.TextDirection = Syncfusion.DocIO.DLS.TextDirection.Vertical
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
WordDocument document = new WordDocument();
//Adds new section to the document.
IWSection section = document.AddSection();
//Adds new table to the section.
IWTable table = section.AddTable();
//Adds new row to the table.
WTableRow tableRow = table.AddRow();
//Adds new cell to the row.
WTableCell tableCell = tableRow.AddCell();
tableCell.Width = 100;
//Adds new paragraph to the cell.
IWParagraph paragraph = tableCell.AddParagraph();
//Adds new text to the paragraph.
paragraph.AppendText("Content Control");
//Create the Cell Content Control for the document.
CellContentControl control = new CellContentControl(document);
//Change the color value in Content Control properties.
control.ContentControlProperties.Color = System.Drawing.Color.Green;
//Set it to the row content control.
tableCell.ContentControl = control;
//Save the Word document.
document.Save("Sample.docx", FormatType.Docx);
//Close the document.
document.Close();
Dim document As New WordDocument()
'Adds new section to the document.
Dim section As IWSection = document.AddSection()
'Adds new table to the section.
Dim table As IWTable = section.AddTable()
'Adds new row to the table.
Dim tableRow As WTableRow = table.AddRow()
'Adds new cell to the row.
Dim tableCell As WTableCell = tableRow.AddCell()
tableCell.Width = 100
'Adds new paragraph to the cell.
Dim paragraph As IWParagraph = tableCell.AddParagraph()
'Adds new text to the paragraph.
paragraph.AppendText("Content Control")
'Create the Cell Content Control for the document.
Dim control As New CellContentControl(document)
'Change the color value in Content Control properties.
control.ContentControlProperties.Color = System.Drawing.Color.Green
' Set it to the row content control.
tableCell.ContentControl = control
'Save the Word document.
document.Save("Sample.docx", FormatType.Docx)
'Close the document.
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx");
//Get the table
WTable table = document.Sections[0].Tables[0] as WTable;
//Find the text in the table
TextSelection selection = table.Find(new Regex("Cell"));
WTextRange text = selection.GetAsOneRange();
//Get the owner paragraph
WParagraph paragraph = text.OwnerParagraph;
//Get the owner cell
WTableCell cell = paragraph.OwnerTextBody as WTableCell;
//Get the index of the cell
int index = cell.GetCellIndex();
//Apply text direction to the next cell
WTableRow row = cell.OwnerRow;
row.RowFormat.BackColor = Color.LightGray;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx")
'Get the table
Dim table As WTable = TryCast(document.Sections(0).Tables(0), WTable)
'Find the text in the table
Dim selection As TextSelection = table.Find(New Regex("Cell"))
Dim text As WTextRange = selection.GetAsOneRange()
'Get the owner paragraph
Dim paragraph As WParagraph = text.OwnerParagraph
'Get the owner cell
Dim cell As WTableCell = TryCast(paragraph.OwnerTextBody, WTableCell)
'Get the index of the cell
Dim index As Integer = cell.GetCellIndex()
'Apply text direction to the next cell
Dim row As WTableRow = cell.OwnerRow
row.RowFormat.BackColor = Color.LightGray
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx");
//Get the table
WTable table = document.Sections[0].Tables[0] as WTable;
foreach (WTableRow row in table.Rows)
{
foreach (WTableCell cell in row.Cells)
{
cell.Width = 100;
}
}
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx")
'Get the table
Dim table As WTable = TryCast(document.Sections(0).Tables(0), WTable)
For Each row As WTableRow In table.Rows
For Each cell As WTableCell In row.Cells
cell.Width = 100
Next
Next
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
section.AddParagraph().AppendText("Price Details");
section.AddParagraph();
//Add a new table into Word document
IWTable table = section.AddTable();
//Add the first row into table
WTableRow row = table.AddRow();
//Add the first cell into first row
WTableCell cell = row.AddCell();
cell.Width = 100;
cell.AddParagraph().AppendText("Orange");
//Add the second cell into first row
cell = row.AddCell();
cell.Width = 100;
cell.AddParagraph().AppendText("$30");
//Add the second row into table
row = table.AddRow(true, false);
//Add the first cell into second row
cell = row.AddCell();
cell.Width = 100;
cell.AddParagraph().AppendText("Apple");
//Add the second cell into second row
cell = row.AddCell();
cell.Width = 100;
cell.AddParagraph().AppendText("$50");
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument()
Dim section As IWSection = document.AddSection()
section.AddParagraph().AppendText("Price Details")
section.AddParagraph()
'Add a new table into Word document
Dim table As IWTable = section.AddTable()
'Add the first row into table
Dim row As WTableRow = table.AddRow()
'Add the first cell into first row
Dim cell As WTableCell = row.AddCell()
cell.Width = 100
cell.AddParagraph().AppendText("Orange")
'Add the second cell into first row
cell = row.AddCell()
cell.Width = 100
cell.AddParagraph().AppendText("$30")
'Add the second row into table
row = table.AddRow(True, False)
'Add the first cell into second row
cell = row.AddCell()
cell.Width = 100
cell.AddParagraph().AppendText("Apple")
'Add the second cell into second row
cell = row.AddCell()
cell.Width = 100
cell.AddParagraph().AppendText("$50")
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
section.AddParagraph().AppendText("Price Details");
section.AddParagraph();
//Add a new table into Word document
IWTable table = section.AddTable();
//Add the first row into table
WTableRow row = table.AddRow();
//Add the first cell into first row
WTableCell cell = row.AddCell();
cell.Width = 100;
cell.AddParagraph().AppendText("Orange");
//Add the second cell into first row
cell = row.AddCell();
cell.Width = 100;
cell.AddParagraph().AppendText("$30");
//Add the second row into table
row = table.AddRow(true, false);
//Add the first cell into second row
cell = row.AddCell();
cell.Width = 50;
cell.AddParagraph().AppendText("Apple");
//Add the second cell into second row
cell = row.AddCell(true);
cell.AddParagraph().AppendText("$50");
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument()
Dim section As IWSection = document.AddSection()
section.AddParagraph().AppendText("Price Details")
section.AddParagraph()
'Add a new table into Word document
Dim table As IWTable = section.AddTable()
'Add the first row into table
Dim row As WTableRow = table.AddRow()
'Add the first cell into first row
Dim cell As WTableCell = row.AddCell()
cell.Width = 100
cell.AddParagraph().AppendText("Orange")
'Add the second cell into first row
cell = row.AddCell()
cell.Width = 100
cell.AddParagraph().AppendText("$30")
'Add the second row into table
row = table.AddRow(True, False)
'Add the first cell into second row
cell = row.AddCell()
cell.Width = 50
cell.AddParagraph().AppendText("Apple")
'Add the second cell into second row
cell = row.AddCell(True)
cell.AddParagraph().AppendText("$50")
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx");
//Get the table
WTable table = document.Sections[0].Tables[0] as WTable;
//Find the text in the table
TextSelection selection = table.Find(new Regex("Cell"));
WTextRange text = selection.GetAsOneRange();
//Get the owner paragraph
WParagraph paragraph = text.OwnerParagraph;
//Get the owner cell
WTableCell cell = paragraph.OwnerTextBody as WTableCell;
//Get the row index.
int index = cell.OwnerRow.GetRowIndex();
//Set height for next row
table.Rows[index + 1].Height = 20;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx")
'Get the table
Dim table As WTable = TryCast(document.Sections(0).Tables(0), WTable)
'Find the text in the table
Dim selection As TextSelection = table.Find(New Regex("Cell"))
Dim text As WTextRange = selection.GetAsOneRange()
'Get the owner paragraph
Dim paragraph As WParagraph = text.OwnerParagraph
'Get the owner cell
Dim cell As WTableCell = TryCast(paragraph.OwnerTextBody, WTableCell)
'Get the row index.
Dim index As Integer = cell.OwnerRow.GetRowIndex()
'Set height for next row
table.Rows(index + 1).Height = 20
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
//Add a new table into Word document
IWTable table = section.AddTable();
//Set number of rows and columns
table.ResetCells(2, 2);
//Set row height and type.
table.Rows[1].Height = 20;
table.Rows[1].HeightType = TableRowHeightType.AtLeast;
//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()
Dim section As IWSection = document.AddSection()
'Add a new table into Word document
Dim table As IWTable = section.AddTable()
'Set number of rows and columns
table.ResetCells(2, 2)
'Set row height and type.
table.Rows(1).Height = 20
table.Rows(1).HeightType = TableRowHeightType.AtLeast
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
WordDocument document = new WordDocument();
//Adds new section to the document.
IWSection section = document.AddSection();
//Adds new table to the section.
IWTable table = section.AddTable();
//Adds new row to the table.
WTableRow tableRow = table.AddRow();
//Adds new cell to the row.
WTableCell tableCell = tableRow.AddCell();
tableCell.Width = 100;
//Adds new paragraph to the cell.
IWParagraph paragraph = tableCell.AddParagraph();
//Adds new text to the paragraph.
paragraph.AppendText("Content Control");
//Create the Row Content Control for the document.
RowContentControl control = new RowContentControl(document);
//Change the color value in Content Control properties.
control.ContentControlProperties.Color = System.Drawing.Color.Blue;
// Sets it to the row content control.
tableRow.ContentControl = control;
//Save the Word document.
document.Save("Sample.docx", FormatType.Docx);
//Close the document.
document.Close();
Dim document As New WordDocument()
'Adds new section to the document.
Dim section As IWSection = document.AddSection()
'Adds new table to the section.
Dim table As IWTable = section.AddTable()
'Adds new row to the table.
Dim tableRow As WTableRow = table.AddRow()
'Adds new cell to the row.
Dim tableCell As WTableCell = tableRow.AddCell()
tableCell.Width = 100
'Adds new paragraph to the cell.
Dim paragraph As IWParagraph = tableCell.AddParagraph()
'Adds new text to the paragraph.
paragraph.AppendText("Content Control")
'Create the Row Content Control for the document.
Dim control As New RowContentControl(document)
'Change the color value in Content Control properties.
control.ContentControlProperties.Color = System.Drawing.Color.Blue
' Sets it to the row content control.
tableRow.ContentControl = control
'Save the Word document.
document.Save("Sample.docx", FormatType.Docx)
'Close the document.
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Loads an existing document
WordDocument document = new WordDocument("Template.docx");
HTMLExport export = new HTMLExport();
//The images in the input document will be copied to this folder
document.SaveOptions.HtmlExportImagesFolder = @"D:\Data\";
//The headers and footers in the input will be exported
document.SaveOptions.HtmlExportHeadersFooters = true;
//Export the text form fields as editable
document.SaveOptions.HtmlExportTextInputFormFieldAsText = false;
//Set the style sheet type
document.SaveOptions.HtmlExportCssStyleSheetType = CssStyleSheetType.External;
//Set name for style sheet
document.SaveOptions.HtmlExportCssStyleSheetFileName = "UserDefinedFileName.css";
//Save the document as html file
export.SaveAsXhtml(document, "WordtoHtml.html");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Loads an existing document
Dim document As New WordDocument("Template.docx")
Dim export As New HTMLExport()
'The images in the input document will be copied to this folder
document.SaveOptions.HtmlExportImagesFolder = "D:\Data\"
'The headers and footers in the input will be exported
document.SaveOptions.HtmlExportHeadersFooters = True
'Export the text form fields as editable
document.SaveOptions.HtmlExportTextInputFormFieldAsText = False
'Set the style sheet type
document.SaveOptions.HtmlExportCssStyleSheetType = CssStyleSheetType.External
'Set name for style sheet
document.SaveOptions.HtmlExportCssStyleSheetFileName = "UserDefinedFileName.css"
'Save the document as html file
export.SaveAsXhtml(document, "WordtoHtml.html")
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Export the fonts used in the document
document.SaveOptions.EPubExportFont = true;
//Export header and footer
document.SaveOptions.HtmlExportHeadersFooters = true;
//Save the document as EPub file
document.Save("WordToEPub.epub", FormatType.EPub);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Export the fonts used in the document
document.SaveOptions.EPubExportFont = True
'Export header and footer
document.SaveOptions.HtmlExportHeadersFooters = True
'Save the document as EPub file
document.Save("WordToEPub.epub", FormatType.EPub)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing document
WordDocument document = new WordDocument("Template.doc", FormatType.Doc);
//Preserve compatibility mode as in the input Word document
document.SaveOptions.MaintainCompatibilityMode = true;
//Save the document as Docx file
document.Save("Result.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing document
Dim document As New WordDocument("Template.doc", FormatType.Doc)
'Export the fonts used in the document
document.SaveOptions.EPubExportFont = True
'Preserve compatibility mode as in the input Word document
document.SaveOptions.MaintainCompatibilityMode = True
'Save the document as Docx file
document.Save("Result.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
Open the document
WordDocument document = new WordDocument("Sample.docx");
Set the folder location to export the images
document.SaveOptions.MarkdownExportImagesFolder = @"D:/WordToMarkdownConversion/";
Save as Markdown document
document.Save("Result.md", FormatType.Markdown);
Close the document
document.Close();
//'Opens the document.
Dim document As WordDocument = New WordDocument("Sample.docx");
Set the folder location to export the images
document.SaveOptions.MarkdownExportImagesFolder = @"D:/WordToMarkdownConversion/";
Save as Markdown document
document.Save("Result.md", FormatType.Markdown);
Close the document
document.Close();
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing document
WordDocument document = new WordDocument("Template.rtf", FormatType.Rtf);
//Sets the OptmizedRtfFileSize property as true
document.SaveOptions.OptimizeRtfFileSize = true;
//Save the document as Docx file
document.Save("Result.rtf", FormatType.Rtf);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing document
Dim document As New WordDocument("Template.rtf", FormatType.Rtf)
'Sets the OptmizedRtfFileSize property as true
document.SaveOptions.OptimizeRtfFileSize = True
'Save the document as Docx file
document.Save("Result.rtf", FormatType.Rtf)
'Close the document
document.Close()
End Sub
//Opens an existing Word document
WordDocument document = new WordDocument("Input.docx");
//Disables a flag to export HTML without WordCompatiblity
document.SaveOptions.HTMLExportWithWordCompatiblity = false;
//Saves the document
document.Save("Output.html", FormatType.Html);
//Closes the document
document.Close();
'Opens an existing Word document
Dim document As WordDocument = New WordDocument("Input.docx")
'Disables a flag to export HTML without WordCompatiblity
document.SaveOptions.HTMLExportWithWordCompatiblity = False
'Saves the document
document.Save("Output.html", FormatType.Html)
'Close the document
document.Close()
//Loads an existing Word document
WordDocument wordDocument = new WordDocument("Template.docx", FormatType.Docx);
//Sets ShowInBalloons to render a document comments in converted PDF document.
wordDocument.RevisionOptions.CommentDisplayMode = CommentDisplayMode.ShowInBalloons;
//Instantiation of DocToPDFConverter for Word to PDF conversion
DocToPDFConverter converter = new DocToPDFConverter();
//Converts Word document into PDF document
PdfDocument pdfDocument = converter.ConvertToPDF(wordDocument);
//Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf");
//Releases all resources used by the object
converter.Dispose();
//Closes the instance of document objects
wordDocument.Close();
pdfDocument.Close(true);
'Loads an existing Word document
Dim wordDocument As WordDocument = New WordDocument("Template.docx", FormatType.Docx)
'Sets ShowInBalloons to render a document comments in converted PDF document.
wordDocument.RevisionOptions.CommentDisplayMode = CommentDisplayMode.ShowInBalloons
'Instantiation of DocToPDFConverter for Word to PDF conversion
Dim converter As DocToPDFConverter = New DocToPDFConverter
'Converts Word document into PDF document
Dim pdfDocument As PdfDocument = converter.ConvertToPDF(wordDocument)
'Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf")
'Releases all resources used by the object
converter.Dispose()
'Closes the instance of document objects
wordDocument.Close()
pdfDocument.Close(True)
//Loads an existing Word document
WordDocument wordDocument = new WordDocument("Template.docx", FormatType.Docx);
//Sets ShowInBalloons to render a document comments in converted PDF document.
wordDocument.RevisionOptions.CommentDisplayMode = CommentDisplayMode.ShowInBalloons;
//Sets the color to be used for Comment Balloon.
wordDocument.RevisionOptions.CommentColor = RevisionColor.Pink;
//Instantiation of DocToPDFConverter for Word to PDF conversion
DocToPDFConverter converter = new DocToPDFConverter();
//Converts Word document into PDF document
PdfDocument pdfDocument = converter.ConvertToPDF(wordDocument);
//Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf");
//Releases all resources used by the object
converter.Dispose();
//Closes the instance of document objects
wordDocument.Close();
pdfDocument.Close(true);
'Loads an existing Word document
Dim wordDocument As WordDocument = New WordDocument("Template.docx", FormatType.Docx)
'Sets ShowInBalloons to render a document comments in converted PDF document.
wordDocument.RevisionOptions.CommentDisplayMode = CommentDisplayMode.ShowInBalloons
'Sets the color to be used for Comment Balloon.
wordDocument.RevisionOptions.CommentColor = RevisionColor.Pink
'Instantiation of DocToPDFConverter for Word to PDF conversion
Dim converter As DocToPDFConverter = New DocToPDFConverter
'Converts Word document into PDF document
Dim pdfDocument As PdfDocument = converter.ConvertToPDF(wordDocument)
'Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf")
'Releases all resources used by the object
converter.Dispose()
'Closes the instance of document objects
wordDocument.Close()
pdfDocument.Close(True)
//Loads an existing Word document
WordDocument wordDocument = new WordDocument("Template.docx", FormatType.Docx);
//Sets revision types to preserve track changes in PDF conversion.
wordDocument.RevisionOptions.ShowMarkup = RevisionType.Insertions | RevisionType.Formatting | RevisionType.Deletions;
//Sets the color for Revision mark color.
wordDocument.RevisionOptions.RevisionBarsColor = RevisionColor.Pink;
//Instantiation of DocToPDFConverter for Word to PDF conversion
DocToPDFConverter converter = new DocToPDFConverter();
//Converts Word document into PDF document
PdfDocument pdfDocument = converter.ConvertToPDF(wordDocument);
//Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf");
//Releases all resources used by the object
converter.Dispose();
//Closes the instance of document objects
wordDocument.Close();
pdfDocument.Close(true);
'Loads an existing Word document
Dim wordDocument As WordDocument = New WordDocument("Template.docx", FormatType.Docx)
'Sets revision types to preserve track changes in PDF conversion.
wordDocument.RevisionOptions.ShowMarkup = RevisionType.Insertions Or RevisionType.Formatting Or RevisionType.Deletions
'Sets the color for Revision mark color.
wordDocument.RevisionOptions.RevisionBarsColor = RevisionColor.Pink
'Instantiation of DocToPDFConverter for Word to PDF conversion
Dim converter As DocToPDFConverter = New DocToPDFConverter
'Converts Word document into PDF document
Dim pdfDocument As PdfDocument = converter.ConvertToPDF(wordDocument)
'Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf")
'Releases all resources used by the object
converter.Dispose()
'Closes the instance of document objects
wordDocument.Close()
pdfDocument.Close(True)
//Loads an existing Word document
WordDocument wordDocument = new WordDocument("Template.docx", FormatType.Docx);
//Sets revision types to preserve track changes in PDF conversion.
wordDocument.RevisionOptions.ShowMarkup = RevisionType.Insertions | RevisionType.Formatting | RevisionType.Deletions;
//Sets the color for inserted text color.
wordDocument.RevisionOptions.InsertedTextColor = RevisionColor.ClassicRed;
//Instantiation of DocToPDFConverter for Word to PDF conversion
DocToPDFConverter converter = new DocToPDFConverter();
//Converts Word document into PDF document
PdfDocument pdfDocument = converter.ConvertToPDF(wordDocument);
//Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf");
//Releases all resources used by the object
converter.Dispose();
//Closes the instance of document objects
wordDocument.Close();
pdfDocument.Close(true);
'Loads an existing Word document
Dim wordDocument As WordDocument = New WordDocument("Template.docx", FormatType.Docx)
'Sets revision types to preserve track changes in PDF conversion.
wordDocument.RevisionOptions.ShowMarkup = RevisionType.Insertions Or RevisionType.Formatting Or RevisionType.Deletions
'Sets the color for inserted text color.
wordDocument.RevisionOptions.InsertedTextColor = RevisionColor.ClassicRed
'Instantiation of DocToPDFConverter for Word to PDF conversion
Dim converter As DocToPDFConverter = New DocToPDFConverter
'Converts Word document into PDF document
Dim pdfDocument As PdfDocument = converter.ConvertToPDF(wordDocument)
'Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf")
'Releases all resources used by the object
converter.Dispose()
'Closes the instance of document objects
wordDocument.Close()
pdfDocument.Close(True)
//Loads an existing Word document
WordDocument wordDocument = new WordDocument("Template.docx", FormatType.Docx);
//Sets revision types to preserve track changes in PDF conversion.
wordDocument.RevisionOptions.ShowMarkup = RevisionType.Insertions | RevisionType.Formatting | RevisionType.Deletions;
//Sets the color for Deleted content color.
wordDocument.RevisionOptions.DeletedTextColor = RevisionColor.ClassicBlue;
//Instantiation of DocToPDFConverter for Word to PDF conversion
DocToPDFConverter converter = new DocToPDFConverter();
//Converts Word document into PDF document
PdfDocument pdfDocument = converter.ConvertToPDF(wordDocument);
//Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf");
//Releases all resources used by the object
converter.Dispose();
//Closes the instance of document objects
wordDocument.Close();
pdfDocument.Close(true);
'Loads an existing Word document
Dim wordDocument As WordDocument = New WordDocument("Template.docx", FormatType.Docx)
'Sets revision types to preserve track changes in PDF conversion.
wordDocument.RevisionOptions.ShowMarkup = RevisionType.Insertions Or RevisionType.Formatting Or RevisionType.Deletions
'Sets the color for Deleted content color.
wordDocument.RevisionOptions.DeletedTextColor = RevisionColor.ClassicBlue
'Instantiation of DocToPDFConverter for Word to PDF conversion
Dim converter As DocToPDFConverter = New DocToPDFConverter
'Converts Word document into PDF document
Dim pdfDocument As PdfDocument = converter.ConvertToPDF(wordDocument)
'Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf")
'Releases all resources used by the object
converter.Dispose()
'Closes the instance of document objects
wordDocument.Close()
pdfDocument.Close(True)
//Loads an existing Word document
WordDocument wordDocument = new WordDocument("Template.docx", FormatType.Docx);
//Sets revision types to preserve track changes in PDF conversion.
wordDocument.RevisionOptions.ShowMarkup = RevisionType.Insertions | RevisionType.Formatting | RevisionType.Deletions;
//Sets the color for Revised property color.
wordDocument.RevisionOptions.RevisedPropertiesColor = RevisionColor.Turquoise;
//Instantiation of DocToPDFConverter for Word to PDF conversion
DocToPDFConverter converter = new DocToPDFConverter();
//Converts Word document into PDF document
PdfDocument pdfDocument = converter.ConvertToPDF(wordDocument);
//Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf");
//Releases all resources used by the object
converter.Dispose();
//Closes the instance of document objects
wordDocument.Close();
pdfDocument.Close(true);
'Loads an existing Word document
Dim wordDocument As WordDocument = New WordDocument("Template.docx", FormatType.Docx)
'Sets revision types to preserve track changes in PDF conversion.
wordDocument.RevisionOptions.ShowMarkup = RevisionType.Insertions Or RevisionType.Formatting Or RevisionType.Deletions
'Sets the color for Revised property color.
wordDocument.RevisionOptions.RevisedPropertiesColor = RevisionColor.Turquoise
'Instantiation of DocToPDFConverter for Word to PDF conversion
Dim converter As DocToPDFConverter = New DocToPDFConverter
'Converts Word document into PDF document
Dim pdfDocument As PdfDocument = converter.ConvertToPDF(wordDocument)
'Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf")
'Releases all resources used by the object
converter.Dispose()
'Closes the instance of document objects
wordDocument.Close()
pdfDocument.Close(True)
//Loads an existing Word document
WordDocument wordDocument = new WordDocument("Template.docx", FormatType.Docx);
//Sets revision types to preserve track changes in PDF conversion.
wordDocument.RevisionOptions.ShowMarkup = RevisionType.Insertions | RevisionType.Formatting | RevisionType.Deletions;
//Instantiation of DocToPDFConverter for Word to PDF conversion
DocToPDFConverter converter = new DocToPDFConverter();
//Converts Word document into PDF document
PdfDocument pdfDocument = converter.ConvertToPDF(wordDocument);
//Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf");
//Releases all resources used by the object
converter.Dispose();
//Closes the instance of document objects
wordDocument.Close();
pdfDocument.Close(true);
'Loads an existing Word document
Dim wordDocument As WordDocument = New WordDocument("Template.docx", FormatType.Docx)
'Sets revision types to preserve track changes in PDF conversion.
wordDocument.RevisionOptions.ShowMarkup = RevisionType.Insertions Or RevisionType.Formatting Or RevisionType.Deletions
'Instantiation of DocToPDFConverter for Word to PDF conversion
Dim converter As DocToPDFConverter = New DocToPDFConverter
'Converts Word document into PDF document
Dim pdfDocument As PdfDocument = converter.ConvertToPDF(wordDocument)
'Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf")
'Releases all resources used by the object
converter.Dispose()
'Closes the instance of document objects
wordDocument.Close()
pdfDocument.Close(True)
//Loads an existing Word document
WordDocument wordDocument = new WordDocument("Template.docx", FormatType.Docx);
//Sets revision types to preserve track changes in PDF conversion.
wordDocument.RevisionOptions.ShowMarkup = RevisionType.Insertions | RevisionType.Formatting | RevisionType.Deletions;
//Hides showing revisions in balloons when converting Word documents to PDF
wordDocument.RevisionOptions.ShowInBalloons = RevisionType.None;
//Instantiation of DocToPDFConverter for Word to PDF conversion
DocToPDFConverter converter = new DocToPDFConverter();
//Converts Word document into PDF document
PdfDocument pdfDocument = converter.ConvertToPDF(wordDocument);
//Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf");
//Releases all resources used by the object
converter.Dispose();
//Closes the instance of document objects
wordDocument.Close();
pdfDocument.Close(true);
'Loads an existing Word document
Dim wordDocument As WordDocument = New WordDocument("Template.docx", FormatType.Docx)
'Sets revision types to preserve track changes in PDF conversion.
wordDocument.RevisionOptions.ShowMarkup = RevisionType.Insertions Or RevisionType.Formatting Or RevisionType.Deletions
'Hides showing revisions in balloons when converting Word documents to PDF
wordDocument.RevisionOptions.ShowInBalloons = RevisionType.None
'Instantiation of DocToPDFConverter for Word to PDF conversion
Dim converter As DocToPDFConverter = New DocToPDFConverter
'Converts Word document into PDF document
Dim pdfDocument As PdfDocument = converter.ConvertToPDF(wordDocument)
'Saves the PDF file
pdfDocument.Save("WordtoPDF.pdf")
'Releases all resources used by the object
converter.Dispose()
'Closes the instance of document objects
wordDocument.Close()
pdfDocument.Close(True)
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument();
document.Open("Table.docx", FormatType.Docx);
WSection section = document.Sections[0];
WTable table = section.Tables[0] as WTable;
//Access the instance of the first row in the table
WTableRow row = table.Rows[0];
//Specify the row height
row.Height = 20;
//Specify the row height type
row.HeightType = TableRowHeightType.AtLeast;
//Access the instance of the first cell in the row
WTableCell cell = row.Cells[0];
//Specify the cell back ground color
cell.CellFormat.BackColor = Color.FromArgb(192, 192, 192);
//Specify the same padding as table option as false to preserve current cell padding
cell.CellFormat.SamePaddingsAsTable = false;
//Specify the left, right, top and bottom padding of the cell
cell.CellFormat.Paddings.Left = 5;
cell.CellFormat.Paddings.Right = 5;
cell.CellFormat.Paddings.Top = 5;
cell.CellFormat.Paddings.Bottom = 5;
//Specify the vertical alignment of content of text
cell.CellFormat.VerticalAlignment = VerticalAlignment.Middle;
//Access the instance of the second cell in the row
cell = row.Cells[1];
cell.CellFormat.BackColor = Color.FromArgb(192, 192, 192);
cell.CellFormat.SamePaddingsAsTable = false;
//Specify the left, right, top and bottom padding of the cell
cell.CellFormat.Paddings.All = 5;
cell.CellFormat.VerticalAlignment = VerticalAlignment.Middle;
document.Save("TableCellFormatting.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument()
document.Open("Table.docx", FormatType.Docx)
Dim section As WSection = document.Sections(0)
Dim table As WTable = TryCast(section.Tables(0), WTable)
'Access the instance of the first row in the table
Dim row As WTableRow = table.Rows(0)
'Specify the row height
row.Height = 20
'Specify the row height type
row.HeightType = TableRowHeightType.AtLeast
'Access the instance of the first cell in the row
Dim cell As WTableCell = row.Cells(0)
'Specify the cell back ground color
cell.CellFormat.BackColor = Color.FromArgb(192, 192, 192)
'Specify the same padding as table option as false to preserve current cell padding
cell.CellFormat.SamePaddingsAsTable = False
'Specify the left, right, top and bottom padding of the cell
cell.CellFormat.Paddings.Left = 5
cell.CellFormat.Paddings.Right = 5
cell.CellFormat.Paddings.Top = 5
cell.CellFormat.Paddings.Bottom = 5
'Specify the vertical alignment of content of text
cell.CellFormat.VerticalAlignment = VerticalAlignment.Middle
'Access the instance of the second cell in the row
cell = row.Cells(1)
cell.CellFormat.BackColor = Color.FromArgb(192, 192, 192)
cell.CellFormat.SamePaddingsAsTable = False
'Specify the left, right, top and bottom padding of the cell
cell.CellFormat.Paddings.All = 5
cell.CellFormat.VerticalAlignment = VerticalAlignment.Middle
document.Save("TableCellFormatting.docx", FormatType.Docx)
document.Close()
End Sub
Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
Gets the style from document styles collection
Style style = document.Styles.FindByName("ParaStyle") as Style;
Link the styles
style.LinkedStyleName = "CharStyle";
Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Load an existing Word document into DocIO instance
Dim document As WordDocument = New WordDocument("Template.docx")
'Gets the style from document styles collection
Dim style As Style = TryCast(document.Styles.FindByName("ParaStyle"), Style)
'Link the styles
style.LinkedStyleName = "CharStyle"
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new text to the paragraph
IWTextRange text = paragraph.AppendText("Text with All caps.");
//All Caps
text.CharacterFormat.AllCaps = true;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Right to left text.");
//Right to left text with bold and italic styles.
text.CharacterFormat.Bidi = true;
text.CharacterFormat.FontNameBidi = "Times New Roman";
text.CharacterFormat.FontSizeBidi = 14;
text.CharacterFormat.BoldBidi = true;
text.CharacterFormat.ItalicBidi = true;
paragraph = section.AddParagraph();
//Bold
text = paragraph.AppendText("Bold text.");
text.CharacterFormat.Bold = true;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Text with border.");
//Borders
text.CharacterFormat.Border.BorderType = BorderStyle.DotDash;
text.CharacterFormat.Border.LineWidth = 0.5f;
text.CharacterFormat.Border.Color = Color.Blue;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Character spacing.");
text.CharacterFormat.CharacterSpacing = 1;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Double strike.");
//Double strike
text.CharacterFormat.DoubleStrike = true;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Emboss.");
//Emboss
text.CharacterFormat.Emboss = true;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Engrave.");
//Engrave
text.CharacterFormat.Engrave = true;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Font name.");
//Font name
text.CharacterFormat.FontName = "Algerian";
paragraph = section.AddParagraph();
text = paragraph.AppendText("Font size.");
//Font size
text.CharacterFormat.FontSize = 10;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Highlight color.");
//Highlight color
text.CharacterFormat.HighlightColor = Color.Gray;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Italic.");
//Italic
text.CharacterFormat.Italic = true;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Outline.");
//Outline
text.CharacterFormat.OutLine = true;
paragraph = section.AddParagraph();
paragraph.AppendText("Position Property with text");
text = paragraph.AppendText("raised by 10 points.");
//Position
text.CharacterFormat.Position = 10;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Shadow.");
//Shadow
text.CharacterFormat.Shadow = true;
paragraph = section.AddParagraph();
text = paragraph.AppendText("SmallCaps.");
//SmallCaps
text.CharacterFormat.SmallCaps = true;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Strikeout.");
//Strikeout
text.CharacterFormat.Strikeout = true;
paragraph = section.AddParagraph();
paragraph.AppendText("Text");
text = paragraph.AppendText("Subscript.");
//Subscript
text.CharacterFormat.SubSuperScript = SubSuperScript.SubScript;
paragraph = section.AddParagraph();
paragraph.AppendText("Text");
text = paragraph.AppendText("Superscript.");
//Superscript
text.CharacterFormat.SubSuperScript = SubSuperScript.SuperScript;
paragraph = section.AddParagraph();
text = paragraph.AppendText("TextBackgroundColor.");
//TextBackgroundColor
text.CharacterFormat.TextBackgroundColor = Color.LightSkyBlue;
paragraph = section.AddParagraph();
text = paragraph.AppendText("TextColor.");
//TextColor
text.CharacterFormat.TextColor = Color.Green;
paragraph = section.AddParagraph();
text = paragraph.AppendText("UnderlineStyle.");
//UnderlineStyle
text.CharacterFormat.UnderlineStyle = UnderlineStyle.Dash;
//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()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new text to the paragraph
Dim text As IWTextRange = paragraph.AppendText("Text with All caps.")
'All Caps
text.CharacterFormat.AllCaps = True
paragraph = section.AddParagraph()
text = paragraph.AppendText("Right to left text.")
'Right to left text with bold and italic styles.
text.CharacterFormat.Bidi = True
text.CharacterFormat.FontNameBidi = "Times New Roman"
text.CharacterFormat.FontSizeBidi = 14
text.CharacterFormat.BoldBidi = True
text.CharacterFormat.ItalicBidi = True
paragraph = section.AddParagraph()
'Bold
text = paragraph.AppendText("Bold text.")
text.CharacterFormat.Bold = True
paragraph = section.AddParagraph()
text = paragraph.AppendText("Text with border.")
'Borders
text.CharacterFormat.Border.BorderType = BorderStyle.DotDash
text.CharacterFormat.Border.LineWidth = 0.5F
text.CharacterFormat.Border.Color = Color.Blue
paragraph = section.AddParagraph()
text = paragraph.AppendText("Character spacing.")
text.CharacterFormat.CharacterSpacing = 1
paragraph = section.AddParagraph()
text = paragraph.AppendText("Double strike.")
'Double strike
text.CharacterFormat.DoubleStrike = True
paragraph = section.AddParagraph()
text = paragraph.AppendText("Emboss.")
'Emboss
text.CharacterFormat.Emboss = True
paragraph = section.AddParagraph()
text = paragraph.AppendText("Engrave.")
'Engrave
text.CharacterFormat.Engrave = True
paragraph = section.AddParagraph()
text = paragraph.AppendText("Font name.")
'Font name
text.CharacterFormat.FontName = "Algerian"
paragraph = section.AddParagraph()
text = paragraph.AppendText("Font size.")
'Font size
text.CharacterFormat.FontSize = 10
paragraph = section.AddParagraph()
text = paragraph.AppendText("Highlight color.")
'Highlight color
text.CharacterFormat.HighlightColor = Color.Gray
paragraph = section.AddParagraph()
text = paragraph.AppendText("Italic.")
'Italic
text.CharacterFormat.Italic = True
paragraph = section.AddParagraph()
text = paragraph.AppendText("Outline.")
'Outline
text.CharacterFormat.OutLine = True
paragraph = section.AddParagraph()
paragraph.AppendText("Position Property with text")
text = paragraph.AppendText("raised by 10 points.")
'Position
text.CharacterFormat.Position = 10
paragraph = section.AddParagraph()
text = paragraph.AppendText("Shadow.")
'Shadow
text.CharacterFormat.Shadow = True
paragraph = section.AddParagraph()
text = paragraph.AppendText("SmallCaps.")
'SmallCaps
text.CharacterFormat.SmallCaps = True
paragraph = section.AddParagraph()
text = paragraph.AppendText("Strikeout.")
'Strikeout
text.CharacterFormat.Strikeout = True
paragraph = section.AddParagraph()
paragraph.AppendText("Text")
text = paragraph.AppendText("Subscript.")
'Subscript
text.CharacterFormat.SubSuperScript = SubSuperScript.SubScript
paragraph = section.AddParagraph()
paragraph.AppendText("Text")
text = paragraph.AppendText("Superscript.")
'Superscript
text.CharacterFormat.SubSuperScript = SubSuperScript.SuperScript
paragraph = section.AddParagraph()
text = paragraph.AppendText("TextBackgroundColor.")
'TextBackgroundColor
text.CharacterFormat.TextBackgroundColor = Color.LightSkyBlue
paragraph = section.AddParagraph()
text = paragraph.AppendText("TextColor.")
'TextColor
text.CharacterFormat.TextColor = Color.Green
paragraph = section.AddParagraph()
text = paragraph.AppendText("UnderlineStyle.")
'UnderlineStyle
text.CharacterFormat.UnderlineStyle = UnderlineStyle.Dash
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new text
IWTextRange text = paragraph.AppendText("Text to describe LocaleIdBidi text");
//Set right to left layout for text
text.CharacterFormat.Bidi = true;
//Set language identifier for right to left or complex script characters
text.CharacterFormat.LocaleIdBidi = (short)LocaleIDs.he_IL;
paragraph = section.AddParagraph();
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new text
Dim text As IWTextRange = paragraph.AppendText("Text to describe LocaleIdBidi text")
'Set right to left layout for text
text.CharacterFormat.Bidi = True
'Set language identifier for right to left or complex script characters
text.CharacterFormat.LocaleIdBidi = CType(LocaleIDs.he_IL, Short)
paragraph = section.AddParagraph()
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new text
IWTextRange text = paragraph.AppendText("Text to describe contextual alternates");
text.CharacterFormat.FontName = "Segoe Script";
//Set contextual alternates
text.CharacterFormat.UseContextualAlternates = true;
paragraph = section.AddParagraph();
//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()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new text
Dim text As IWTextRange = paragraph.AppendText("Text to describe contextual alternates")
text.CharacterFormat.FontName = "Segoe Script"
'Set contextual alternates
text.CharacterFormat.UseContextualAlternates = True
paragraph = section.AddParagraph()
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new text
IWTextRange text = paragraph.AppendText("Text to describe discretional ligatures");
//Set ligature type
text.CharacterFormat.Ligatures = LigatureType.Discretional;
text.CharacterFormat.FontName = "Arial";
paragraph = section.AddParagraph();
text = paragraph.AppendText("Text to describe contextual ligatures");
text.CharacterFormat.Ligatures = LigatureType.Contextual;
text.CharacterFormat.FontName = "Arial";
paragraph = section.AddParagraph();
text = paragraph.AppendText("Text to describe historical ligatures");
text.CharacterFormat.Ligatures = LigatureType.Historical;
text.CharacterFormat.FontName = "Arial";
//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()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new text
Dim text As IWTextRange = paragraph.AppendText("Text to describe discretional ligatures")
'Set ligature type as Discretional
text.CharacterFormat.Ligatures = LigatureType.Discretional
text.CharacterFormat.FontName = "Arial"
paragraph = section.AddParagraph()
text = paragraph.AppendText("Text to describe contextual ligatures")
'Set ligature type as Contextual
text.CharacterFormat.Ligatures = LigatureType.Contextual
text.CharacterFormat.FontName = "Arial"
paragraph = section.AddParagraph()
text = paragraph.AppendText("Text to describe historical ligatures")
'Set ligature type as Historical
text.CharacterFormat.Ligatures = LigatureType.Historical
text.CharacterFormat.FontName = "Arial"
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new text
IWTextRange text = paragraph.AppendText("Numbers to describe oldstyle number form 0123456789");
text.CharacterFormat.FontName = "Calibri";
//Set number style
text.CharacterFormat.NumberForm = NumberFormType.OldStyle;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Numbers to describe lining number form 0123456789");
text.CharacterFormat.FontName = "Calibri";
//Set number style
text.CharacterFormat.NumberForm = NumberFormType.Lining;
//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()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new text
Dim text As IWTextRange = paragraph.AppendText("Numbers to describe oldstyle number form 0123456789")
text.CharacterFormat.FontName = "Calibri"
'Set number style
text.CharacterFormat.NumberForm = NumberFormType.OldStyle
paragraph = section.AddParagraph()
text = paragraph.AppendText("Numbers to describe lining number form 0123456789")
text.CharacterFormat.FontName = "Calibri"
'Set number style
text.CharacterFormat.NumberForm = NumberFormType.Lining
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new text
IWTextRange text = paragraph.AppendText("Numbers to describe tabular number spacing 0123456789");
text.CharacterFormat.FontName = "Calibri";
//Set number spacing
text.CharacterFormat.NumberSpacing = NumberSpacingType.Tabular;
paragraph = section.AddParagraph();
text = paragraph.AppendText("Numbers to describe proportional number spacing 0123456789");
text.CharacterFormat.FontName = "Calibri";
//Set number spacing
text.CharacterFormat.NumberSpacing = NumberSpacingType.Proportional;
//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()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new text
Dim text As IWTextRange = paragraph.AppendText("Numbers to describe tabular number spacing 0123456789")
text.CharacterFormat.FontName = "Calibri"
'Set number spacing
text.CharacterFormat.NumberSpacing = NumberSpacingType.Tabular
paragraph = section.AddParagraph()
text = paragraph.AppendText("Numbers to describe proportional number spacing 0123456789")
text.CharacterFormat.FontName = "Calibri"
'Set number spacing
text.CharacterFormat.NumberSpacing = NumberSpacingType.Proportional
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new text
IWTextRange text = paragraph.AppendText("Text to describe stylistic sets");
text.CharacterFormat.FontName = "Gabriola";
//Set stylistic set
text.CharacterFormat.StylisticSet = StylisticSetType.StylisticSet06;
paragraph = section.AddParagraph();
//Add new text
text = paragraph.AppendText("Text to describe stylistic sets");
text.CharacterFormat.FontName = "Gabriola";
//Set stylistic set
text.CharacterFormat.StylisticSet = StylisticSetType.StylisticSet15;
//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()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new text
Dim text As IWTextRange = paragraph.AppendText("Text to describe stylistic sets")
text.CharacterFormat.FontName = "Gabriola"
'Set stylistic set
text.CharacterFormat.StylisticSet = StylisticSetType.StylisticSet06
paragraph = section.AddParagraph()
'Add new text
text = paragraph.AppendText("Text to describe stylistic sets")
text.CharacterFormat.FontName = "Gabriola"
'Set stylistic set
text.CharacterFormat.StylisticSet = StylisticSetType.StylisticSet15
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new text to the paragraph
paragraph.AppendText("Paragraphs are the basic elements of the Word document. It can contain text and images. " +
"Paragraphs are the basic elements of the Word document. It can contain text and images. Paragraphs are the basic elements of the Word document. It can contain text and images.");
//After spacing, back color, borders, contextual spacing
paragraph.ParagraphFormat.AfterSpacing = 18f;
paragraph.ParagraphFormat.BackColor = Color.LightGray;
paragraph.ParagraphFormat.Bidi = true;
paragraph.ParagraphFormat.Borders.BorderType = BorderStyle.Dot;
paragraph.ParagraphFormat.Borders.Color = Color.Maroon;
paragraph.ParagraphFormat.Borders.LineWidth = 0.5f;
paragraph.ParagraphFormat.ContextualSpacing = true;
paragraph = section.AddParagraph();
paragraph.AppendText("Paragraphs are the basic elements of the Word document. It can contain text and images. " +
"Paragraphs are the basic elements of the Word document. It can contain text and images. Paragraphs are the basic elements of the Word document. It can contain text and images.");
//column break, firstline indent, alignment
paragraph.ParagraphFormat.ColumnBreakAfter = true;
paragraph.ParagraphFormat.FirstLineIndent = 12;
paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.JustifyHigh;
paragraph = section.AddParagraph();
paragraph.AppendText("Paragraphs are the basic elements of the Word document. It can contain text and images. " +
"Paragraphs are the basic elements of the Word document. It can contain text and images. Paragraphs are the basic elements of the Word document. It can contain text and images.");
//Hanging indent, keep, left indent, line spacing, keep follow
paragraph.ParagraphFormat.FirstLineIndent = -12;
paragraph.ParagraphFormat.Keep = true;
paragraph.ParagraphFormat.LeftIndent = 10;
paragraph.ParagraphFormat.LineSpacing = 2;
paragraph.ParagraphFormat.LineSpacingRule = LineSpacingRule.AtLeast;
paragraph.ParagraphFormat.KeepFollow = true;
paragraph = section.AddParagraph();
paragraph.AppendText("Paragraphs are the basic elements of the Word document. It can contain text and images. " +
"Paragraphs are the basic elements of the Word document. It can contain text and images. Paragraphs are the basic elements of the Word document. It can contain text and images.");
//Mirror indent, outline level, page break
paragraph.ParagraphFormat.MirrorIndents = true;
paragraph.ParagraphFormat.OutlineLevel = OutlineLevel.Level2;
paragraph.ParagraphFormat.PageBreakAfter = true;
paragraph = section.AddParagraph();
paragraph.AppendText("Paragraphs are the basic elements of the Word document. It can contain text and images. " +
"Paragraphs are the basic elements of the Word document. It can contain text and images. Paragraphs are the basic elements of the Word document. It can contain text and images.");
//Right indent, auto spacing
paragraph.ParagraphFormat.RightIndent = 10;
paragraph.ParagraphFormat.SpaceAfterAuto = true;
paragraph.ParagraphFormat.SpaceBeforeAuto = true;
paragraph = section.AddParagraph();
paragraph.AppendText("Paragraphs are the basic elements of the Word document. It can contain text and images. " +
"Paragraphs are the basic elements of the Word document. It can contain text and images. Paragraphs are the basic elements of the Word document. It can contain text and images.");
//Auto hyphens, window control, before spacing, page break
paragraph.ParagraphFormat.SuppressAutoHyphens = true;
paragraph.ParagraphFormat.WidowControl = true;
paragraph.ParagraphFormat.BeforeSpacing = 18f;
paragraph.ParagraphFormat.PageBreakBefore = true;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new text to the paragraph
paragraph.AppendText("Paragraphs are the basic elements of the Word document. It can contain text and images. " & "Paragraphs are the basic elements of the Word document. It can contain text and images. Paragraphs are the basic elements of the Word document. It can contain text and images.")
'After spacing, back color, borders, contextual spacing
paragraph.ParagraphFormat.AfterSpacing = 18.0F
paragraph.ParagraphFormat.BackColor = Color.LightGray
paragraph.ParagraphFormat.Bidi = True
paragraph.ParagraphFormat.Borders.BorderType = BorderStyle.Dot
paragraph.ParagraphFormat.Borders.Color = Color.Maroon
paragraph.ParagraphFormat.Borders.LineWidth = 0.5F
paragraph.ParagraphFormat.ContextualSpacing = True
paragraph = section.AddParagraph()
paragraph.AppendText("Paragraphs are the basic elements of the Word document. It can contain text and images. " & "Paragraphs are the basic elements of the Word document. It can contain text and images. Paragraphs are the basic elements of the Word document. It can contain text and images.")
'column break, firstline indent, alignment
paragraph.ParagraphFormat.ColumnBreakAfter = True
paragraph.ParagraphFormat.FirstLineIndent = 12
paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.JustifyHigh
paragraph = section.AddParagraph()
paragraph.AppendText("Paragraphs are the basic elements of the Word document. It can contain text and images. " & "Paragraphs are the basic elements of the Word document. It can contain text and images. Paragraphs are the basic elements of the Word document. It can contain text and images.")
'Hanging indent, keep, left indent, line spacing, keep follow
paragraph.ParagraphFormat.FirstLineIndent = -12
paragraph.ParagraphFormat.Keep = True
paragraph.ParagraphFormat.LeftIndent = 10
paragraph.ParagraphFormat.LineSpacing = 2
paragraph.ParagraphFormat.LineSpacingRule = LineSpacingRule.AtLeast
paragraph.ParagraphFormat.KeepFollow = True
paragraph = section.AddParagraph()
paragraph.AppendText("Paragraphs are the basic elements of the Word document. It can contain text and images. " & "Paragraphs are the basic elements of the Word document. It can contain text and images. Paragraphs are the basic elements of the Word document. It can contain text and images.")
'Mirror indent, outline level, page break
paragraph.ParagraphFormat.MirrorIndents = True
paragraph.ParagraphFormat.OutlineLevel = OutlineLevel.Level2
paragraph.ParagraphFormat.PageBreakAfter = True
paragraph = section.AddParagraph()
paragraph.AppendText("Paragraphs are the basic elements of the Word document. It can contain text and images. " & "Paragraphs are the basic elements of the Word document. It can contain text and images. Paragraphs are the basic elements of the Word document. It can contain text and images.")
'Right indent, auto spacing
paragraph.ParagraphFormat.RightIndent = 10
paragraph.ParagraphFormat.SpaceAfterAuto = True
paragraph.ParagraphFormat.SpaceBeforeAuto = True
paragraph = section.AddParagraph()
paragraph.AppendText("Paragraphs are the basic elements of the Word document. It can contain text and images. " & "Paragraphs are the basic elements of the Word document. It can contain text and images. Paragraphs are the basic elements of the Word document. It can contain text and images.")
'Auto hyphens, window control, before spacing, page break
paragraph.ParagraphFormat.SuppressAutoHyphens = True
paragraph.ParagraphFormat.WidowControl = True
paragraph.ParagraphFormat.BeforeSpacing = 18.0F
paragraph.ParagraphFormat.PageBreakBefore = True
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an instance of WordDocument class (Empty Word Document)
WordDocument document = new WordDocument();
//Open an existing Word document into DocIO instance
document.Open("Table.docx", FormatType.Docx);
//Access the instance of the first section in the Word document
WSection section = document.Sections[0];
//Access the instance of the first table in the section
WTable table = section.Tables[0] as WTable;
//Specify the title for the table
table.Title ="PriceDetails";
//Specify the description of the table
table.Description = "This table shows the price details of various fruits";
//Specify the left indent of the table
table.IndentFromLeft = 50;
//Specify the background color of the table
table.TableFormat.BackColor = Color.FromArgb(192, 192, 192);
//Specify the horizontal alignment of the table
table.TableFormat.HorizontalAlignment = RowAlignment.Left;
//Specify the left, right, top and bottom padding of all the cells in the table
table.TableFormat.Paddings.All = 10;
//Specify the auto resize of table to automatically resize all cell width based on its content
table.TableFormat.IsAutoResized = true;
//Specify the table top, bottom, left and right border line width
table.TableFormat.Borders.LineWidth = 2f;
//Specify the table horizontal border line width
table.TableFormat.Borders.Horizontal.LineWidth = 2f;
//Specify the table vertical border line width
table.TableFormat.Borders.Vertical.LineWidth = 2f;
//Specify the tables top, bottom, left and right border color
table.TableFormat.Borders.Color = Color.Red;
//Specify the table Horizontal border color
table.TableFormat.Borders.Horizontal.Color = Color.Red;
//Specify the table vertical border color
table.TableFormat.Borders.Vertical.Color = Color.Red;
//Specify the table borders border type
table.TableFormat.Borders.BorderType = BorderStyle.Double;
//Access the instance of the first row in the table
WTableRow row = table.Rows[0];
//Specify the row height
row.Height = 20;
//Specify the row height type
row.HeightType = TableRowHeightType.AtLeast;
document.Save("TableFormatting.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an instance of WordDocument class (Empty Word Document)
Dim document As New WordDocument()
'Open an existing Word document into DocIO instance
document.Open("Table.docx", FormatType.Docx)
'Access the instance of the first section in the Word document
Dim section As WSection = document.Sections(0)
'Access the instance of the first table in the section
Dim table As WTable = TryCast(section.Tables(0), WTable)
'Specify the title for the table
table.Title = "PriceDetails"
'Specify the description of the table
table.Description = "This table shows the price details of various fruits"
'Specify the left indent of the table
table.IndentFromLeft = 50
'Specify the background color of the table
table.TableFormat.BackColor = Color.FromArgb(192, 192, 192)
'Specify the horizontal alignment of the table
table.TableFormat.HorizontalAlignment = RowAlignment.Left
'Specify the left, right, top and bottom padding of all the cells in the table
table.TableFormat.Paddings.All = 10
'Specify the auto resize of table to automatically resize all cell width based on its content
table.TableFormat.IsAutoResized = True
'Specify the table top, bottom, left and right border line width
table.TableFormat.Borders.LineWidth = 2.0F
'Specify the table horizontal border line width
table.TableFormat.Borders.Horizontal.LineWidth = 2.0F
'Specify the table vertical border line width
table.TableFormat.Borders.Vertical.LineWidth = 2.0F
'Specify the tables top, bottom, left and right border color
table.TableFormat.Borders.Color = Color.Red
'Specify the table Horizontal border color
table.TableFormat.Borders.Horizontal.Color = Color.Red
'Specify the table vertical border color
table.TableFormat.Borders.Vertical.Color = Color.Red
'Specify the table borders border type
table.TableFormat.Borders.BorderType = BorderStyle.[Double]
'Access the instance of the first row in the table
Dim row As WTableRow = table.Rows(0)
'Specify the row height
row.Height = 20
'Specify the row height type
row.HeightType = TableRowHeightType.AtLeast
document.Save("TableFormatting.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument("Template.docx");
WSection section = document.Sections[0];
WTable table = section.Tables[0] as WTable;
//Disable breaking across pages for all rows in the table.
foreach (WTableRow row in table.Rows)
row.RowFormat.IsBreakAcrossPages = false;
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument("Template.docx")
Dim section As WSection = document.Sections(0)
Dim table As WTable = TryCast(section.Tables(0), WTable)
'Disable breaking across pages for all rows in the table.
For Each row As WTableRow In table.Rows
row.RowFormat.IsBreakAcrossPages = False
Next
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an instance of WordDocument class (Empty Word Document)
WordDocument document = new WordDocument();
//Open an existing Word document into DocIO instance
document.Open("Table.docx", FormatType.Docx);
//Access the instance of the first section in the Word document
WSection section = document.Sections[0];
//Access the instance of the first table in the section
WTable table = section.Tables[0] as WTable;
//Specify the table positioning options
table.TableFormat.Positioning.HorizPositionAbs = HorizontalPosition.Right;
table.TableFormat.Positioning.HorizRelationTo = HorizontalRelation.Margin;
table.TableFormat.Positioning.VertPositionAbs = VerticalPosition.Center;
table.TableFormat.Positioning.VertRelationTo = VerticalRelation.Page;
table.TableFormat.Positioning.DistanceFromBottom = 10;
table.TableFormat.Positioning.DistanceFromLeft = 10;
table.TableFormat.Positioning.DistanceFromRight = 10;
table.TableFormat.Positioning.DistanceFromTop = 10;
//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 an instance of WordDocument class (Empty Word Document)
Dim document As New WordDocument()
'Open an existing Word document into DocIO instance
document.Open("Table.docx", FormatType.Docx)
'Access the instance of the first section in the Word document
Dim section As WSection = document.Sections(0)
'Access the instance of the first table in the section
Dim table As WTable = TryCast(section.Tables(0), WTable)
'Specify the table positioning options
table.TableFormat.Positioning.HorizPositionAbs = HorizontalPosition.Right
table.TableFormat.Positioning.HorizRelationTo = HorizontalRelation.Margin
table.TableFormat.Positioning.VertPositionAbs = VerticalPosition.Center
table.TableFormat.Positioning.VertRelationTo = VerticalRelation.Page
table.TableFormat.Positioning.DistanceFromBottom = 10
table.TableFormat.Positioning.DistanceFromLeft = 10
table.TableFormat.Positioning.DistanceFromRight = 10
table.TableFormat.Positioning.DistanceFromTop = 10
'Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Append new textbox to the paragraph
IWTextBox textbox = paragraph.AppendTextBox(150, 75);
//Add new text to the textbox body
IWParagraph textboxParagraph = textbox.TextBoxBody.AddParagraph();
textboxParagraph.AppendText("Text inside text box");
//Set fill color, line width, line dashing and line style for textbox
textbox.TextBoxFormat.FillColor = Color.LightGreen;
textbox.TextBoxFormat.LineWidth = 2;
textbox.TextBoxFormat.LineDashing = LineDashing.Dash;
textbox.TextBoxFormat.LineStyle = TextBoxLineStyle.Double;
//Apply textbox text direction
textbox.TextBoxFormat.TextDirection = Syncfusion.DocIO.DLS.TextDirection.VerticalTopToBottom;
//Set text wrapping style and type
textbox.TextBoxFormat.TextWrappingStyle = TextWrappingStyle.InFrontOfText;
textbox.TextBoxFormat.TextWrappingType = TextWrappingType.Right;
//Set horizontal and vertical position
textbox.TextBoxFormat.HorizontalPosition = 200;
textbox.TextBoxFormat.VerticalPosition = 200;
//Set horizontal and vertical origin
textbox.TextBoxFormat.VerticalOrigin = VerticalOrigin.Margin;
textbox.TextBoxFormat.HorizontalOrigin = HorizontalOrigin.Page;
//Set top and bottom margin values
textbox.TextBoxFormat.InternalMargin.Bottom = 5f;
textbox.TextBoxFormat.InternalMargin.Top = 5f;
//Set horizontal and vertical alignment
textbox.TextBoxFormat.VerticalAlignment = ShapeVerticalAlignment.Bottom;
textbox.TextBoxFormat.HorizontalAlignment = ShapeHorizontalAlignment.Center;
//Save and close the Word 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()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Append new textbox to the paragraph
Dim textbox As IWTextBox = paragraph.AppendTextBox(150, 75)
'Add new text to the textbox body
Dim textboxParagraph As IWParagraph = textbox.TextBoxBody.AddParagraph()
textboxParagraph.AppendText("Text inside text box")
'Set fill color, line width, line dashing and line style for textbox
textbox.TextBoxFormat.FillColor = Color.LightGreen
textbox.TextBoxFormat.LineWidth = 2
textbox.TextBoxFormat.LineDashing = LineDashing.Dash
textbox.TextBoxFormat.LineStyle = TextBoxLineStyle.[Double]
'Apply textbox text direction
textbox.TextBoxFormat.TextDirection = Syncfusion.DocIO.DLS.TextDirection.VerticalTopToBottom
'Set text wrapping style and type
textbox.TextBoxFormat.TextWrappingStyle = TextWrappingStyle.InFrontOfText
textbox.TextBoxFormat.TextWrappingType = TextWrappingType.Right
'Set horizontal and vertical position
textbox.TextBoxFormat.HorizontalPosition = 200
textbox.TextBoxFormat.VerticalPosition = 200
'Set horizontal and vertical origin
textbox.TextBoxFormat.VerticalOrigin = VerticalOrigin.Margin
textbox.TextBoxFormat.HorizontalOrigin = HorizontalOrigin.Page
'Set top and bottom margin values
textbox.TextBoxFormat.InternalMargin.Bottom = 5.0F
textbox.TextBoxFormat.InternalMargin.Top = 5.0F
'Set horizontal and vertical alignment
textbox.TextBoxFormat.VerticalAlignment = ShapeVerticalAlignment.Bottom
textbox.TextBoxFormat.HorizontalAlignment = ShapeHorizontalAlignment.Center
'Save and close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
//Creates a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Appends new textbox to the paragraph
IWTextBox textbox = paragraph.AppendTextBox(150, 50);
//Adds new text to the textbox body
IWParagraph textboxParagraph = textbox.TextBoxBody.AddParagraph();
textboxParagraph.AppendText("Text inside text box");
//Sets vertical alignment of the text
textbox.TextBoxFormat.TextVerticalAlignment = VerticalAlignment.Bottom;
//Save and close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Creates a new Word document
Dim document As New WordDocument()
'Adds new section to the document
Dim section As IWSection = document.AddSection()
'Adds new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Appends new textbox to the paragraph
Dim textbox As IWTextBox = paragraph.AppendTextBox(150, 50)
'Adds new text to the textbox body
Dim textboxParagraph As IWParagraph = textbox.TextBoxBody.AddParagraph()
textboxParagraph.AppendText("Text inside text box")
'Sets vertical alignment of the text
textbox.TextBoxFormat.TextVerticalAlignment = VerticalAlignment.Bottom
'Save and close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Creates a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Appends new textbox to the paragraph
IWTextBox textbox = paragraph.AppendTextBox(150, 75);
//Adds new text to the textbox body
IWParagraph textboxParagraph = textbox.TextBoxBody.AddParagraph();
textboxParagraph.AppendText("Text inside text box");
//Sets textbox rotation in degree
textbox.TextBoxFormat.Rotation = 90;
//Saves and closes the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Creates a new Word document
Dim document As WordDocument = New WordDocument
'Adds new section to the document
Dim section As IWSection = document.AddSection
'Adds new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph
'Appends new textbox to the paragraph
Dim textbox As IWTextBox = paragraph.AppendTextBox(150, 75)
'Adds new text to the textbox body
Dim textboxParagraph As IWParagraph = textbox.TextBoxBody.AddParagraph
textboxParagraph.AppendText("Text inside text box")
'Sets textbox rotation in degree
textbox.TextBoxFormat.Rotation = 90
'Saves and closes the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Creates a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Appends new textbox to the paragraph
IWTextBox textbox = paragraph.AppendTextBox(150, 75);
//Adds new text to the textbox body
IWParagraph textboxParagraph = textbox.TextBoxBody.AddParagraph();
textboxParagraph.AppendText("Text inside text box");
//Sets horizontal flip to the textbox
textbox.TextBoxFormat.FlipHorizontal = true;
//Saves and closes the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Creates a new Word document
Dim document As WordDocument = New WordDocument
'Adds new section to the document
Dim section As IWSection = document.AddSection
'Adds new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph
'Appends new textbox to the paragraph
Dim textbox As IWTextBox = paragraph.AppendTextBox(150, 75)
'Adds new text to the textbox body
Dim textboxParagraph As IWParagraph = textbox.TextBoxBody.AddParagraph
textboxParagraph.AppendText("Text inside text box")
'Sets horizontal flip to the textbox
textbox.TextBoxFormat.FlipHorizontal = True
'Saves and closes the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Creates a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Appends new textbox to the paragraph
IWTextBox textbox = paragraph.AppendTextBox(150, 75);
//Adds new text to the textbox body
IWParagraph textboxParagraph = textbox.TextBoxBody.AddParagraph();
textboxParagraph.AppendText("Text inside text box");
//Sets vertical flip to the textbox
textbox.TextBoxFormat.FlipVertical = true;
//Saves and closes the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Creates a new Word document
Dim document As WordDocument = New WordDocument
'Adds new section to the document
Dim section As IWSection = document.AddSection
'Adds new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph
'Appends new textbox to the paragraph
Dim textbox As IWTextBox = paragraph.AppendTextBox(150, 75)
'Adds new text to the textbox body
Dim textboxParagraph As IWParagraph = textbox.TextBoxBody.AddParagraph
textboxParagraph.AppendText("Text inside text box")
'Sets vertical flip to the textbox
textbox.TextBoxFormat.FlipVertical = True
'Saves and closes the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Creates a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Appends new textbox to the paragraph
IWTextBox textbox = paragraph.AppendTextBox(150, 50);
//Adds new text to the textbox body
IWParagraph textboxParagraph = textbox.TextBoxBody.AddParagraph();
textboxParagraph.AppendText("Text inside text box text inside text box text inside text box.");
//Resize the textbox based on its contents
textbox.TextBoxFormat.AutoFit = true;
//Save and close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Creates a new Word document
Dim document As New WordDocument()
'Adds new section to the document
Dim section As IWSection = document.AddSection()
'Adds new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Appends new textbox to the paragraph
Dim textbox As IWTextBox = paragraph.AppendTextBox(150, 50)
'Adds new text to the textbox body
Dim textboxParagraph As IWParagraph = textbox.TextBoxBody.AddParagraph()
textboxParagraph.AppendText("Text inside text box text inside text box text inside text box.")
'Resize the textbox based on its contents
textbox.TextBoxFormat.AutoFit = True
'Save and close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Creates a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Appends new textbox to the paragraph
IWTextBox textbox = paragraph.AppendTextBox(150, 50);
//Adds new text to the textbox body
IWParagraph textboxParagraph = textbox.TextBoxBody.AddParagraph();
textboxParagraph.AppendText("Text inside text box text inside text box text inside text box.");
//Allow the textbox to overlap other textboxes
textbox.TextBoxFormat.AllowOverlap = true;
//Save and close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Creates a new Word document
Dim document As New WordDocument()
'Adds new section to the document
Dim section As IWSection = document.AddSection()
'Adds new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Appends new textbox to the paragraph
Dim textbox As IWTextBox = paragraph.AppendTextBox(150, 50)
'Adds new text to the textbox body
Dim textboxParagraph As IWParagraph = textbox.TextBoxBody.AddParagraph()
textboxParagraph.AppendText("Text inside text box text inside text box text inside text box.")
'Allow the textbox to overlap other textboxes
textbox.TextBoxFormat.AllowOverlap = True
'Save and close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
IBlockContentControl control = section.Body.AddBlockContentControl(ContentControlType.RichText);
//Adds new paragraph to the section.
WParagraph paragraph = new WParagraph(control.Document);
//Adds new text to the content control.
paragraph.AppendText("Block content control");
//Adds pagagraph into the Block content control.
control.TextBody.ChildEntities.Add(paragraph);
//Sets title of the block content control.
control.ContentControlProperties.Title = "Rich text content control";
//Adds content control into the document.
document.LastSection.Body.ChildEntities.Add(control);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
Dim document As New WordDocument()
'Adds new section to the document
Dim section As IWSection = document.AddSection()
Dim control As New BlockContentControl(document, ContentControlType.RichText)
'Adds new paragraph to the section.
Dim paragraph As New WParagraph(control.Document)
'Adds new text to the content control.
paragraph.AppendText("Block content control")
'Adds pagagraph into the Block content control.
control.TextBody.ChildEntities.Add(paragraph)
'Sets title of the block content control.
control.ContentControlProperties.Title = "Rich text content control"
'Adds content control into the document.
document.LastSection.Body.ChildEntities.Add(control)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
IBlockContentControl control = section.Body.AddBlockContentControl(ContentControlType.RichText);
//Adds new paragraph to the section.
WParagraph paragraph = new WParagraph(control.Document);
//Adds new text to the content control.
paragraph.AppendText("Block content control");
//Adds pagagraph into the Block content control.
control.TextBody.ChildEntities.Add(paragraph);
//Adds content control into the document.
document.LastSection.Body.ChildEntities.Add(control);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
Dim document As New WordDocument()
'Adds new section to the document
Dim section As IWSection = document.AddSection()
Dim control As New BlockContentControl(document, ContentControlType.RichText)
'Adds new paragraph to the section.
Dim paragraph As New WParagraph(control.Document)
'Adds new text to the content control.
paragraph.AppendText("Block content control")
'Adds pagagraph into the Block content control.
control.TextBody.ChildEntities.Add(paragraph)
'Adds content control into the document.
document.LastSection.Body.ChildEntities.Add(control)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Adds new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText);
//Adds new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Rich Text Content Control";
(paragraph.Items.LastItem as IInlineContentControl).ParagraphItems.Add(textRange);
IInlineContentControl richTextControl = paragraph.Items.LastItem as IInlineContentControl;
richTextControl.ParagraphItems.Add(textRange);
// Sets Title property of the content control.
richTextControl.ContentControlProperties.Title = "Rich text content control";
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
Dim document As New WordDocument()
'Adds new section to the document
Dim section As IWSection = document.AddSection()
'Adds new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Adds new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText)
'Adds new text to the content control
Dim textRange As New WTextRange(document)
textRange.Text = "Rich Text Content Control"
TryCast(paragraph.Items.LastItem, IInlineContentControl).ParagraphItems.Add(textRange)
Dim richTextControl As IInlineContentControl = TryCast(paragraph.Items.LastItem, IInlineContentControl)
richTextControl.ParagraphItems.Add(textRange)
' Sets Title property of the content control.
richTextControl.ContentControlProperties.Title = "Rich text content control"
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Adds new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText);
//Adds new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Rich Text Content Control";
(paragraph.Items.LastItem as IInlineContentControl).ParagraphItems.Add(textRange);
IInlineContentControl richTextControl = paragraph.Items.LastItem as IInlineContentControl;
richTextControl.ParagraphItems.Add(textRange);
// Sets Title property of the content control.
richTextControl.ContentControlProperties.Title = "Rich text content control";
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
Dim document As New WordDocument()
'Adds new section to the document
Dim section As IWSection = document.AddSection()
'Adds new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Adds new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText)
'Adds new text to the content control
Dim textRange As New WTextRange(document)
textRange.Text = "Rich Text Content Control"
TryCast(paragraph.Items.LastItem, IInlineContentControl).ParagraphItems.Add(textRange)
Dim richTextControl As IInlineContentControl = TryCast(paragraph.Items.LastItem, IInlineContentControl)
richTextControl.ParagraphItems.Add(textRange)
' Sets Title property of the content control.
richTextControl.ContentControlProperties.Title = "Rich text content control"
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
document.EnsureMinimal();
//Add new text
IWTextRange text = document.LastParagraph.AppendText("Hello world");
//Initialize character format
WCharacterFormat characterformat = new WCharacterFormat(document);
characterformat.Bold = true;
characterformat.Italic = true;
characterformat.TextColor = Color.Blue;
//Apply character format
text.ApplyCharacterFormat(characterformat);
//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()
document.EnsureMinimal()
'Add new text
Dim text As IWTextRange = document.LastParagraph.AppendText("Hello world")
'Initialize character format
Dim characterformat As New WCharacterFormat(document)
characterformat.Bold = True
characterformat.Italic = True
characterformat.TextColor = Color.Blue
'Apply character format
text.ApplyCharacterFormat(characterformat)
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Initialize new picture
WPicture picture = new WPicture(document);
//Load image from the file
picture.LoadImage(Image.FromFile("Image.png"));
//Set width and height
picture.Height = 100;
picture.Width = 150;
//Add picture to the paragraph
paragraph.Items.Add(picture);
//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()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Initialize new picture
Dim picture As New WPicture(document)
'Load image from the file
picture.LoadImage(Image.FromFile("Image.png"))
'Set width and height
picture.Height = 100
picture.Width = 150
'Add picture to the paragraph
paragraph.Items.Add(picture)
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Get the image and convert to byte array
Image image = Image.FromFile("Image.png");
MemoryStream imageStream = new MemoryStream();
image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
byte[] imageBytes = imageStream.ToArray();
//Initialize new picture
WPicture picture = new WPicture(document);
//Load image from the byte array
picture.LoadImage(imageBytes);
//Set width and height
picture.Height = 100;
picture.Width = 150;
//Add picture to the paragraph
paragraph.Items.Add(picture);
//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()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Get the image and convert to byte array
Dim image__1 As Image = Image.FromFile("Image.png")
Dim imageStream As New MemoryStream()
image__1.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png)
Dim imageBytes As Byte() = imageStream.ToArray()
'Initialize new picture
Dim picture As New WPicture(document)
'Load image from the byte array
picture.LoadImage(imageBytes)
'Set width and height
picture.Height = 100
picture.Width = 150
'Add picture to the paragraph
paragraph.Items.Add(picture)
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Get the SVG image as byte array.
byte[] imageBytes = File.ReadAllBytes("Image.png");
//Get the SVG image as byte array.
byte[] svgData = File.ReadAllBytes("Image.svg");
//Initialize new picture
WPicture picture = new WPicture(document);
//Load both fallback and SVG image from the byte array
picture.LoadImage(svgData, imageBytes);
//Set width and height
picture.Height = 100;
picture.Width = 150;
//Add picture to the paragraph
paragraph.Items.Add(picture);
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Get the image byte array
Dim imageBytes As Byte() = File.ReadAllBytes("Image.png")
'Get the SVG image as byte array.
Dim svgData As Byte() = File.ReadAllBytes("Image.svg")
'Initialize new picture
Dim picture As New WPicture(document)
'Load both fallback and SVG image from the byte array
picture.LoadImage(svgData, imageBytes)
'Set width and height
picture.Height = 100
picture.Width = 150
'Add picture to the paragraph
paragraph.Items.Add(picture)
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("This paragraph has picture. ");
//Append new picture to the paragraph
IWPicture picture = paragraph.AppendPicture(Image.FromFile("Image.png"));
//Set width and height for the paragraph
picture.Width = 150;
picture.Height = 100;
//Set caption for picture
picture.AddCaption("Figure 1.1", CaptionNumberingFormat.Number, CaptionPosition.AboveImage);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("This paragraph has picture. ")
'Append new picture to the paragraph
Dim picture As IWPicture = paragraph.AppendPicture(Image.FromFile("Image.png"))
'Set width and height for the paragraph
picture.Width = 150
picture.Height = 100
'Set caption for picture
picture.AddCaption("Figure 1.1", CaptionNumberingFormat.Number, CaptionPosition.AboveImage)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
//Creates a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new text to the paragraph
IWParagraph paragraph = section.AddParagraph();
//Gets the image and convert to byte array
Image image = Image.FromFile("Image.png");
MemoryStream imageStream = new MemoryStream();
image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
byte[] imageBytes = imageStream.ToArray();
//Initializes new picture
WPicture picture = new WPicture(document);
//Loads an image from the byte array
picture.LoadImage(imageBytes);
//Sets height and width for the image
picture.Height = 100;
picture.Width = 150;
//Sets horizontal flip to the picture
picture.FlipHorizontal = true;
//Adds image to the paragraph
paragraph.Items.Add(picture);
//Saves the Word document
document.Save("Sample.docx", FormatType.Docx);
//Closes the document
document.Close();
'Creates a New Word document
Dim document As WordDocument = New WordDocument
'Adds new section to the document
Dim section As IWSection = document.AddSection
'Adds new text to the paragraph
Dim paragraph As IWParagraph = section.AddParagraph
'Gets the image and convert to byte array
Dim image As Image = Image.FromFile("Image.png")
Dim imageStream As MemoryStream = New MemoryStream
image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png)
Dim imageBytes() As Byte = imageStream.ToArray
'Initializes new picture
Dim picture As WPicture = New WPicture(document)
'Loads an image from the byte array
picture.LoadImage(imageBytes)
'Sets height and width for the image
picture.Height = 100
picture.Width = 150
'Sets horizontal flip to the picture
picture.FlipHorizontal = True
'Adds image to the paragraph
paragraph.Items.Add(picture)
'Saves the Word document
document.Save("Sample.docx", FormatType.Docx)
'Closes the document
document.Close()
//Creates a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new text to the paragraph
IWParagraph paragraph = section.AddParagraph();
//Gets the image and convert to byte array
Image image = Image.FromFile("Image.png");
MemoryStream imageStream = new MemoryStream();
image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
byte[] imageBytes = imageStream.ToArray();
//Initializes new picture
WPicture picture = new WPicture(document);
//Loads an image from the byte array
picture.LoadImage(imageBytes);
//Sets height and width for the image
picture.Height = 100;
picture.Width = 150;
//Sets vertical flip to the picture
picture.FlipVertical = true;
//Adds image to the paragraph
paragraph.Items.Add(picture);
//Saves the Word document
document.Save("Sample.docx", FormatType.Docx);
//Closes the document
document.Close();
'Creates a New Word document
Dim document As WordDocument = New WordDocument
'Adds new section to the document
Dim section As IWSection = document.AddSection
'Adds new text to the paragraph
Dim paragraph As IWParagraph = section.AddParagraph
'Gets the image and convert to byte array
Dim image As Image = Image.FromFile("Image.png")
Dim imageStream As MemoryStream = New MemoryStream
image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png)
Dim imageBytes() As Byte = imageStream.ToArray
'Initializes new picture
Dim picture As WPicture = New WPicture(document)
'Loads an image from the byte array
picture.LoadImage(imageBytes)
'Sets height and width for the image
picture.Height = 100
picture.Width = 150
'Sets vertical flip to the picture
picture.FlipVertical = True
'Adds image to the paragraph
paragraph.Items.Add(picture)
'Saves the Word document
document.Save("Sample.docx", FormatType.Docx)
'Closes the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Add the section into the Word document
IWSection section = document.AddSection();
string paraText = "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";
//Add the paragraph into the created section
IWParagraph paragraph = section.AddParagraph();
//Append the TOC field with LowerHeadingLevel and UpperHeadingLevel to determines the TOC entries
paragraph.AppendTOC(1, 3);
//Add the section into the Word document
section = document.AddSection();
//Add the paragraph into the created section
paragraph = section.AddParagraph();
//Add the text for the headings
paragraph.AppendText("First Chapter");
//Set a build in heading style.
paragraph.ApplyStyle(BuiltinStyle.Heading1);
//Add the text into the paragraph
section.AddParagraph().AppendText(paraText);
//Add the section into the Word document
section = document.AddSection();
//Add the paragraph into the created section
paragraph = section.AddParagraph();
//Add the text for the headings
paragraph.AppendText("Second Chapter");
//Set a build in heading style.
paragraph.ApplyStyle(BuiltinStyle.Heading2);
//Add the text into the paragraph
section.AddParagraph().AppendText(paraText);
//Add the section into the Word document
section = document.AddSection();
//Add the paragraph into the created section
paragraph = section.AddParagraph();
//Add the text into the headings
paragraph.AppendText("Third Chapter");
//Set a build in heading style
paragraph.ApplyStyle(BuiltinStyle.Heading3);
//Add the text into the paragraph.
section.AddParagraph().AppendText(paraText);
//Update the table of contents
document.UpdateTableOfContents();
//Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add the section into the Word document
Dim section As IWSection = document.AddSection()
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"
'Add the paragraph into the created section
Dim paragraph As IWParagraph = section.AddParagraph()
'Append the TOC field with LowerHeadingLevel and UpperHeadingLevel to determines the TOC entries
paragraph.AppendTOC(1, 3)
'Add the section into the Word document
section = document.AddSection()
'Add the paragraph into the created section
paragraph = section.AddParagraph()
'Add the text for the headings
paragraph.AppendText("First Chapter")
'Set a build in heading style
paragraph.ApplyStyle(BuiltinStyle.Heading1)
'Add the text into the paragraph.
section.AddParagraph().AppendText(paraText)
'Add the section into the Word document
section = document.AddSection()
'Add the paragraph into the created section
paragraph = section.AddParagraph()
'Add the text for the headings
paragraph.AppendText("Second Chapter")
'Set a build in heading style
paragraph.ApplyStyle(BuiltinStyle.Heading2)
'Add the text into the paragraph
section.AddParagraph().AppendText(paraText)
'Add the section into the Word document
section = document.AddSection()
'Add the paragraph into the created section
paragraph = section.AddParagraph()
'Add the text into the headings
paragraph.AppendText("Third Chapter")
'Set a build in heading style
paragraph.ApplyStyle(BuiltinStyle.Heading3)
'Add the text into the paragraph
section.AddParagraph().AppendText(paraText)
'Update the table of contents
document.UpdateTableOfContents()
'Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Create a new custom styles
Style style = (WParagraphStyle)document.AddParagraphStyle("Mystyle");
style.CharacterFormat.Bold = true;
style.CharacterFormat.FontName = "Verdana";
style.CharacterFormat.FontSize = 25;
//Add the section into the Word document
IWSection section = document.AddSection();
string paraText = "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";
//Add the paragraph into the created section
IWParagraph paragraph = section.AddParagraph();
//Append the TOC field with LowerHeadingLevel and UpperHeadingLevel to determines the TOC entries
TableOfContent toc = paragraph.AppendTOC(1, 3);
toc.UseHeadingStyles = false;
//Set the TOC level style based on which the TOC should be created
toc.SetTOCLevelStyle(2, "Mystyle");
//Add the section into the Word document
section = document.AddSection();
//Add the paragraph into the created section
paragraph = section.AddParagraph();
//Add the text for the headings
paragraph.AppendText("First Chapter");
//Set the build in heading style
paragraph.ApplyStyle("Mystyle");
//Add the text into the paragraph
section.AddParagraph().AppendText(paraText);
//Add the section into the Word document
section = document.AddSection();
//Add the paragraph into the created section
paragraph = section.AddParagraph();
//Add the text for the headings
paragraph.AppendText("Second Chapter");
//Set the build in heading style
paragraph.ApplyStyle(BuiltinStyle.Heading1);
//Add the text to the paragraph
section.AddParagraph().AppendText(paraText);
//Add the section into Word document
section = document.AddSection();
//Add a paragraph to created section
paragraph = section.AddParagraph();
//Add the text for the headings
paragraph.AppendText("Third Chapter");
//Set the build in heading style
paragraph.ApplyStyle("Mystyle");
//Add the text to the paragraph
section.AddParagraph().AppendText(paraText);
//Update the table of contents
document.UpdateTableOfContents();
//Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Create a new custom styles
Dim style As Style = DirectCast(document.AddParagraphStyle("Mystyle"), WParagraphStyle)
style.CharacterFormat.Bold = True
style.CharacterFormat.FontName = "Verdana"
style.CharacterFormat.FontSize = 25
'Add the section into the Word document
Dim section As IWSection = document.AddSection()
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"
'Add the paragraph into the created section
Dim paragraph As IWParagraph = section.AddParagraph()
'Append the TOC field with LowerHeadingLevel and UpperHeadingLevel to determine the TOC entries
Dim toc As TableOfContent = paragraph.AppendTOC(1, 3)
toc.UseHeadingStyles = False
'Set the TOC level style based on which the TOC should be created
toc.SetTOCLevelStyle(2, "Mystyle")
'Add the section into the Word document
section = document.AddSection()
'Add the paragraph into the created section
paragraph = section.AddParagraph()
'Add the text for the headings
paragraph.AppendText("First Chapter")
'Set the build in heading style
paragraph.ApplyStyle("Mystyle")
'Add the text into the paragraph
section.AddParagraph().AppendText(paraText)
'Add the section into the Word document
section = document.AddSection()
'Add the paragraph into the created section
paragraph = section.AddParagraph()
'Add the text for the headings
paragraph.AppendText("Second Chapter")
'Set the build in heading style
paragraph.ApplyStyle(BuiltinStyle.Heading1)
'Add the text to the paragraph
section.AddParagraph().AppendText(paraText)
'Add the section into Word document
section = document.AddSection()
'Add a paragraph to created section
paragraph = section.AddParagraph()
'Add the text for the headings
paragraph.AppendText("Third Chapter")
'Set the build in heading style
paragraph.ApplyStyle("Mystyle")
'Add the text to the paragraph
section.AddParagraph().AppendText(paraText)
'Update the table of contents
document.UpdateTableOfContents()
'Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Load a Word document
WordDocument document = new WordDocument("Template.docx");
WTextBody textBody = document.Sections[0].Body;
WParagraph paragraph = textBody.Paragraphs[0];
//Get the TOC item from the paragraph
TableOfContent toc = paragraph.ChildEntities[0] as TableOfContent;
//Gets the style name for the specified level
string styleName = toc.GetTOCLevelStyle(1);
WParagraphStyle style = document.Styles.FindByName(styleName) as WParagraphStyle;
//Modify the character format of the style
style.CharacterFormat.HighlightColor = Color.LightGray;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Load a Word document
Dim document As New WordDocument("Template.docx")
Dim textBody As WTextBody = document.Sections(0).Body
Dim paragraph As WParagraph = textBody.Paragraphs(0)
'Get the TOC item from the paragraph
Dim toc As TableOfContent = TryCast(paragraph.ChildEntities(0), TableOfContent)
'Gets the style name for the specified level
Dim styleName As String = toc.GetTOCLevelStyle(1)
Dim style As WParagraphStyle = TryCast(document.Styles.FindByName(styleName), WParagraphStyle)
'Modify the character format of the style
style.CharacterFormat.HighlightColor = Color.LightGray
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document.
using (WordDocument document = new WordDocument())
{
//Add a new section to the document.
IWSection section = document.AddSection();
//Add a paragraph to the section.
IWParagraph paragraph = section.AddParagraph();
//Append the TOC field with LowerHeadingLevel and UpperHeadingLevel to determine the TOC entries.
TableOfContent tableOfContent = paragraph.AppendTOC(1, 3);
//Set the name of SEQ field identifier for table of figures.
tableOfContent.TableOfFiguresLabel = "Figure";
//Add a paragraph to the section.
paragraph = section.AddParagraph();
//Add image to the paragraph.
FileStream imageStream = new FileStream(@"Image.png", FileMode.Open, FileAccess.ReadWrite);
IWPicture picture = paragraph.AppendPicture(imageStream);
//Add Image caption.
IWParagraph paragraph1 = picture.AddCaption("Figure", CaptionNumberingFormat.Number, CaptionPosition.AfterImage);
//Add text to the paragraph.
paragraph1.AppendText(" Icon.");
//Update the fields in Word document.
document.UpdateDocumentFields();
//Update the table of contents.
document.UpdateTableOfContents();
//Saves the Word document to MemoryStream.
MemoryStream stream = new MemoryStream();
document.Save(stream, FormatType.Docx);
}
'Create a new Word document.
Dim document As WordDocument = New WordDocument()
'Add a new section to the document.
Dim section As IWSection = document.AddSection()
'Add a paragraph to the section.
Dim paragraph As IWParagraph = section.AddParagraph()
'Append the TOC field with LowerHeadingLevel and UpperHeadingLevel to determine the TOC entries.
Dim tableOfContent As TableOfContent = paragraph.AppendTOC(1, 3)
'Set the name of SEQ field identifier for table of figures.
tableOfContent.TableOfFiguresLabel = "Figure"
'Add a paragraph to the section.
paragraph = section.AddParagraph()
'Add image to the paragraph.
Dim imageStream As FileStream = New FileStream("Image.png", FileMode.Open, FileAccess.ReadWrite)
Dim picture As IWPicture = paragraph.AppendPicture(imageStream)
'Add Image caption.
Dim paragraph1 As IWParagraph = picture.AddCaption("Figure", CaptionNumberingFormat.Number, CaptionPosition.AfterImage)
'Add text to the paragraph.
paragraph1.AppendText(" Icon.")
'Update the fields in Word document.
document.UpdateDocumentFields()
'Update the table of contents.
document.UpdateTableOfContents()
'Save the document.
document.Save("Result.docx")
document.Close()
//Create a new Word document.
using (WordDocument document = new WordDocument())
{
//Add a new section to the document.
IWSection section = document.AddSection();
//Add a paragraph to the section.
IWParagraph paragraph = section.AddParagraph();
//Append the TOC field with LowerHeadingLevel and UpperHeadingLevel to determine the TOC entries.
TableOfContent tableOfContent = paragraph.AppendTOC(1, 3);
//Set the name of SEQ field identifier for table of figures.
tableOfContent.TableOfFiguresLabel = "Figure";
//Disable the flag, to exclude caption's label and number in TOC entries.
tableOfContent.IncludeCaptionLabelsAndNumbers = false;
//Add a paragraph to the section.
paragraph = section.AddParagraph();
//Add image to the paragraph.
FileStream imageStream = new FileStream(@"Image.png", FileMode.Open, FileAccess.ReadWrite);
IWPicture picture = paragraph.AppendPicture(imageStream);
//Add Image caption.
IWParagraph paragraph1 = picture.AddCaption("Figure", CaptionNumberingFormat.Number, CaptionPosition.AfterImage);
//Add text to the paragraph.
paragraph1.AppendText(" Icon.");
//Update the fields in Word document.
document.UpdateDocumentFields();
//Update the table of contents.
document.UpdateTableOfContents();
//Saves the Word document to MemoryStream.
MemoryStream stream = new MemoryStream();
document.Save(stream, FormatType.Docx);
}
'Create a new Word document.
Dim document As WordDocument = New WordDocument()
'Add a new section to the document.
Dim section As IWSection = document.AddSection()
'Add a paragraph to the section.
Dim paragraph As IWParagraph = section.AddParagraph()
'Append the TOC field with LowerHeadingLevel and UpperHeadingLevel to determine the TOC entries.
Dim tableOfContent As TableOfContent = paragraph.AppendTOC(1, 3)
'Set the name of SEQ field identifier for table of figures.
tableOfContent.TableOfFiguresLabel = "Figure"
'Disable the flag, to exclude caption's label and number in TOC entries.
tableOfContent.IncludeCaptionLabelsAndNumbers = False
'Add a paragraph to the section.
paragraph = section.AddParagraph()
'Add image to the paragraph.
Dim imageStream As FileStream = New FileStream("Image.png", FileMode.Open, FileAccess.ReadWrite)
Dim picture As IWPicture = paragraph.AppendPicture(imageStream)
'Add Image caption.
Dim paragraph1 As IWParagraph = picture.AddCaption("Figure", CaptionNumberingFormat.Number, CaptionPosition.AfterImage)
'Add text to the paragraph.
paragraph1.AppendText(" Icon.")
'Update the fields in Word document.
document.UpdateDocumentFields()
'Update the table of contents.
document.UpdateTableOfContents()
'Save the document.
document.Save("Result.docx")
document.Close()
//Create a Word document.
WordDocument document = new WordDocument();
//Adds the section into the Word document.
IWSection section = document.AddSection();
//Adds the paragraph into the created section.
IWParagraph tocParagraph = section.AddParagraph();
//Append the TOC field with LowerHeadingLevel and UpperHeadingLevel to determine the TOC entries.
TableOfContent tableOfContent = tocParagraph.AppendTOC(1, 3);
//Enables the property IncludeNewLineCharacters to preserve newline characters in the TableOfContent.
tableOfContent.IncludeNewLineCharacters = true;
//Adds the paragraph into the section.
WParagraph paragraph = section.AddParagraph() as WParagraph;
//Adds the text and breaks the headings.
paragraph.AppendText("First ");
paragraph.AppendBreak(BreakType.LineBreak);
paragraph.AppendText("Chapter");
//Sets a built-in heading style.
paragraph.ApplyStyle(BuiltinStyle.Heading1);
//Adds the text into the new paragraph of the section.
section.AddParagraph().AppendText("AdventureWorks Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company.");
//Updated the table of content.
document.UpdateTableOfContents();
//Saves the document.
document.Save("Result.docx");
document.Close();
'Create a Word document.
Dim document As WordDocument = New WordDocument()
'Add the section into the Word document.
Dim section As IWSection = document.AddSection()
'Add the paragraph into the created section.
Dim tocParagraph As IWParagraph = section.AddParagraph()
'Append the TOC field with LowerHeadingLevel and UpperHeadingLevel to determine the TOC entries.
Dim tableOfContent As TableOfContent = tocParagraph.AppendTOC(1, 3)
'Enable the property IncludeNewLineCharacters to preserve newline characters in TableOfContent.
tableOfContent.IncludeNewLineCharacters = True
'Add the paragraph into the section.
Dim paragraph As WParagraph = TryCast(section.AddParagraph(), WParagraph)
'Add the text and break the headings.
paragraph.AppendText("First ")
paragraph.AppendBreak(BreakType.LineBreak)
paragraph.AppendText("Chapter")
'Set a built-in heading style.
paragraph.ApplyStyle(BuiltinStyle.Heading1)
'Add the text into the new paragraph of the section.
section.AddParagraph().AppendText("AdventureWorks Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company.")
'Updated the table of content.
document.UpdateTableOfContents()
'Save the document.
document.Save("Result.docx")
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
WParagraph paragraph = section.AddParagraph() as WParagraph;
paragraph.AppendText("Gender\t");
//Append new Checkbox
WCheckBox checkbox = paragraph.AppendCheckBox();
checkbox.Checked = false;
//Set Checkbox size
checkbox.CheckBoxSize = 10;
checkbox.CalculateOnExit = true;
//Set help text
checkbox.Help = "Help text";
paragraph.AppendText("Male\t");
checkbox = paragraph.AppendCheckBox();
checkbox.Checked = false;
checkbox.CheckBoxSize = 10;
checkbox.CalculateOnExit = true;
paragraph.AppendText("Female");
//Save the Word document
document.Save("Checkbox.docx", FormatType.Docx);
//Close the document
document.Close();
}
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Initialize new text range instance
IWTextRange textrange = new WTextRange(document);
//Add text and its formatting
textrange.Text = "A new text is added";
textrange.CharacterFormat.FontSize = 14;
textrange.CharacterFormat.Bold = true;
textrange.CharacterFormat.TextColor = Color.Green;
//Add text range to the paragraph
paragraph.Items.Add(textrange);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Initialize new text range instance
Dim textrange As IWTextRange = New WTextRange(document)
'Add text and its formatting
textrange.Text = "A new text is added"
text.CharacterFormat.FontSize = 14
text.CharacterFormat.Bold = True
text.CharacterFormat.TextColor = Color.Green
'Add text range to the paragraph
paragraph.Items.Add(textrange)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
document.EnsureMinimal();
//Add new text
IWTextRange text = document.LastParagraph.AppendText("Hello world");
//Initialize character format
WCharacterFormat characterformat = new WCharacterFormat(document);
characterformat.Bold = true;
characterformat.Italic = true;
characterformat.TextColor = Color.Blue;
//Apply character format
text.ApplyCharacterFormat(characterformat);
//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()
document.EnsureMinimal()
'Add new text
Dim text As IWTextRange = document.LastParagraph.AppendText("Hello world")
'Initialize character format
Dim characterformat As New WCharacterFormat(document)
characterformat.Bold = True
characterformat.Italic = True
characterformat.TextColor = Color.Blue
'Apply character format
text.ApplyCharacterFormat(characterformat)
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
//Creates an instance of WordDocument class
WordDocument document = new WordDocument();
//Adds a new section into the Word Document
IWSection section = document.AddSection();
//Adds a new paragraph into Word document and appends text into paragraph
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("Today's Date: ");
//Adds the new Date field in Word document with field name and its type
WField field = paragraph.AppendField("Date", FieldType.FieldDate) as WField;
//Updates the field
field.Update();
//Unlink the field
field.Unlink();
//Saves the document in the given name and format
document.Save("Sample.docx", FormatType.Docx);
//Releases the resources occupied by WordDocument instance
document.Close();
'Creates an instance of WordDocument class
Dim document As WordDocument = New WordDocument()
'Adds a new section into the Word Document
Dim section As IWSection = document.AddSection()
'Adds a new paragraph into Word document and appends text into paragraph
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("Today's Date: ")
'Adds the new Date field in Word document with field name and its type
Dim field As WField = CType(paragraph.AppendField("Date", FieldType.FieldDate), WField)
'Updates the field
field.Update()
'Unlink the field
field.Unlink()
'Saves the document in the given name and format
document.Save("Sample.docx", FormatType.Docx)
'Releases the resources occupied by WordDocument instance
document.Close()
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Input data for chart
Dim data As Object()() = New Object(5)() {}
For i As Integer = 0 To 5
data(i) = New Object(2) {}
Next
data(0)(0) = ""
data(1)(0) = "Gravad lax"
data(2)(0) = "Louisiana Hot spiced Okara"
data(3)(0) = "Mascarpone Fabioli"
data(4)(0) = "Wimmers gute SemmelKnodel"
data(5)(0) = "Maxilaku"
data(0)(1) = "Sum of Purchases"
data(1)(1) = 286
data(2)(1) = 680
data(3)(1) = 288
data(4)(1) = 200
data(5)(1) = 731
data(0)(2) = "Sum of Future Expenses"
data(1)(2) = 1300
data(2)(2) = 700
data(3)(2) = 1280
data(4)(2) = 1200
data(5)(2) = 2660
'Create and Append chart to the paragraph
Dim chart As WChart = paragraph.AppendChart(data, 470, 300)
'Set chart type and title
chart.ChartType = OfficeChartType.Column_Clustered
chart.ChartTitle = "Purchase Details"
chart.ChartTitleArea.FontName = "Calibri"
chart.ChartTitleArea.Size = 14
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None
chart.PrimaryCategoryAxis.Title = "Products"
chart.PrimaryValueAxis.Title = "In Dollars"
'Set position of legend
chart.Legend.Position = OfficeLegendPosition.Bottom
'Save the document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
//Open the template document.
WordDocument document = new WordDocument("Template.docx");
//Get the paragraph.
WParagraph paragraph = document.LastParagraph;
//Get the chart entity.
WChart chart = paragraph.ChildEntities[0] as WChart;
//Replaces the chart data with the worksheet data.
chart.Refresh(true);
//Save and close the document
document.Save("Sample.docx");
document.Close();
'Open the template document.
Dim document As WordDocument = New WordDocument("Template.docx")
'Get the paragraph.
Dim paragraph As WParagraph = document.LastParagraph
'Get the chart entity.
Dim chart As WChart = TryCast(paragraph.ChildEntities(0), WChart)
'Replaces the chart data with the worksheet data..
chart.Refresh(True)
'Save and close the document
document.Save("Sample.docx")
document.Close()
//Loads the template document
WordDocument document = new WordDocument("Template.docx");
//Gets the last paragraph
WParagraph paragraph = document.LastParagraph;
//Gets the chart entity from the paragraph items
WChart chart = paragraph.ChildEntities[0] as WChart;
//Modifies the external data file path of chart
chart.ExternalDataPath = @"Data\Excel_Template.xlsx";
//Saves and closes the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Loads the template document
Dim document As New WordDocument("Template.docx")
'Gets the last paragraph
Dim paragraph As WParagraph = document.LastParagraph
'Gets the chart entity from the paragraph items
Dim chart As WChart = TryCast(paragraph.ChildEntities(0), WChart)
'Modifies the external data file path of chart
chart.ExternalDataPath = "Data\Excel_Template.xlsx"
'Saves and closes the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Get the paragraph
WParagraph paragraph = document.LastParagraph;
//Get the chart entity
WChart chart = paragraph.ChildEntities[1] as WChart;
//Format chart area.
IOfficeChartFrameFormat chartArea = chart.ChartArea;
//Set border line pattern, color, line weight
chartArea.Border.LinePattern = OfficeChartLinePattern.Solid;
chartArea.Border.LineColor = Color.Blue;
chartArea.Border.LineWeight = OfficeChartLineWeight.Hairline;
//Set fill type and fill colors
chartArea.Fill.FillType = OfficeFillType.Gradient;
chartArea.Fill.GradientColorType = OfficeGradientColor.TwoColor;
chartArea.Fill.BackColor = Color.FromArgb(205, 217, 234);
chartArea.Fill.ForeColor = Color.White;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Get the paragraph
Dim paragraph As WParagraph = document.LastParagraph
'Get the chart entity
Dim chart As WChart = TryCast(paragraph.ChildEntities(1), WChart)
'Format chart area.
Dim chartArea As IOfficeChartFrameFormat = chart.ChartArea
'Set border line pattern, color, line weight
chartArea.Border.LinePattern = OfficeChartLinePattern.Solid
chartArea.Border.LineColor = Color.Blue
chartArea.Border.LineWeight = OfficeChartLineWeight.Hairline
'Set fill type and fill colors
chartArea.Fill.FillType = OfficeFillType.Gradient
chartArea.Fill.GradientColorType = OfficeGradientColor.TwoColor
chartArea.Fill.BackColor = Color.FromArgb(205, 217, 234)
chartArea.Fill.ForeColor = Color.White
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
WParagraph paragraph = document.LastParagraph;
//Get the chart entity
WChart chart = paragraph.ChildEntities[0] as WChart;
//Set border settings - line color, pattern, weight, transparency
chart.PlotArea.Border.AutoFormat = false;
chart.PlotArea.Border.IsAutoLineColor = false;
chart.PlotArea.Border.LineColor = Color.Blue;
chart.PlotArea.Border.LinePattern = OfficeChartLinePattern.DashDot;
chart.PlotArea.Border.LineWeight = OfficeChartLineWeight.Wide;
chart.PlotArea.Border.Transparency = 0.6;
//Set the plot area’s fill type, color
chart.PlotArea.Fill.FillType = OfficeFillType.SolidColor;
chart.PlotArea.Fill.ForeColor = Color.LightPink;
//Set the plot area shadow presence
chart.PlotArea.Shadow.ShadowInnerPresets = Office2007ChartPresetsInner.InsideDiagonalTopLeft;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
Dim paragraph As WParagraph = document.LastParagraph
'Get the chart entity
Dim chart As WChart = TryCast(paragraph.ChildEntities(0), WChart)
'Set border settings - line color, pattern, weight, transparency
chart.PlotArea.Border.AutoFormat = False
chart.PlotArea.Border.IsAutoLineColor = False
chart.PlotArea.Border.LineColor = Color.Blue
chart.PlotArea.Border.LinePattern = OfficeChartLinePattern.DashDot
chart.PlotArea.Border.LineWeight = OfficeChartLineWeight.Wide
chart.PlotArea.Border.Transparency = 0.6
'Set the plot area’s fill type, color
chart.PlotArea.Fill.FillType = OfficeFillType.SolidColor
chart.PlotArea.Fill.ForeColor = Color.LightPink
'Set the plot area shadow presence
chart.PlotArea.Shadow.ShadowInnerPresets = Office2007ChartPresetsInner.InsideDiagonalTopLeft
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add section to the document
IWSection sec = document.AddSection();
//Add paragraph to the section
IWParagraph paragraph = sec.AddParagraph();
//Load the excel file as stream
Stream excelStream = File.OpenRead("Excel_Template.xlsx");
//Create and Append chart to the paragraph with excel stream as parameter
WChart chart = paragraph.AppendChart(excelStream, 1, "B2:C6", 470, 300);
//Set chart type and title
chart.ChartType = OfficeChartType.Column_Clustered_3D;
chart.ChartTitle = "Purchase Details";
chart.ChartTitleArea.FontName = "Calibri";
chart.ChartTitleArea.Size = 14;
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None;
//Set name to chart series
chart.Series[0].Name = "Sum of Purchases";
chart.Series[1].Name = "Sum of Future Expenses";
chart.PrimaryCategoryAxis.Title = "Products";
chart.PrimaryValueAxis.Title = "In Dollars";
//Set position of legend
chart.Legend.Position = OfficeLegendPosition.Bottom;
//Set roatation and elevation values
chart.Rotation = 20;
chart.Elevation = 15;
//Set side wall properties
chart.SideWall.Fill.FillType = OfficeFillType.SolidColor;
chart.SideWall.Fill.ForeColor = Color.White;
chart.SideWall.Fill.BackColor = Color.White;
chart.SideWall.Border.LineColor = System.Drawing.Color.Beige;
//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()
'Add section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Load the excel file as stream
Dim excelStream As Stream = File.OpenRead("Excel_Template.xlsx")
'Create and Append chart to the paragraph with excel stream as parameter
Dim chart As WChart = paragraph.AppendChart(excelStream, 1, "B2:C6", 470, 300)
'Set chart type and title
chart.ChartType = OfficeChartType.Column_Clustered_3D
chart.ChartTitle = "Purchase Details"
chart.ChartTitleArea.FontName = "Calibri"
chart.ChartTitleArea.Size = 14
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None
'Set name to chart series
chart.Series(0).Name = "Sum of Purchases"
chart.Series(1).Name = "Sum of Future Expenses"
chart.PrimaryCategoryAxis.Title = "Products"
chart.PrimaryValueAxis.Title = "In Dollars"
'Set position of legend
chart.Legend.Position = OfficeLegendPosition.Bottom
'Set rotation and elevation values
chart.Rotation = 20
chart.Elevation = 15
'Set side wall properties
chart.SideWall.Fill.FillType = OfficeFillType.SolidColor
chart.SideWall.Fill.ForeColor = Color.White
chart.SideWall.Fill.BackColor = Color.White
chart.SideWall.Border.LineColor = System.Drawing.Color.Beige
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add section to the document
IWSection sec = document.AddSection();
//Add paragraph to the section
IWParagraph paragraph = sec.AddParagraph();
//Load the excel file as stream
Stream excelStream = File.OpenRead("Excel_Template.xlsx");
//Create and Append chart to the paragraph with excel stream as parameter
WChart chart = paragraph.AppendChart(excelStream, 1, "B2:C6", 470, 300);
//Set chart type and title
chart.ChartType = OfficeChartType.Column_Clustered_3D;
chart.ChartTitle = "Purchase Details";
chart.ChartTitleArea.FontName = "Calibri";
chart.ChartTitleArea.Size = 14;
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None;
//Set name to chart series
chart.Series[0].Name = "Sum of Purchases";
chart.Series[1].Name = "Sum of Future Expenses";
chart.PrimaryCategoryAxis.Title = "Products";
chart.PrimaryValueAxis.Title = "In Dollars";
//Set position of legend
chart.Legend.Position = OfficeLegendPosition.Bottom;
//Set roatation and elevation values
chart.Rotation = 20;
chart.Elevation = 15;
//Set the Backwall fill option.
chart.BackWall.Fill.FillType = OfficeFillType.Gradient;
//Set the Texture Type.
chart.BackWall.Fill.GradientColorType = OfficeGradientColor.TwoColor;
chart.BackWall.Fill.GradientStyle = OfficeGradientStyle.Diagonl_Down;
chart.BackWall.Fill.ForeColor = Color.WhiteSmoke;
chart.BackWall.Fill.BackColor = Color.LightBlue;
//Set the Border Linecolor.
chart.BackWall.Border.LineColor = System.Drawing.Color.Wheat;
//Set the Picture Type.
chart.BackWall.PictureUnit = OfficeChartPictureType.stretch;
//Set the Backwall thickness.
chart.BackWall.Thickness = 10;
//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()
'Add section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Load the excel file as stream
Dim excelStream As Stream = File.OpenRead("Excel_Template.xlsx")
'Create and Append chart to the paragraph with excel stream as parameter
Dim chart As WChart = paragraph.AppendChart(excelStream, 1, "B2:C6", 470, 300)
'Set chart type and title
chart.ChartType = OfficeChartType.Column_Clustered_3D
chart.ChartTitle = "Purchase Details"
chart.ChartTitleArea.FontName = "Calibri"
chart.ChartTitleArea.Size = 14
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None
'Set name to chart series
chart.Series(0).Name = "Sum of Purchases"
chart.Series(1).Name = "Sum of Future Expenses"
chart.PrimaryCategoryAxis.Title = "Products"
chart.PrimaryValueAxis.Title = "In Dollars"
'Set position of legend
chart.Legend.Position = OfficeLegendPosition.Bottom
'Set rotation and elevation values
chart.Rotation = 20
chart.Elevation = 15
'Set the Backwall fill option.
chart.BackWall.Fill.FillType = OfficeFillType.Gradient
'Set the Texture Type.
chart.BackWall.Fill.GradientColorType = OfficeGradientColor.TwoColor
chart.BackWall.Fill.GradientStyle = OfficeGradientStyle.Diagonl_Down
chart.BackWall.Fill.ForeColor = Color.WhiteSmoke
chart.BackWall.Fill.BackColor = Color.LightBlue
'Set the Border Linecolor.
chart.BackWall.Border.LineColor = System.Drawing.Color.Wheat
'Set the Picture Type.
chart.BackWall.PictureUnit = OfficeChartPictureType.stretch
'Set the Backwall thickness.
chart.BackWall.Thickness = 10
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add section to the document
IWSection sec = document.AddSection();
//Add paragraph to the section
IWParagraph paragraph = sec.AddParagraph();
//Load the excel file as stream
Stream excelStream = File.OpenRead("Excel_Template.xlsx");
//Create and Append chart to the paragraph with excel stream as parameter
WChart chart = paragraph.AppendChart(excelStream, 1, "B2:C6", 470, 300);
//Set chart type and title
chart.ChartType = OfficeChartType.Column_Clustered;
chart.ChartTitle = "Purchase Details";
chart.ChartTitleArea.FontName = "Calibri";
chart.ChartTitleArea.Size = 14;
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None;
//Set name to chart series
chart.Series[0].Name = "Sum of Purchases";
chart.Series[1].Name = "Sum of Future Expenses";
//Display data table
chart.HasDataTable = true;
chart.PrimaryCategoryAxis.Title = "Products";
chart.PrimaryValueAxis.Title = "In Dollars";
//Set position of legend
chart.Legend.Position = OfficeLegendPosition.Bottom;
//Save the document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Load the excel file as stream
Dim excelStream As Stream = File.OpenRead("Excel_Template.xlsx")
'Create and Append chart to the paragraph with excel stream as parameter
Dim chart As WChart = paragraph.AppendChart(excelStream, 1, "B2:C6", 470, 300)
'Set chart type and title
chart.ChartType = OfficeChartType.Column_Clustered
chart.ChartTitle = "Purchase Details"
chart.ChartTitleArea.FontName = "Calibri"
chart.ChartTitleArea.Size = 14
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None
'Set name to chart series
chart.Series(0).Name = "Sum of Purchases"
chart.Series(1).Name = "Sum of Future Expenses"
chart.PrimaryCategoryAxis.Title = "Products"
chart.PrimaryValueAxis.Title = "In Dollars"
'Set position of legend
chart.Legend.Position = OfficeLegendPosition.Bottom
'Display data table
chart.HasDataTable = True
'Save the document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load the template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
WParagraph paragraph = document.LastParagraph;
//Get the chart entity
WChart chart = paragraph.ChildEntities[0] as WChart;
//Set the legend position
chart.Legend.Position = OfficeLegendPosition.Left;
//Set the layout inclusion
chart.Legend.IncludeInLayout = true;
//Set the legend border format - color, pattern, weight
chart.Legend.FrameFormat.Border.AutoFormat = false;
chart.Legend.FrameFormat.Border.IsAutoLineColor = false;
chart.Legend.FrameFormat.Border.LineColor = Color.Blue;
chart.Legend.FrameFormat.Border.LinePattern = OfficeChartLinePattern.DashDot;
chart.Legend.FrameFormat.Border.LineWeight = OfficeChartLineWeight.Wide;
//Set the legend's text area formatting - font name, weight, color, size
chart.Legend.TextArea.Bold = true;
chart.Legend.TextArea.Color = OfficeKnownColors.Bright_green;
chart.Legend.TextArea.FontName = "Times New Roman";
chart.Legend.TextArea.Size = 20;
chart.Legend.TextArea.Strikethrough = true;
//Modify the legend entry
chart.Legend.LegendEntries[0].IsDeleted = true;
//Modify the legend layout - height, left, top, width
chart.Legend.Layout.Height = 50;
chart.Legend.Layout.HeightMode = LayoutModes.factor;
chart.Legend.Layout.Left = 10;
chart.Legend.Layout.LeftMode = LayoutModes.factor;
chart.Legend.Layout.Top = 30;
chart.Legend.Layout.TopMode = LayoutModes.factor;
chart.Legend.Layout.Width = 100;
chart.Legend.Layout.WidthMode = LayoutModes.factor;
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load the template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
Dim paragraph As WParagraph = document.LastParagraph
'Get the chart entity
Dim chart As WChart = TryCast(paragraph.ChildEntities(0), WChart)
'Set the legend position
chart.Legend.Position = OfficeLegendPosition.Left
'Set the layout inclusion
chart.Legend.IncludeInLayout = True
'Set the legend border format - color, pattern, weight
chart.Legend.FrameFormat.Border.AutoFormat = False
chart.Legend.FrameFormat.Border.IsAutoLineColor = False
chart.Legend.FrameFormat.Border.LineColor = Color.Blue
chart.Legend.FrameFormat.Border.LinePattern = OfficeChartLinePattern.DashDot
chart.Legend.FrameFormat.Border.LineWeight = OfficeChartLineWeight.Wide
'Set the legend's text area formatting - font name, weight, color, size
chart.Legend.TextArea.Bold = True
chart.Legend.TextArea.Color = OfficeKnownColors.Bright_green
chart.Legend.TextArea.FontName = "Times New Roman"
chart.Legend.TextArea.Size = 20
chart.Legend.TextArea.Strikethrough = True
'Modify the legend entry
chart.Legend.LegendEntries(0).IsDeleted = True
'Modify the legend layout - height, left, top, width
chart.Legend.Layout.Height = 50
chart.Legend.Layout.HeightMode = LayoutModes.factor
chart.Legend.Layout.Left = 10
chart.Legend.Layout.LeftMode = LayoutModes.factor
chart.Legend.Layout.Top = 30
chart.Legend.Layout.TopMode = LayoutModes.factor
chart.Legend.Layout.Width = 100
chart.Legend.Layout.WidthMode = LayoutModes.factor
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add section to the document
IWSection sec = document.AddSection();
//Add paragraph to the section
IWParagraph paragraph = sec.AddParagraph();
//Load the excel file as stream
Stream excelStream = File.OpenRead("Excel_Template.xlsx");
//Create and Append chart to the paragraph with excel stream as parameter
WChart chart = paragraph.AppendChart(excelStream, 1, "B2:C6", 470, 300);
//Set chart type and title
chart.ChartType = OfficeChartType.Column_Clustered_3D;
chart.ChartTitle = "Purchase Details";
chart.ChartTitleArea.FontName = "Calibri";
chart.ChartTitleArea.Size = 14;
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None;
//Set name to chart series
chart.Series[0].Name = "Sum of Purchases";
chart.Series[1].Name = "Sum of Future Expenses";
chart.PrimaryCategoryAxis.Title = "Products";
chart.PrimaryValueAxis.Title = "In Dollars";
//Set position of legend
chart.Legend.Position = OfficeLegendPosition.Bottom;
//Set roatation and elevation values
chart.Rotation = 20;
chart.Elevation = 15;
//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()
'Add section to the document
Dim sec As IWSection = document.AddSection()
'Add paragraph to the section
Dim paragraph As IWParagraph = sec.AddParagraph()
'Load the excel file as stream
Dim excelStream As Stream = File.OpenRead("Excel_Template.xlsx")
'Create and Append chart to the paragraph with excel stream as parameter
Dim chart As WChart = paragraph.AppendChart(excelStream, 1, "B2:C6", 470, 300)
'Set chart type and title
chart.ChartType = OfficeChartType.Column_Clustered_3D
chart.ChartTitle = "Purchase Details"
chart.ChartTitleArea.FontName = "Calibri"
chart.ChartTitleArea.Size = 14
chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None
'Set name to chart series
chart.Series(0).Name = "Sum of Purchases"
chart.Series(1).Name = "Sum of Future Expenses"
chart.PrimaryCategoryAxis.Title = "Products"
chart.PrimaryValueAxis.Title = "In Dollars"
'Set position of legend
chart.Legend.Position = OfficeLegendPosition.Bottom
'Set rotation and elevation values
chart.Rotation = 20
chart.Elevation = 15
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
Get the Ancestor comment
WComment ancestorComment = document.Comments[1].Ancestor;
Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Load an existing Word document into DocIO instance
Dim document As WordDocument = New WordDocument("Template.docx")
'Get the Ancestor comment
Dim ancestorComment As WComment = document.Comments(1).Ancestor
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
// Load an existing Word document into DocIO instance
using (WordDocument document = new WordDocument("Template.docx"))
{
// Checks whether the comment is resolved or not
bool done = document.Comments[0].Done;
// Saves the Word document
document.Save("Sample.docx", FormatType.Docx);
}
'Load an existing Word document into DocIO instance
Dim document As WordDocument = New WordDocument("Template.docx")
'Checks whether the comment is resolved or not
Dim done As Boolean = document.Comments(0).Done
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument();
IWSection section = document.AddSection();
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("If field which uses string of characters in expression");
paragraph = section.AddParagraph();
//Create the new instance of IF field
WIfField field = paragraph.AppendField("If", FieldType.FieldIf) as WIfField;
//Specify the expression, true and false statement in field code
field.FieldCode = "IF \"True\" = \"True\" \"The given statement is Correct\" \"The given statement is Wrong\"";
paragraph = section.AddParagraph();
paragraph.AppendText("If field which uses numbers in expression");
paragraph = section.AddParagraph();
//Create the new instance of IF field
field = paragraph.AppendField("If", FieldType.FieldIf) as WIfField;
//Specify the expression, true and false statement in field code
field.FieldCode = "IF 100 >= 1000 \"The given statement is Correct\" \"The given statement is Wrong\"";
//Update the document fields
document.UpdateDocumentFields();
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument()
Dim section As IWSection = document.AddSection()
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("If field which uses string of characters in expression")
paragraph = section.AddParagraph()
'Create the new instance of IF field
Dim field As WIfField = TryCast(paragraph.AppendField("If", FieldType.FieldIf), WIfField)
'Specify the expression, true and false statement in field code
field.FieldCode = "IF ""True"" = ""True"" ""The given statement is Correct"" ""The given statement is Wrong"""
paragraph = section.AddParagraph()
paragraph.AppendText("If field which uses numbers in expression")
paragraph = section.AddParagraph()
'Create the new instance of IF field
field = TryCast(paragraph.AppendField("If", FieldType.FieldIf), WIfField)
'Specify the expression, true and false statement in field code
field.FieldCode = "IF 100 >= 1000 ""The given statement is Correct"" ""The given statement is Wrong"""
'Update the document fields
document.UpdateDocumentFields()
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("This paragraph has picture. ");
//Append new picture to the paragraph
IWPicture picture = paragraph.AppendPicture(Image.FromFile("Image.png"));
//Set width and height for the paragraph
picture.Width = 150;
picture.Height = 100;
//Set text wrapping style – When the wrapping style is inline the images will not be absolutely positioned. It will be added next to the textrange.
picture.TextWrappingStyle = TextWrappingStyle.Square;
picture.TextWrappingType = TextWrappingType.Largest;
//Set horizontal and vertical origin
picture.HorizontalOrigin = HorizontalOrigin.Page;
picture.VerticalOrigin = VerticalOrigin.Paragraph;
//Set horizontal and vertical position for the picture
picture.HorizontalPosition = 200;
picture.VerticalPosition = 150;
//Set horizontal and vertical alignments
picture.HorizontalAlignment = ShapeHorizontalAlignment.Center;
picture.VerticalAlignment = ShapeVerticalAlignment.Bottom;
//Set name, title, alternate text.
picture.Title = "PictureTitle";
picture.Name = "PictureName";
picture.IsBelowText = true;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("This paragraph has picture. ")
'Append new picture to the paragraph
Dim picture As IWPicture = paragraph.AppendPicture(Image.FromFile("Image.png"))
'Set width and height for the paragraph
picture.Width = 150
picture.Height = 100
'Set text wrapping style – When the wrapping style is inline the images will not be absolutely positioned. It will be added next to the textrange.
picture.TextWrappingStyle = TextWrappingStyle.Square
picture.TextWrappingType = TextWrappingType.Largest
'Set horizontal and vertical origin
picture.HorizontalOrigin = HorizontalOrigin.Page
picture.VerticalOrigin = VerticalOrigin.Paragraph
'Set horizontal and vertical position for the picture
picture.HorizontalPosition = 200
picture.VerticalPosition = 150
'Set horizontal and vertical alignments
picture.HorizontalAlignment = ShapeHorizontalAlignment.Center
picture.VerticalAlignment = ShapeVerticalAlignment.Bottom
'Set name, title, alternate text.
picture.Title = "PictureTitle"
picture.Name = "PictureName"
picture.IsBelowText = True
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Get the image and convert to byte array
Image image = Image.FromFile("Image.png");
MemoryStream imageStream = new MemoryStream();
image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
byte[] imageBytes = imageStream.ToArray();
//Initialize new picture
WPicture picture = new WPicture(document);
//Load image from the byte array
picture.LoadImage(imageBytes);
//Set width and height
picture.Height = 100;
picture.Width = 150;
//Add picture to the paragraph
paragraph.Items.Add(picture);
//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()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Get the image and convert to byte array
Dim image__1 As Image = Image.FromFile("Image.png")
Dim imageStream As New MemoryStream()
image__1.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png)
Dim imageBytes As Byte() = imageStream.ToArray()
'Initialize new picture
Dim picture As New WPicture(document)
'Load image from the byte array
picture.LoadImage(imageBytes)
'Set width and height
picture.Height = 100
picture.Width = 150
'Add picture to the paragraph
paragraph.Items.Add(picture)
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Get the SVG image as byte array.
byte[] imageBytes = File.ReadAllBytes("Image.png");
//Get the SVG image as byte array.
byte[] svgData = File.ReadAllBytes("Image.svg");
//Initialize new picture
WPicture picture = new WPicture(document);
//Load both fallback and SVG image from the byte array
picture.LoadImage(svgData, imageBytes);
//Set width and height
picture.Height = 100;
picture.Width = 150;
//Add picture to the paragraph
paragraph.Items.Add(picture);
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Get the image byte array
Dim imageBytes As Byte() = File.ReadAllBytes("Image.png")
'Get the SVG image as byte array.
Dim svgData As Byte() = File.ReadAllBytes("Image.svg")
'Initialize new picture
Dim picture As New WPicture(document)
'Load both fallback and SVG image from the byte array
picture.LoadImage(svgData, imageBytes)
'Set width and height
picture.Height = 100
picture.Width = 150
'Add picture to the paragraph
paragraph.Items.Add(picture)
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Initialize new picture
WPicture picture = new WPicture(document);
//Load image from the file
picture.LoadImage(Image.FromFile("Image.png"));
//Set width and height
picture.Height = 100;
picture.Width = 150;
//Add picture to the paragraph
paragraph.Items.Add(picture);
//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()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Initialize new picture
Dim picture As New WPicture(document)
'Load image from the file
picture.LoadImage(Image.FromFile("Image.png"))
'Set width and height
picture.Height = 100
picture.Width = 150
'Add picture to the paragraph
paragraph.Items.Add(picture)
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("This paragraph has picture. ");
//Append new picture to the paragraph
IWPicture picture = paragraph.AppendPicture(Image.FromFile("Image.png"));
//Set width and height for the paragraph
picture.Width = 150;
picture.Height = 100;
//Set caption for picture
picture.AddCaption("Figure 1.1", CaptionNumberingFormat.Number, CaptionPosition.AboveImage);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("This paragraph has picture. ")
'Append new picture to the paragraph
Dim picture As IWPicture = paragraph.AppendPicture(Image.FromFile("Image.png"))
'Set width and height for the paragraph
picture.Width = 150
picture.Height = 100
'Set caption for picture
picture.AddCaption("Figure 1.1", CaptionNumberingFormat.Number, CaptionPosition.AboveImage)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
//Creates a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new text to the paragraph
IWParagraph paragraph = section.AddParagraph();
//Gets the image and convert to byte array
Image image = Image.FromFile("Image.png");
MemoryStream imageStream = new MemoryStream();
image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
byte[] imageBytes = imageStream.ToArray();
//Initializes new picture
WPicture picture = new WPicture(document);
//Loads an image from the byte array
picture.LoadImage(imageBytes);
//Sets height and width for the image
picture.Height = 100;
picture.Width = 150;
//Sets picture rotation in degree
picture.Rotation = 90;
//Adds image to the paragraph
paragraph.Items.Add(picture);
//Saves the Word document
document.Save("Sample.docx", FormatType.Docx);
//Closes the document
document.Close();
'Creates a New Word document
Dim document As WordDocument = New WordDocument
'Adds new section to the document
Dim section As IWSection = document.AddSection
'Adds new text to the paragraph
Dim paragraph As IWParagraph = section.AddParagraph
'Gets the image and convert to byte array
Dim image As Image = Image.FromFile("Image.png")
Dim imageStream As MemoryStream = New MemoryStream
image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png)
Dim imageBytes() As Byte = imageStream.ToArray
'Initializes new picture
Dim picture As WPicture = New WPicture(document)
'Loads an image from the byte array
picture.LoadImage(imageBytes)
'Sets height and width for the image
picture.Height = 100
picture.Width = 150
'Sets picture rotation in degree
picture.Rotation = 90
'Adds image to the paragraph
paragraph.Items.Add(picture)
'Saves the Word document
document.Save("Sample.docx", FormatType.Docx)
'Closes the document
document.Close()
//Creates a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new text to the paragraph
IWParagraph paragraph = section.AddParagraph();
//Gets the image and convert to byte array
Image image = Image.FromFile("Image.png");
MemoryStream imageStream = new MemoryStream();
image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
byte[] imageBytes = imageStream.ToArray();
//Initializes new picture
WPicture picture = new WPicture(document);
//Loads an image from the byte array
picture.LoadImage(imageBytes);
//Sets height and width for the image
picture.Height = 100;
picture.Width = 150;
//Sets horizontal flip to the picture
picture.FlipHorizontal = true;
//Adds image to the paragraph
paragraph.Items.Add(picture);
//Saves the Word document
document.Save("Sample.docx", FormatType.Docx);
//Closes the document
document.Close();
'Creates a New Word document
Dim document As WordDocument = New WordDocument
'Adds new section to the document
Dim section As IWSection = document.AddSection
'Adds new text to the paragraph
Dim paragraph As IWParagraph = section.AddParagraph
'Gets the image and convert to byte array
Dim image As Image = Image.FromFile("Image.png")
Dim imageStream As MemoryStream = New MemoryStream
image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png)
Dim imageBytes() As Byte = imageStream.ToArray
'Initializes new picture
Dim picture As WPicture = New WPicture(document)
'Loads an image from the byte array
picture.LoadImage(imageBytes)
'Sets height and width for the image
picture.Height = 100
picture.Width = 150
'Sets horizontal flip to the picture
picture.FlipHorizontal = True
'Adds image to the paragraph
paragraph.Items.Add(picture)
'Saves the Word document
document.Save("Sample.docx", FormatType.Docx)
'Closes the document
document.Close()
//Creates a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new text to the paragraph
IWParagraph paragraph = section.AddParagraph();
//Gets the image and convert to byte array
Image image = Image.FromFile("Image.png");
MemoryStream imageStream = new MemoryStream();
image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
byte[] imageBytes = imageStream.ToArray();
//Initializes new picture
WPicture picture = new WPicture(document);
//Loads an image from the byte array
picture.LoadImage(imageBytes);
//Sets height and width for the image
picture.Height = 100;
picture.Width = 150;
//Sets vertical flip to the picture
picture.FlipVertical = true;
//Adds image to the paragraph
paragraph.Items.Add(picture);
//Saves the Word document
document.Save("Sample.docx", FormatType.Docx);
//Closes the document
document.Close();
'Creates a New Word document
Dim document As WordDocument = New WordDocument
'Adds new section to the document
Dim section As IWSection = document.AddSection
'Adds new text to the paragraph
Dim paragraph As IWParagraph = section.AddParagraph
'Gets the image and convert to byte array
Dim image As Image = Image.FromFile("Image.png")
Dim imageStream As MemoryStream = New MemoryStream
image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png)
Dim imageBytes() As Byte = imageStream.ToArray
'Initializes new picture
Dim picture As WPicture = New WPicture(document)
'Loads an image from the byte array
picture.LoadImage(imageBytes)
'Sets height and width for the image
picture.Height = 100
picture.Width = 150
'Sets vertical flip to the picture
picture.FlipVertical = True
'Adds image to the paragraph
paragraph.Items.Add(picture)
'Saves the Word document
document.Save("Sample.docx", FormatType.Docx)
'Closes the document
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument("Bookmarks.docx");
//Add new paragraph to the section
WParagraph paragraph = document.Sections[0].AddParagraph() as WParagraph;
//Append sequence field to the paragraph
WSeqField field = (WSeqField)paragraph.AppendField("Sequence field", FieldType.FieldSequence);
//Set the bookmark name as caption and number format
field.CaptionName = "Northwind";
field.NumberFormat = CaptionNumberingFormat.Roman;
//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("Bookmarks.docx")
'Add new paragraph to the section
Dim paragraph As WParagraph = TryCast(document.Sections(0).AddParagraph(), WParagraph)
'Append sequence field to the paragraph
Dim field As WSeqField = DirectCast(paragraph.AppendField("Sequence field", FieldType.FieldSequence), WSeqField)
'Set the bookmark name as caption and number format
field.CaptionName = "Northwind"
field.NumberFormat = CaptionNumberingFormat.Roman
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
//Load an existing Word document into DocIO instance.
WordDocument document = new WordDocument("Template.docx");
//Add new paragraph to the section
WParagraph paragraph = document.Sections[0].AddParagraph() as WParagraph;
//Append sequence field to the paragraph
WSeqField field = (WSeqField)paragraph.AppendField("Sequence field", FieldType.FieldSequence);
//Set the NumberFormat of the SeqField.
field.NumberFormat = CaptionNumberingFormat.Number;
//Updates the document fields
document.UpdateDocumentFields();
//Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Load an existing Word document into DocIO instance.
Dim document As WordDocument = New WordDocument("Template.docx")
'Add new paragraph to the section
Dim paragraph As WParagraph = TryCast(document.Sections(0).AddParagraph(), WParagraph)
'Append sequence field to the paragraph
Dim field As WSeqField = CType(paragraph.AppendField("Sequence field", FieldType.FieldSequence), WSeqField)
'Set the NumberFormat of the SeqField.
field.NumberFormat = CaptionNumberingFormat.Number
'Updates the document fields
document.UpdateDocumentFields()
'Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Load an existing Word document into DocIO instance.
WordDocument document = new WordDocument("Template.docx");
//Add new paragraph to the section
WParagraph paragraph = document.Sections[0].AddParagraph() as WParagraph;
//Append sequence field to the paragraph
WSeqField field = (WSeqField)paragraph.AppendField("Sequence field", FieldType.FieldSequence);
//Set the CaptionName of the SeqField.
field.CaptionName = "Test";
//Updates the document fields
document.UpdateDocumentFields();
//Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Load an existing Word document into DocIO instance.
Dim document As WordDocument = New WordDocument("Template.docx")
'Add new paragraph to the section
Dim paragraph As WParagraph = TryCast(document.Sections(0).AddParagraph(), WParagraph)
'Append sequence field to the paragraph
Dim field As WSeqField = CType(paragraph.AppendField("Sequence field", FieldType.FieldSequence), WSeqField)
'Set the CaptionName of the SeqField.
field.CaptionName = "Test";
//Updates the document fields
document.UpdateDocumentFields()
'Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Load an existing Word document into DocIO instance.
WordDocument document = new WordDocument("Template.docx");
//Add new paragraph to the section
WParagraph paragraph = document.Sections[0].AddParagraph() as WParagraph;
//Append sequence field to the paragraph
WSeqField field = (WSeqField)paragraph.AppendField("Sequence field", FieldType.FieldSequence);
//Set the BookmarkName of the SeqField.
field.BookmarkName = "Bookmark1";
//Updates the document fields
document.UpdateDocumentFields();
//Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Load an existing Word document into DocIO instance.
Dim document As WordDocument = New WordDocument("Template.docx")
'Add new paragraph to the section
Dim paragraph As WParagraph = TryCast(document.Sections(0).AddParagraph(), WParagraph)
'Append sequence field to the paragraph
Dim field As WSeqField = CType(paragraph.AppendField("Sequence field", FieldType.FieldSequence), WSeqField)
'Set the BookmarkName of the SeqField.
field.BookmarkName = "Bookmark1"
'Updates the document fields
document.UpdateDocumentFields()
'Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Load an existing Word document into DocIO instance.
WordDocument document = new WordDocument("Template.docx");
//Add new paragraph to the section
WParagraph paragraph = document.Sections[0].AddParagraph() as WParagraph;
//Append sequence field to the paragraph
WSeqField field = (WSeqField)paragraph.AppendField("Sequence field", FieldType.FieldSequence);
//Set the InsertNextNumber of the SeqField.
field.InsertNextNumber = true;
//Updates the document fields
document.UpdateDocumentFields();
//Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx);
document.Close();
Load an existing Word document into DocIO instance.
Dim document As WordDocument = New WordDocument("Template.docx")
'Add new paragraph to the section
Dim paragraph As WParagraph = TryCast(document.Sections(0).AddParagraph(), WParagraph)
'Append sequence field to the paragraph
Dim field As WSeqField = CType(paragraph.AppendField("Sequence field", FieldType.FieldSequence), WSeqField)
'Set the InsertNextNumber of the SeqField.
field.InsertNextNumber = True
'Updates the document fields
document.UpdateDocumentFields()
'Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Load an existing Word document into DocIO instance.
WordDocument document = new WordDocument("Template.docx");
//Add new paragraph to the section
WParagraph paragraph = document.Sections[0].AddParagraph() as WParagraph;
//Append sequence field to the paragraph
WSeqField field = (WSeqField)paragraph.AppendField("Sequence field", FieldType.FieldSequence);
//Set the RepeatNearestNumber of the SeqField.
field.RepeatNearestNumber = true;
//Updates the document fields
document.UpdateDocumentFields();
//Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Load an existing Word document into DocIO instance.
Dim document As WordDocument = New WordDocument("Template.docx")
'Add new paragraph to the section
Dim paragraph As WParagraph = TryCast(document.Sections(0).AddParagraph(), WParagraph)
'Append sequence field to the paragraph
Dim field As WSeqField = CType(paragraph.AppendField("Sequence field", FieldType.FieldSequence), WSeqField)
'Set the RepeatNearestNumber of the SeqField.
field.RepeatNearestNumber = True
'Updates the document fields
document.UpdateDocumentFields()
'Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Load an existing Word document into DocIO instance.
WordDocument document = new WordDocument("Template.docx");
//Add new paragraph to the section
WParagraph paragraph = document.Sections[0].AddParagraph() as WParagraph;
//Append sequence field to the paragraph
WSeqField field = (WSeqField)paragraph.AppendField("Sequence field", FieldType.FieldSequence);
//Set the HideResult of the SeqField.
field.HideResult = true;
//Updates the document fields
document.UpdateDocumentFields();
//Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx);
document.Close();
Load an existing Word document into DocIO instance.
Dim document As WordDocument = New WordDocument("Template.docx")
//Add new paragraph to the section
Dim paragraph As WParagraph = TryCast(document.Sections(0).AddParagraph(), WParagraph)
//Append sequence field to the paragraph
Dim field As WSeqField = CType(paragraph.AppendField("Sequence field", FieldType.FieldSequence), WSeqField)
//Set the HideResult of the SeqField.
field.HideResult = True
//Updates the document fields
document.UpdateDocumentFields()
//Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Load an existing Word document into DocIO instance.
WordDocument document = new WordDocument("Template.docx");
//Add new paragraph to the section
WParagraph paragraph = document.Sections[0].AddParagraph() as WParagraph;
//Append sequence field to the paragraph
WSeqField field = (WSeqField)paragraph.AppendField("Sequence field", FieldType.FieldSequence);
//Set the ResetNumber of the SeqField.
field.ResetNumber = 7;
//Updates the document fields
document.UpdateDocumentFields();
//Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx);
document.Close();
Load an existing Word document into DocIO instance.
Dim document As WordDocument = New WordDocument("Template.docx")
//Add new paragraph to the section
Dim paragraph As WParagraph = TryCast(document.Sections(0).AddParagraph(), WParagraph)
//Append sequence field to the paragraph
Dim field As WSeqField = CType(paragraph.AppendField("Sequence field", FieldType.FieldSequence), WSeqField)
//Set the ResetNumber of the SeqField.
field.ResetNumber = 7
//Updates the document fields
document.UpdateDocumentFields()
//Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Load an existing Word document into DocIO instance.
WordDocument document = new WordDocument("Template.docx");
//Add new paragraph to the section
WParagraph paragraph = document.Sections[0].AddParagraph() as WParagraph;
//Append sequence field to the paragraph
WSeqField field = (WSeqField)paragraph.AppendField("Sequence field", FieldType.FieldSequence);
//Set the ResetHeadingLevel of the SeqField.
field.ResetHeadingLevel = 1;
//Updates the document fields
document.UpdateDocumentFields();
//Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx);
document.Close();
Load an existing Word document into DocIO instance.
Dim document As WordDocument = New WordDocument("Template.docx")
//Add new paragraph to the section
Dim paragraph As WParagraph = TryCast(document.Sections(0).AddParagraph(), WParagraph)
//Append sequence field to the paragraph
Dim field As WSeqField = CType(paragraph.AppendField("Sequence field", FieldType.FieldSequence), WSeqField)
//Set the ResetHeadingLevel of the SeqField.
field.ResetHeadingLevel = 1;
//Updates the document fields
document.UpdateDocumentFields()
//Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx)
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("Example of adding symbols to the paragraph: ");
//Insert symbol with character code 100
WSymbol symbol = paragraph.AppendSymbol(100);
symbol.FontName = "Windings";
//Save and close the Word 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()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("Example of adding symbols to the paragraph: ")
'Insert symbol with character code 100
Dim symbol As WSymbol = paragraph.AppendSymbol(100)
symbol.FontName = "Windings"
'Save and close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Append new textbox to the paragraph
IWTextBox textbox = paragraph.AppendTextBox(150, 75);
//Add new text to the textbox body
IWParagraph textboxParagraph = textbox.TextBoxBody.AddParagraph();
textboxParagraph.AppendText("Text inside text box");
textboxParagraph = textbox.TextBoxBody.AddParagraph();
//Add new picture to textbox body
IWPicture picture = textboxParagraph.AppendPicture(Image.FromFile(@"Image.png"));
picture.Height = 75;
picture.Width = 50;
//Save and close the Word 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()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Append new textbox to the paragraph
Dim textbox As IWTextBox = paragraph.AppendTextBox(150, 75)
'Add new text to the textbox body
Dim textboxParagraph As IWParagraph = textbox.TextBoxBody.AddParagraph()
textboxParagraph.AppendText("Text inside text box")
textboxParagraph = textbox.TextBoxBody.AddParagraph()
'Add new picture to textbox body
Dim picture As IWPicture = textboxParagraph.AppendPicture(Image.FromFile("Image.png"))
picture.Height = 75
picture.Width = 50
'Save and close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
WParagraph paragraph = section.AddParagraph() as WParagraph;
paragraph.AppendText("General Information");
section.AddParagraph();
paragraph = section.AddParagraph() as WParagraph;
IWTextRange text = paragraph.AppendText("Name\t");
text.CharacterFormat.Bold = true;
//Append Text form field
WTextFormField textfield = paragraph.AppendTextFormField(null);
//Set type of Text form field
textfield.Type = TextFormFieldType.RegularText;
textfield.CharacterFormat.FontName = "Calibri";
textfield.CalculateOnExit = true;
section.AddParagraph();
paragraph = section.AddParagraph() as WParagraph;
text = paragraph.AppendText("Date of Birth\t");
text.CharacterFormat.Bold = true;
//Append Text form field
textfield = paragraph.AppendTextFormField("Date field", DateTime.Now.ToString("MM/DD/YY"));
textfield.StringFormat = "MM/DD/YY";
//Set Text form field type
textfield.Type = TextFormFieldType.DateText;
textfield.CalculateOnExit = true;
//Save the Word document
document.Save("Textfield.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As WParagraph = TryCast(section.AddParagraph(), WParagraph)
paragraph.AppendText("General Information")
section.AddParagraph()
paragraph = TryCast(section.AddParagraph(), WParagraph)
Dim text As IWTextRange = paragraph.AppendText("Name" & vbTab)
text.CharacterFormat.Bold = True
'Append Text form field
Dim textfield As WTextFormField = paragraph.AppendTextFormField(Nothing)
'Set type of Text form field
textfield.Type = TextFormFieldType.RegularText
textfield.CharacterFormat.FontName = "Calibri"
textfield.CalculateOnExit = True
section.AddParagraph()
paragraph = TryCast(section.AddParagraph(), WParagraph)
text = paragraph.AppendText("Date of Birth" & vbTab)
text.CharacterFormat.Bold = True
'Append Text form field
textfield = paragraph.AppendTextFormField("Date field", DateTime.Now.ToString("MM/DD/YY"))
textfield.StringFormat = "MM/DD/YY"
'Set Text form field type
textfield.Type = TextFormFieldType.DateText
textfield.CalculateOnExit = True
'Save the Word document
document.Save("Textfield.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
//Load the template Word document.
WordDocument document = new WordDocument("Template.docx");
//Data source.
DataSet ds = new DataSet();
ds.Tables.Add();
//Define the columns
ds.Tables[0].TableName = "Employee";
ds.Tables[0].Columns.Add("NAME");
ds.Tables[0].Columns.Add("DESC");
//Set the values.
DataRow row;
row = ds.Tables["Employee"].NewRow();
row["NAME"] = "AAA";
row["DESC"] = null;
ds.Tables["Employee"].Rows.Add(row);
row = ds.Tables["Employee"].NewRow();
row["NAME"] = "BBB";
row["DESC"] = "";
ds.Tables["Employee"].Rows.Add(row);
row = ds.Tables["Employee"].NewRow();
row["NAME"] = "CCC";
row["DESC"] = "ccc";
ds.Tables["Employee"].Rows.Add(row);
//Enable a flag to start a new page for each group of records.
document.MailMerge.StartAtNewPage= true;
//Execute mail merge.
document.MailMerge.ExecuteGroup(ds.Tables["Employee"]);
//Save the Word document.
document.Save("Result.docx", FormatType.Docx);
//Close the Word document.
document.Close();
'Load the template Word document.
Dim document As WordDocument = New WordDocument("Template.docx")
'Data source.
Dim ds As DataSet = New DataSet
ds.Tables.Add
'Define the columns.
ds.Tables(0).TableName = "Employee"
ds.Tables(0).Columns.Add("NAME")
ds.Tables(0).Columns.Add("DESC")
'Set values.
Dim row As DataRow
row = ds.Tables("Employee").NewRow
row("NAME") = "AAA"
row("DESC") = Nothing
ds.Tables("Employee").Rows.Add(row)
row = ds.Tables("Employee").NewRow
row("NAME") = "BBB"
row("DESC") = ""
ds.Tables("Employee").Rows.Add(row)
row = ds.Tables("Employee").NewRow
row("NAME") = "CCC"
row("DESC") = "ccc"
ds.Tables("Employee").Rows.Add(row)
'Enable a flag to start a new page for each group of records.
document.MailMerge.StartAtNewPage= true
'Execute mail merge.
document.MailMerge.ExecuteGroup(ds.Tables("Employee"))
'Save the Word document.
document.Save("Result.docx", FormatType.Docx)
'Close the Word document.
document.Close
//Opens the template document.
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Set "InsertAsNew" as true to insert a new row for every group when group start and end present in the same table cell.
document.MailMerge.InsertAsNewRow = true;
//Performs the mail merge.
document.MailMerge.ExecuteGroup(DataTable);
//Saves and closes the WordDocument instance.
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Opens the template document.
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Set "InsertAsNew" as true to insert a new row for every group when group start and end present in the same table cell.
document.MailMerge.InsertAsNewRow = True
'Performs the mail merge.
document.MailMerge.ExecuteGroup(DataTable)
'Saves and closes the WordDocument instance.
document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Load an existing Word document into WordDocument instance.
WordDocument document = new WordDocument("Sample.docx", FormatType.Docx);
//Change the datasource property of the mail merge settings in the word document.
document.MailMerge.Settings.DataSource = "NewDataSource.txt";
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
'Load an existing Word document into WordDocument instance
Dim document As New WordDocument("Sample.docx", FormatType.Docx)
'Change the datasource property of the mail merge settings in the word document
document.MailMerge.Settings.DataSource = "NewDataSource.txt"
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
//Load an existing Word document into WordDocument instance.
WordDocument document = new WordDocument("Sample.docx", FormatType.Docx);
//Removes the mail merge settings in the word document.
if (document.MailMerge.Settings.HasData)
document.MailMerge.Settings.RemoveData();
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
'Load an existing Word document into WordDocument instance
Dim document As New WordDocument("Sample.docx", FormatType.Docx)
'Removes the mail merge settings in the word document.
If document.MailMerge.Settings.HasData Then
document.MailMerge.Settings.RemoveData()
End If
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
//Load an existing Word document into WordDocument instance.
WordDocument document = new WordDocument("Sample.docx", FormatType.Docx);
//Change the datasource property of the mail merge settings in the word document.
document.MailMerge.Settings.DataSource = "NewDataSource.txt";
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
'Load an existing Word document into WordDocument instance
Dim document As New WordDocument("Sample.docx", FormatType.Docx)
'Change the datasource property of the mail merge settings in the word document
document.MailMerge.Settings.DataSource = "NewDataSource.txt"
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
//Load an existing Word document into WordDocument instance.
WordDocument document = new WordDocument("Sample.docx", FormatType.Docx);
//Removes the mail merge settings in the word document.
if (document.MailMerge.Settings.HasData)
document.MailMerge.Settings.RemoveData();
//Saves the specified document
document.Save("Sample.docx", FormatType.Docx);
//Close the WordDocument instance
document.Close();
'Load an existing Word document into WordDocument instance
Dim document As New WordDocument("Sample.docx", FormatType.Docx)
'Removes the mail merge settings in the word document.
If document.MailMerge.Settings.HasData Then
document.MailMerge.Settings.RemoveData()
End If
'Saves the specified document
document.Save("Sample.docx", FormatType.Docx)
'Close the WordDocument instance
document.Close()
//Load an existing Word document into DocIO instance.
WordDocument document = new WordDocument("Template.docx");
//Get the revision from the revision collection and accepts.
document.Revisions[0].Accept();
//Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Load an existing Word document into DocIO instance.
Dim document As WordDocument = New WordDocument("Template.docx")
'Get the revision from the revision collection and accepts.
document.Revisions(0).Accept()
'Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Load an existing Word document into DocIO instance.
WordDocument document = new WordDocument("Template.docx");
//Get the revision from the revision collection and rejects.
document.Revisions[0].Reject();
//Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Load an existing Word document into DocIO instance.
Dim document As WordDocument = New WordDocument("Template.docx")
'Get the revision from the revision collection and rejects.
document.Revisions(0).Reject()
'Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Loads an existing Word document
WordDocument document = new WordDocument(@"Template.docx");
//If the author of current revision is same as expected author name, then accept it
if (document.Revisions[0].Author == "Syncfusion")
document.Revisions[0].Accept();
//Saves and closes the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Loads an existing Word document
Dim document As WordDocument = New WordDocument("Template.docx")
'If the author of current revision is same as expected author name, then accept it
If document.Revisions(0).Author Is "Syncfusion" Then worddocument.Revisions(0).Accept()
'Saves and closes the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Loads an existing Word document
WordDocument document = new WordDocument(@"Template.docx");
DateTime dateTime = DateTime.Parse("2020 - 05 - 28T20: 26:00");
//If the date of current revision same as expected date, then accepts it
if (document.Revisions[0].Date == dateTime)
document.Revisions[0].Accept();
//Saves and closes the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Loads an existing Word document
Dim document As WordDocument = New WordDocument("Template.docx")
Dim dateTime As Date = Date.Parse("2020 - 05 - 28T20: 26:00")
'If the date of current revision same as expected date, then accepts it
If document.Revisions(0).[Date] Is dateTime Then wordDocument.Revisions(0).Accept()
'Saves and closes the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Loads an existing Word document
WordDocument document = new WordDocument("Template.docx");
//If the revision is insertion type of revision, then accept it
if (document.Revisions[0].RevisionType == RevisionType.Insertions)
document.Revisions[0].Accept();
//Saves and closes the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Loads an existing Word document
Dim document As WordDocument = New WordDocument("C:\Users\TamilselvanMuralisun\Desktop\style formatting.docx")
'If the revision is insertion type of revision, then accept it
If document.Revisions(0).RevisionType Is RevisionType.Insertions Then word.Revisions(0).Accept()
'Saves and closes the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
BlockContentControl control = new BlockContentControl(document);
//Adds new paragraph to the section.
WParagraph paragraph = new WParagraph(control.Document);
//Adds new text to the content control.
paragraph.AppendText("Block content control");
//Adds pagagraph into the Block content control.
control.TextBody.ChildEntities.Add(paragraph);
//Sets title of the block content control.
control.ContentControlProperties.Title = "Rich text content control";
//Adds content control into the document.
document.LastSection.Body.ChildEntities.Add(control);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
Dim document As New WordDocument()
'Adds new section to the document
Dim section As IWSection = document.AddSection()
Dim control As New BlockContentControl(document)
'Adds new paragraph to the section.
Dim paragraph As New WParagraph(control.Document)
'Adds new text to the content control.
paragraph.AppendText("Block content control")
'Adds paragraph into the Block content control.
control.TextBody.ChildEntities.Add(paragraph)
'Sets title of the block content control.
control.ContentControlProperties.Title = "Rich text content control"
'Adds content control into the document.
document.LastSection.Body.ChildEntities.Add(control)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
BlockContentControl control = new BlockContentControl(document, ContentControlType.RichText);
//Adds new paragraph to the section.
WParagraph paragraph = new WParagraph(control.Document);
//Adds new text to the content control.
paragraph.AppendText(@"the security requirements are met, the CLR performs just in time (JIT) compilation to convert the IL code to native machine instructions.");
//Adds pagagraph into the Block content control.
control.TextBody.ChildEntities.Add(paragraph);
//Find the text based on regex.
TextSelection text = control.Find(new Regex("instructions"));
//Replaces all entries of given string with replace string.
control.Replace(new Regex(@"requirements"), text);
//Adds content control into the document.
document.LastSection.Body.ChildEntities.Add(control);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
Dim document As New WordDocument()
'Adds new section to the document
Dim section As IWSection = document.AddSection()
Dim control As New BlockContentControl(document, ContentControlType.RichText)
'Adds new paragraph to the section.
Dim paragraph As New WParagraph(control.Document)
'Adds new text to the content control.
paragraph.AppendText("the security requirements are met, the CLR performs just in time (JIT) compilation to convert the IL code to native machine instructions.")
'Adds pagagraph into the Block content control.
control.TextBody.ChildEntities.Add(paragraph)
'Find the text based on regex.
Dim text As TextSelection = control.Find(New Regex("instructions"))
'Replaces all entries of given string with replace string.
control.Replace(New Regex("requirements"), text)
'Adds content control into the document.
document.LastSection.Body.ChildEntities.Add(control)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
BlockContentControl control = new BlockContentControl(document, ContentControlType.RichText);
//Adds new paragraph to the section.
WParagraph paragraph = new WParagraph(control.Document);
//Adds new text to the content control.
paragraph.AppendText(@"the security requirements are met, the CLR performs just in time (JIT) compilation to convert the IL code to native machine instructions.");
//Adds pagagraph into the Block content control.
control.TextBody.ChildEntities.Add(paragraph);
//Find the text based on regex.
TextSelection text = control.Find(new Regex("instructions"));
//Replaces all entries of given string with replace string.
control.Replace(new Regex(@"requirements"), text);
//Adds content control into the document.
document.LastSection.Body.ChildEntities.Add(control);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
Dim document As New WordDocument()
'Adds new section to the document
Dim section As IWSection = document.AddSection()
Dim control As New BlockContentControl(document, ContentControlType.RichText)
'Adds new paragraph to the section.
Dim paragraph As New WParagraph(control.Document)
'Adds new text to the content control.
paragraph.AppendText("the security requirements are met, the CLR performs just in time (JIT) compilation to convert the IL code to native machine instructions.")
'Adds pagagraph into the Block content control.
control.TextBody.ChildEntities.Add(paragraph)
'Find the text based on regex.
Dim text As TextSelection = control.Find(New Regex("instructions"))
'Replaces all entries of given string with replace string.
control.Replace(New Regex("requirements"), text)
'Adds content control into the document.
document.LastSection.Body.ChildEntities.Add(control)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
BlockContentControl control = new BlockContentControl(document, ContentControlType.RichText);
//Adds new paragraph to the section.
WParagraph paragraph = new WParagraph(control.Document);
//Adds new text to the content control.
paragraph.AppendText(@"the security requirements are met, the CLR performs just in time (JIT) compilation to convert the IL code to native machine instructions.");
//Adds pagagraph into the Block content control.
control.TextBody.ChildEntities.Add(paragraph);
//Find the text based on regex.
TextSelection text = control.Find(new Regex("instructions"));
//Replaces all entries of given string with replace string.
control.Replace(new Regex(@"requirements"), text, true);
//Adds content control into the document.
document.LastSection.Body.ChildEntities.Add(control);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
Dim document As New WordDocument()
'Adds new section to the document
Dim section As IWSection = document.AddSection()
Dim control As New BlockContentControl(document, ContentControlType.RichText)
'Adds new paragraph to the section.
Dim paragraph As New WParagraph(control.Document)
'Adds new text to the content control.
paragraph.AppendText("the security requirements are met, the CLR performs just in time (JIT) compilation to convert the IL code to native machine instructions.")
'Adds pagagraph into the Block content control.
control.TextBody.ChildEntities.Add(paragraph)
'Find the text based on regex.
Dim text As TextSelection = control.Find(New Regex("instructions"))
'Replaces all entries of given string with replace string.
control.Replace(New Regex("requirements"), text, true)
'Adds content control into the document.
document.LastSection.Body.ChildEntities.Add(control)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
BlockContentControl control = new BlockContentControl(document, ContentControlType.RichText);
//Adds new paragraph to the section.
WParagraph paragraph = new WParagraph(control.Document);
//Adds new text to the content control.
paragraph.AppendText(@"the security requirements are met, the CLR performs just in time (JIT) compilation to convert the IL code to native machine instructions.");
//Adds pagagraph into the Block content control.
control.TextBody.ChildEntities.Add(paragraph);
//Find the text based on regex.
TextSelection text = control.Find(new Regex("instructions"));
//Replaces all entries of given string with replace string.
control.Replace("requirements", text, false, true, true);
//Adds content control into the document.
document.LastSection.Body.ChildEntities.Add(control);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
Dim document As New WordDocument()
'Adds new section to the document
Dim section As IWSection = document.AddSection()
Dim control As New BlockContentControl(document, ContentControlType.RichText)
'Adds new paragraph to the section.
Dim paragraph As New WParagraph(control.Document)
'Adds new text to the content control.
paragraph.AppendText("the security requirements are met, the CLR performs just in time (JIT) compilation to convert the IL code to native machine instructions.")
'Adds pagagraph into the Block content control.
control.TextBody.ChildEntities.Add(paragraph)
'Find the text based on regex.
Dim text As TextSelection = control.Find(New Regex("instructions"))
'Replaces all entries of given string with replace string.
control.Replace(New Regex("requirements"), text, false, true, true)
'Adds content control into the document.
document.LastSection.Body.ChildEntities.Add(control)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
BlockContentControl control = new BlockContentControl(document, ContentControlType.RichText);
//Adds new paragraph to the section.
WParagraph paragraph = new WParagraph(control.Document);
//Adds new text to the content control.
paragraph.AppendText(@"the security requirements are met, the CLR performs just in time (JIT) compilation to convert the IL code to native machine instructions.");
//Adds pagagraph into the Block content control.
control.TextBody.ChildEntities.Add(paragraph);
//Find the text based on regex.
TextSelection text = control.Find(new Regex("instructions"));
//Replaces all entries of given string with replace string.
control.Replace(new Regex(@"requirements"), text);
//Adds content control into the document.
document.LastSection.Body.ChildEntities.Add(control);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
Dim document As New WordDocument()
'Adds new section to the document
Dim section As IWSection = document.AddSection()
Dim control As New BlockContentControl(document, ContentControlType.RichText)
'Adds new paragraph to the section.
Dim paragraph As New WParagraph(control.Document)
'Adds new text to the content control.
paragraph.AppendText("the security requirements are met, the CLR performs just in time (JIT) compilation to convert the IL code to native machine instructions.")
'Adds pagagraph into the Block content control.
control.TextBody.ChildEntities.Add(paragraph)
'Find the text based on regex.
Dim text As TextSelection = control.Find(New Regex("instructions"))
'Replaces all entries of given string with replace string.
control.Replace(New Regex("requirements"), text)
'Adds content control into the document.
document.LastSection.Body.ChildEntities.Add(control)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
BlockContentControl control = new BlockContentControl(document, ContentControlType.RichText);
//Adds new paragraph to the section.
WParagraph paragraph = new WParagraph(control.Document);
//Adds new text to the content control.
paragraph.AppendText("Block content control");
//Adds pagagraph into the Block content control.
control.TextBody.ChildEntities.Add(paragraph);
//Adds content control into the document.
document.LastSection.Body.ChildEntities.Add(control);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
Dim document As New WordDocument()
'Adds new section to the document
Dim section As IWSection = document.AddSection()
Dim control As New BlockContentControl(document, ContentControlType.RichText)
'Adds new paragraph to the section.
Dim paragraph As New WParagraph(control.Document)
'Adds new text to the content control.
paragraph.AppendText("Block content control")
'Adds pagagraph into the Block content control.
control.TextBody.ChildEntities.Add(paragraph)
'Adds content control into the document.
document.LastSection.Body.ChildEntities.Add(control)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
BlockContentControl control = new BlockContentControl(document, ContentControlType.RichText);
//Adds new paragraph to the section.
WParagraph paragraph = new WParagraph(control.Document);
//Adds new text to the content control.
paragraph.AppendText("Block content control");
//Adds pagagraph into the Block content control.
control.TextBody.ChildEntities.Add(paragraph);
//Sets title of the block content control.
control.ContentControlProperties.Title = "Rich text content control";
//Adds content control into the document.
document.LastSection.Body.ChildEntities.Add(control);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
Dim document As New WordDocument()
'Adds new section to the document
Dim section As IWSection = document.AddSection()
Dim control As New BlockContentControl(document, ContentControlType.RichText)
'Adds new paragraph to the section.
Dim paragraph As New WParagraph(control.Document)
'Adds new text to the content control.
paragraph.AppendText("Block content control")
'Adds paragraph into the Block content control.
control.TextBody.ChildEntities.Add(paragraph)
'Sets title of the block content control.
control.ContentControlProperties.Title = "Rich text content control"
'Adds content control into the document.
document.LastSection.Body.ChildEntities.Add(control)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
BlockContentControl control = new BlockContentControl(document, ContentControlType.RichText);
//Adds new paragraph to the section.
WParagraph paragraph = new WParagraph(control.Document);
//Adds new text to the content control.
paragraph.AppendText("Block content control");
//Adds pagagraph into the Block content control.
control.TextBody.ChildEntities.Add(paragraph);
//Sets title of the block content control.
control.ContentControlProperties.Title = "Rich text content control";
//Adds content control into the document.
document.LastSection.Body.ChildEntities.Add(control);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
Dim document As New WordDocument()
'Adds new section to the document
Dim section As IWSection = document.AddSection()
Dim control As New BlockContentControl(document, ContentControlType.RichText)
'Adds new paragraph to the section.
Dim paragraph As New WParagraph(control.Document)
'Adds new text to the content control.
paragraph.AppendText("Block content control")
'Adds paragraph into the Block content control.
control.TextBody.ChildEntities.Add(paragraph)
'Sets title of the block content control.
control.ContentControlProperties.Title = "Rich text content control"
'Adds content control into the document.
document.LastSection.Body.ChildEntities.Add(control)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
WordDocument document = new WordDocument();
//Adds new section to the document.
IWSection section = document.AddSection();
//Adds new table to the section.
IWTable table = section.AddTable();
//Adds new row to the table.
WTableRow tableRow = table.AddRow();
//Adds new cell to the row.
WTableCell tableCell = tableRow.AddCell();
tableCell.Width = 100;
//Adds new paragraph to the cell.
IWParagraph paragraph = tableCell.AddParagraph();
//Adds new text to the paragraph.
paragraph.AppendText("Content Control");
//Create the Row Content Control for the document.
RowContentControl control = new RowContentControl(document);
//Change the color value in Content Control properties.
control.ContentControlProperties.Color = System.Drawing.Color.Blue;
// Sets it to the row content control.
tableRow.ContentControl = control;
//Save the Word document.
document.Save("Sample.docx", FormatType.Docx);
//Close the document.
document.Close();
Dim document As New WordDocument()
'Adds new section to the document.
Dim section As IWSection = document.AddSection()
'Adds new table to the section.
Dim table As IWTable = section.AddTable()
'Adds new row to the table.
Dim tableRow As WTableRow = table.AddRow()
'Adds new cell to the row.
Dim tableCell As WTableCell = tableRow.AddCell()
tableCell.Width = 100
'Adds new paragraph to the cell.
Dim paragraph As IWParagraph = tableCell.AddParagraph()
'Adds new text to the paragraph.
paragraph.AppendText("Content Control")
'Create the Row Content Control for the document.
Dim control As New RowContentControl(document)
'Change the color value in Content Control properties.
control.ContentControlProperties.Color = System.Drawing.Color.Blue
' Sets it to the row content control.
tableRow.ContentControl = control
'Save the Word document.
document.Save("Sample.docx", FormatType.Docx)
'Close the document.
document.Close()
WordDocument document = new WordDocument();
//Adds new section to the document.
IWSection section = document.AddSection();
//Adds new table to the section.
IWTable table = section.AddTable();
//Adds new row to the table.
WTableRow tableRow = table.AddRow();
//Adds new cell to the row.
WTableCell tableCell = tableRow.AddCell();
tableCell.Width = 100;
//Adds new paragraph to the cell.
IWParagraph paragraph = tableCell.AddParagraph();
//Adds new text to the paragraph.
paragraph.AppendText("Content Control");
//Create the Row Content Control for the document.
RowContentControl control = new RowContentControl(document);
//Change the color value in Content Control properties.
control.ContentControlProperties.Color = System.Drawing.Color.Blue;
// Sets it to the row content control.
tableRow.ContentControl = control;
//Save the Word document.
document.Save("Sample.docx", FormatType.Docx);
//Close the document.
document.Close();
Dim document As New WordDocument()
'Adds new section to the document.
Dim section As IWSection = document.AddSection()
'Adds new table to the section.
Dim table As IWTable = section.AddTable()
'Adds new row to the table.
Dim tableRow As WTableRow = table.AddRow()
'Adds new cell to the row.
Dim tableCell As WTableCell = tableRow.AddCell()
tableCell.Width = 100
'Adds new paragraph to the cell.
Dim paragraph As IWParagraph = tableCell.AddParagraph()
'Adds new text to the paragraph.
paragraph.AppendText("Content Control")
'Create the Row Content Control for the document.
Dim control As New RowContentControl(document)
'Change the color value in Content Control properties.
control.ContentControlProperties.Color = System.Drawing.Color.Blue
' Sets it to the row content control.
tableRow.ContentControl = control
'Save the Word document.
document.Save("Sample.docx", FormatType.Docx)
'Close the document.
document.Close()
WordDocument document = new WordDocument();
//Adds new section to the document.
IWSection section = document.AddSection();
//Adds new table to the section.
IWTable table = section.AddTable();
//Adds new row to the table.
WTableRow tableRow = table.AddRow();
//Adds new cell to the row.
WTableCell tableCell = tableRow.AddCell();
tableCell.Width = 100;
//Adds new paragraph to the cell.
IWParagraph paragraph = tableCell.AddParagraph();
//Adds new text to the paragraph.
paragraph.AppendText("Content Control");
//Create the Cell Content Control for the document.
CellContentControl control = new CellContentControl(document);
//Change the color value in Content Control properties.
control.ContentControlProperties.Color = System.Drawing.Color.Green;
//Set it to the row content control.
tableCell.ContentControl = control;
//Save the Word document.
document.Save("Sample.docx", FormatType.Docx);
//Close the document.
document.Close();
Dim document As New WordDocument()
'Adds new section to the document.
Dim section As IWSection = document.AddSection()
'Adds new table to the section.
Dim table As IWTable = section.AddTable()
'Adds new row to the table.
Dim tableRow As WTableRow = table.AddRow()
'Adds new cell to the row.
Dim tableCell As WTableCell = tableRow.AddCell()
tableCell.Width = 100
'Adds new paragraph to the cell.
Dim paragraph As IWParagraph = tableCell.AddParagraph()
'Adds new text to the paragraph.
paragraph.AppendText("Content Control")
'Create the Cell Content Control for the document.
Dim control As New CellContentControl(document)
'Change the color value in Content Control properties.
control.ContentControlProperties.Color = System.Drawing.Color.Green
' Set it to the row content control.
tableCell.ContentControl = control
'Save the Word document.
document.Save("Sample.docx", FormatType.Docx)
'Close the document.
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Adds new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText);
//Adds new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Rich Text Content Control";
(paragraph.Items.LastItem as InlineContentControl).ParagraphItems.Add(textRange);
InlineContentControl richTextControl = paragraph.Items.LastItem as InlineContentControl;
richTextControl.ParagraphItems.Add(textRange);
// Sets Title property of the content control.
richTextControl.ContentControlProperties.Title = "Rich text content control";
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Adds new section to the document
Dim section As IWSection = document.AddSection()
'Adds new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Adds new rich text content control to the last paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText)
Dim textRange As New WTextRange(document)
textRange.Text = "Rich Text Content Control"
Dim richTextControl As InlineContentControl = section.LastParagraph.LastItem
richTextControl.ParagraphItems.Add(textRange)
'Sets Title property of the content control.
richTextControl.ContentControlProperties.Title = "Rich text content control"
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Adds new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText);
//Adds new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Rich Text Content Control";
(paragraph.Items.LastItem as InlineContentControl).ParagraphItems.Add(textRange);
InlineContentControl richTextControl = paragraph.Items.LastItem as InlineContentControl;
richTextControl.ParagraphItems.Add(textRange);
// Sets Title property of the content control.
richTextControl.ContentControlProperties.Title = "Rich text content control";
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Adds new section to the document
Dim section As IWSection = document.AddSection()
'Adds new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Adds new rich text content control to the last paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText)
Dim textRange As New WTextRange(document)
textRange.Text = "Rich Text Content Control"
Dim richTextControl As InlineContentControl = section.LastParagraph.LastItem
richTextControl.ParagraphItems.Add(textRange)
'Sets Title property of the content control.
richTextControl.ContentControlProperties.Title = "Rich text content control"
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Adds new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText);
//Adds new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Rich Text Content Control";
(paragraph.Items.LastItem as InlineContentControl).ParagraphItems.Add(textRange);
InlineContentControl richTextControl = paragraph.Items.LastItem as InlineContentControl;
richTextControl.ParagraphItems.Add(textRange);
// Sets Title property of the content control.
richTextControl.ContentControlProperties.Title = "Rich text content control";
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Adds new section to the document
Dim section As IWSection = document.AddSection()
'Adds new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Adds new rich text content control to the last paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText)
Dim textRange As New WTextRange(document)
textRange.Text = "Rich Text Content Control"
Dim richTextControl As InlineContentControl = section.LastParagraph.LastItem
richTextControl.ParagraphItems.Add(textRange)
'Sets Title property of the content control.
richTextControl.ContentControlProperties.Title = "Rich text content control"
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new drop down list content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.DropDownList);
//Add new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Drop down Content Control";
InlineContentControl dropDownList = paragraph.Items.LastItem as InlineContentControl;
dropDownList.ParagraphItems.Add(textRange);
ContentControlListItem item = new ContentControlListItem();
item.Value = "1";
item.DisplayText = "Ice cream";
dropDownList.ContentControlProperties.ContentControlListItems.Add(item);
item = new ContentControlListItem();
item.Value = "2";
item.DisplayText = "Cool drinks";
dropDownList.ContentControlProperties.ContentControlListItems.Add(item);
dropDownList.ContentControlProperties.Tag = "Drop down";
dropDownList.ContentControlProperties.Title = "Drop down list items";
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new drop down list content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.DropDownList)
'Add new text to the content control
Dim textRange As New WTextRange(document)
textRange.Text = "Drop down Content Control"
Dim dropDownList As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
Dim item As New ContentControlListItem()
dropDownList.ParagraphItems.Add(textRange);
item.Value = "1"
item.DisplayText = "Ice cream"
dropDownList.ContentControlProperties.ContentControlListItems.Add(item)
item = New ContentControlListItem()
item.Value = "2"
item.DisplayText = "Cool drinks"
dropDownList.ContentControlProperties.ContentControlListItems.Add(item)
dropDownList.ContentControlProperties.Tag = "Drop down"
dropDownList.ContentControlProperties.Title = "Drop down list items"
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new drop down list content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.DropDownList);
//Add new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Drop down Content Control";
InlineContentControl dropDownList = paragraph.Items.LastItem as InlineContentControl;
dropDownList.ParagraphItems.Add(textRange);
ContentControlListItem item = new ContentControlListItem();
item.Value = "1";
item.DisplayText = "Ice cream";
dropDownList.ContentControlProperties.ContentControlListItems.Add(item);
item = new ContentControlListItem();
item.Value = "2";
item.DisplayText = "Cool drinks";
dropDownList.ContentControlProperties.ContentControlListItems.Add(item);
dropDownList.ContentControlProperties.Tag = "Drop down";
dropDownList.ContentControlProperties.Title = "Drop down list items";
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new drop down list content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.DropDownList)
'Add new text to the content control
Dim textRange As New WTextRange(document)
textRange.Text = "Drop down Content Control"
Dim dropDownList As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
dropDownList.ParagraphItems.Add(textRange)
Dim item As New ContentControlListItem()
item.Value = "1"
item.DisplayText = "Ice cream"
dropDownList.ContentControlProperties.ContentControlListItems.Add(item)
item = New ContentControlListItem()
item.Value = "2"
item.DisplayText = "Cool drinks"
dropDownList.ContentControlProperties.ContentControlListItems.Add(item)
dropDownList.ContentControlProperties.Tag = "Drop down"
dropDownList.ContentControlProperties.Title = "Drop down list items"
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
WSection section = document.AddSection() as WSection;
//Add new combo box content control
BlockContentControl block = section.Body.AddBlockContentControl(ContentControlType.ComboBox) as BlockContentControl;
block.TextBody.AddParagraph();
block.TextBody.LastParagraph.AppendText("Block Content control");
ContentControlListItem item1 = new ContentControlListItem();
item1.DisplayText = "Animals";
item1.Value = "Animals";
ContentControlListItem item2 = new ContentControlListItem();
item2.DisplayText = "Fruits";
item2.Value = "Fruits";
block.ContentControlProperties.ContentControlListItems.Add(item1);
//Insert specific item to collection using index
block.ContentControlProperties.ContentControlListItems.Insert(1, item2);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As WSection = TryCast(document.AddSection(), WSection)
'Add new combo box content control
Dim block As BlockContentControl = TryCast(section.Body.AddBlockContentControl(ContentControlType.ComboBox), BlockContentControl)
block.TextBody.AddParagraph();
block.TextBody.LastParagraph.AppendText("Block Content control")
Dim item1 As New ContentControlListItem()
item1.DisplayText = "Animals"
item1.Value = "Animals"
Dim item2 As New ContentControlListItem()
item2.DisplayText = "Fruits"
item2.Value = "Fruits"
block.ContentControlProperties.ContentControlListItems.Add(item1)
'Insert specific item to collection using index
block.ContentControlProperties.ContentControlListItems.Insert(1, item2)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
WSection section = document.AddSection() as WSection;
//Add new combo box content control
BlockContentControl block = section.Body.AddBlockContentControl(ContentControlType.ComboBox) as BlockContentControl;
block.TextBody.AddParagraph();
block.TextBody.LastParagraph.AppendText("Block Content control");
ContentControlListItem item1 = new ContentControlListItem();
item1.DisplayText = "Animals";
item1.Value = "Animals";
ContentControlListItem item2 = new ContentControlListItem();
item2.DisplayText = "Fruits";
item2.Value = "Fruits";
block.ContentControlProperties.ContentControlListItems.Add(item1);
block.ContentControlProperties.ContentControlListItems.Add(item2);
//Remove specific item from collection
block.ContentControlProperties.ContentControlListItems.Remove(item1);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As WSection = TryCast(document.AddSection(), WSection)
'Add new combo box content control
Dim block As BlockContentControl = TryCast(section.Body.AddBlockContentControl(ContentControlType.ComboBox), BlockContentControl)
block.TextBody.AddParagraph()
block.TextBody.LastParagraph.AppendText("Block Content control")
Dim item1 As New ContentControlListItem()
item1.DisplayText = "Animals"
item1.Value = "Animals"
Dim item2 As New ContentControlListItem()
item2.DisplayText = "Fruits"
item2.Value = "Fruits"
block.ContentControlProperties.ContentControlListItems.Add(item1)
block.ContentControlProperties.ContentControlListItems.Add(item2)
'Remove specific item from collection
block.ContentControlProperties.ContentControlListItems.Remove(item1)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
WSection section = document.AddSection() as WSection;
//Add new combo box content control
BlockContentControl block = section.Body.AddBlockContentControl(ContentControlType.ComboBox) as BlockContentControl;
block.TextBody.AddParagraph();
block.TextBody.LastParagraph.AppendText("Block Content control");
ContentControlListItem item1 = new ContentControlListItem();
item1.DisplayText = "Animals";
item1.Value = "Animals";
ContentControlListItem item2 = new ContentControlListItem();
item2.DisplayText = "Fruits";
item2.Value = "Fruits";
block.ContentControlProperties.ContentControlListItems.Add(item1);
block.ContentControlProperties.ContentControlListItems.Add(item2);
//Remove specific item from collection
block.ContentControlProperties.ContentControlListItems.RemoveAt(0);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As WSection = TryCast(document.AddSection(), WSection)
'Add new combo box content control
Dim block As BlockContentControl = TryCast(section.Body.AddBlockContentControl(ContentControlType.ComboBox), BlockContentControl)
block.TextBody.AddParagraph()
block.TextBody.LastParagraph.AppendText("Block Content control");
Dim item1 As New ContentControlListItem()
item1.DisplayText = "Animals"
item1.Value = "Animals"
Dim item2 As New ContentControlListItem()
item2.DisplayText = "Fruits"
item2.Value = "Fruits"
block.ContentControlProperties.ContentControlListItems.Add(item1)
block.ContentControlProperties.ContentControlListItems.Add(item2)
'Remove specific item from collection
block.ContentControlProperties.ContentControlListItems.RemoveAt(0)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
WSection section = document.AddSection() as WSection;
//Add new combo box content control
BlockContentControl block = section.Body.AddBlockContentControl(ContentControlType.ComboBox) as BlockContentControl;
block.TextBody.AddParagraph();
block.TextBody.LastParagraph.AppendText("Block Content control");
ContentControlListItem item1 = new ContentControlListItem();
item1.DisplayText = "Animals";
item1.Value = "Animals";
ContentControlListItem item2 = new ContentControlListItem();
block.ContentControlProperties.ContentControlListItems.Add(item1);
//Insert specific item to collection using index
block.ContentControlProperties.ContentControlListItems.Insert(1, item2);
//Get the ContentControlListItem from the collection
block.ContentControlProperties.ContentControlListItems[1].DisplayText = "Fruits";
block.ContentControlProperties.ContentControlListItems[1].Value = "Fruits";
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As WSection = TryCast(document.AddSection(), WSection)
'Add new combo box content control
Dim block As BlockContentControl = TryCast(section.Body.AddBlockContentControl(ContentControlType.ComboBox), BlockContentControl)
block.TextBody.AddParagraph()
block.TextBody.LastParagraph.AppendText("Block Content control")
Dim item1 As New ContentControlListItem()
item1.DisplayText = "Animals"
item1.Value = "Animals"
Dim item2 As New ContentControlListItem()
block.ContentControlProperties.ContentControlListItems.Add(item1)
'Insert specific item to collection using index
block.ContentControlProperties.ContentControlListItems.Insert(1, item2);
'Get the ContentControlListItem from the collection
block.ContentControlProperties.ContentControlListItems(1).DisplayText = "Fruits"
block.ContentControlProperties.ContentControlListItems(1).Value = "Fruits"
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
WSection section = document.AddSection() as WSection;
//Add new combo box content control
BlockContentControl block = section.Body.AddBlockContentControl(ContentControlType.ComboBox) as BlockContentControl;
block.TextBody.AddParagraph();
block.TextBody.LastParagraph.AppendText("Block Content control");
ContentControlListItem item1 = new ContentControlListItem();
item1.DisplayText = "Animals";
item1.Value = "Animals";
ContentControlListItem item2 = new ContentControlListItem();
item2.DisplayText = "Fruits";
item2.Value = "Fruits";
block.ContentControlProperties.ContentControlListItems.Add(item1);
block.ContentControlProperties.ContentControlListItems.Add(item2);
//Get the count of content control list items
int count = block.ContentControlProperties.ContentControlListItems.Count;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As WSection = TryCast(document.AddSection(), WSection)
'Add new combo box content control
Dim block As BlockContentControl = TryCast(section.Body.AddBlockContentControl(ContentControlType.ComboBox), BlockContentControl)
block.TextBody.AddParagraph()
block.TextBody.LastParagraph.AppendText("Block Content control")
Dim item1 As New ContentControlListItem()
item1.DisplayText = "Animals"
item1.Value = "Animals"
Dim item2 As New ContentControlListItem()
item2.DisplayText = "Fruits"
item2.Value = "Fruits"
block.ContentControlProperties.ContentControlListItems.Add(item1)
block.ContentControlProperties.ContentControlListItems.Add(item2)
'Get the count of content control list items
Dim count As Integer = block.ContentControlProperties.ContentControlListItems.Count
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new drop down list content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.DropDownList);
//Add new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Drop down Content Control";
InlineContentControl dropDownList = paragraph.Items.LastItem as InlineContentControl;
dropDownList.ParagraphItems.Add(textRange);
ContentControlListItem item = new ContentControlListItem();
item.Value = "1";
item.DisplayText = "Ice cream";
dropDownList.ContentControlProperties.ContentControlListItems.Add(item);
item = new ContentControlListItem();
item.Value = "2";
item.DisplayText = "Cool drinks";
dropDownList.ContentControlProperties.ContentControlListItems.Add(item);
dropDownList.ContentControlProperties.Tag = "Drop down";
dropDownList.ContentControlProperties.Title = "Drop down list items";
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new drop down list content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.DropDownList)
'Add new text to the content control
Dim textRange As New WTextRange(document)
textRange.Text = "Drop down Content Control"
Dim dropDownList As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
Dim item As New ContentControlListItem()
dropDownList.ParagraphItems.Add(textRange)
item.Value = "1"
item.DisplayText = "Ice cream"
dropDownList.ContentControlProperties.ContentControlListItems.Add(item)
item = New ContentControlListItem()
item.Value = "2"
item.DisplayText = "Cool drinks"
dropDownList.ContentControlProperties.ContentControlListItems.Add(item)
dropDownList.ContentControlProperties.Tag = "Drop down"
dropDownList.ContentControlProperties.Title = "Drop down list items"
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new drop down list content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.DropDownList);
//Add new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Drop down Content Control";
InlineContentControl dropDownList = paragraph.Items.LastItem as InlineContentControl;
//richTextControl.ParagraphItems.Add(textRange);
ContentControlListItem item = new ContentControlListItem();
item.Value = "1";
item.DisplayText = "Ice cream";
dropDownList.ContentControlProperties.ContentControlListItems.Add(item);
item = new ContentControlListItem();
item.Value = "2";
item.DisplayText = "Cool drinks";
dropDownList.ContentControlProperties.ContentControlListItems.Add(item);
dropDownList.ContentControlProperties.Tag = "Drop down";
dropDownList.ContentControlProperties.Title = "Drop down list items";
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new drop down list content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.DropDownList)
'Add new text to the content control
Dim textRange As New WTextRange(document)
textRange.Text = "Drop down Content Control"
Dim dropDownList As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
'richTextControl.ParagraphItems.Add(textRange);
Dim item As New ContentControlListItem()
item.Value = "1"
item.DisplayText = "Ice cream"
dropDownList.ContentControlProperties.ContentControlListItems.Add(item)
item = New ContentControlListItem()
item.Value = "2"
item.DisplayText = "Cool drinks"
dropDownList.ContentControlProperties.ContentControlListItems.Add(item)
dropDownList.ContentControlProperties.Tag = "Drop down"
dropDownList.ContentControlProperties.Title = "Drop down list items"
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new drop down list content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.DropDownList);
//Add new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Drop down Content Control";
InlineContentControl dropDownList = paragraph.Items.LastItem as InlineContentControl;
ContentControlListItem item = new ContentControlListItem();
item.Value = "1";
item.DisplayText = "Ice cream";
dropDownList.ContentControlProperties.ContentControlListItems.Add(item);
item = new ContentControlListItem();
item.Value = "2";
item.DisplayText = "Cool drinks";
dropDownList.ContentControlProperties.ContentControlListItems.Add(item);
dropDownList.ContentControlProperties.Tag = "Drop down";
dropDownList.ContentControlProperties.Title = "Drop down list items";
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new drop down list content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.DropDownList)
'Add new text to the content control
Dim textRange As New WTextRange(document)
textRange.Text = "Drop down Content Control"
Dim dropDownList As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
Dim item As New ContentControlListItem()
item.Value = "1"
item.DisplayText = "Ice cream"
dropDownList.ContentControlProperties.ContentControlListItems.Add(item)
item = New ContentControlListItem()
item.Value = "2"
item.DisplayText = "Cool drinks"
dropDownList.ContentControlProperties.ContentControlListItems.Add(item)
dropDownList.ContentControlProperties.Tag = "Drop down"
dropDownList.ContentControlProperties.Title = "Drop down list items"
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText);
//Add new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Rich Text Content Control";
(paragraph.Items.LastItem as InlineContentControl).ParagraphItems.Add(textRange);
InlineContentControl richTextControl = paragraph.Items.LastItem as InlineContentControl;
richTextControl.ParagraphItems.Add(textRange);
richTextControl.ContentControlProperties.Appearance = ContentControlAppearance.Tags;
richTextControl.ContentControlProperties.Color = Color.Gray;
richTextControl.ContentControlProperties.LockContentControl = true;
richTextControl.ContentControlProperties.Tag = "RichText";
richTextControl.ContentControlProperties.Title = "Rich text content control";
//Add new text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Text);
//Add new text to the content control
WTextRange textRange1 = new WTextRange(document);
textRange1.Text = "Text Content Control";
(paragraph.Items.LastItem as InlineContentControl).ParagraphItems.Add(textRange1);
InlineContentControl textControl = paragraph.Items.LastItem as InlineContentControl;
textControl.ParagraphItems.Add(textRange1);
textControl.ContentControlProperties.Appearance = ContentControlAppearance.Tags;
textControl.ContentControlProperties.Color = Color.Gray;
textControl.ContentControlProperties.LockContentControl = true;
textControl.ContentControlProperties.LockContents = true;
textControl.ContentControlProperties.Multiline = true;
textControl.ContentControlProperties.Tag = "Text";
textControl.ContentControlProperties.Title = "Text content control";
//Add new date content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Date);
//Add new text to the content control
WTextRange textRange2 = new WTextRange(document);
textRange2.Text = "Date Content Control";
(paragraph.Items.LastItem as InlineContentControl).ParagraphItems.Add(textRange2);
InlineContentControl dateControl = paragraph.Items.LastItem as InlineContentControl;
dateControl.ParagraphItems.Add(textRange2);
dateControl.ContentControlProperties.Appearance = ContentControlAppearance.Tags;
dateControl.ContentControlProperties.DateCalendarType = CalendarType.GregorianArabic;
dateControl.ContentControlProperties.DateDisplayFormat = "dd yy MMMM";
dateControl.ContentControlProperties.DateDisplayLocale = LocaleIDs.en_US;
dateControl.ContentControlProperties.DateStorageFormat = ContentControlDateStorageFormat.DateStorageDate;
dateControl.ContentControlProperties.Tag = "Date control";
dateControl.ContentControlProperties.Title = "Date content control";
//Add new drop down list content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.DropDownList);
//Add new text to the content control
WTextRange textRange3 = new WTextRange(document);
textRange3.Text = "Drop down Content Control";
InlineContentControl dropDownList = paragraph.Items.LastItem as InlineContentControl;
//richTextControl.ParagraphItems.Add(textRange);
ContentControlListItem item = new ContentControlListItem();
item.Value = "1";
item.DisplayText = "Ice cream";
dropDownList.ContentControlProperties.ContentControlListItems.Add(item);
item = new ContentControlListItem();
item.Value = "2";
item.DisplayText = "Cool drinks";
dropDownList.ContentControlProperties.ContentControlListItems.Add(item);
dropDownList.ContentControlProperties.Tag = "Drop down";
dropDownList.ContentControlProperties.Title = "Drop down list items";
//Add new picture content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Picture);
Image image = Image.FromFile("Image.png");
IWPicture picture = new WPicture(document);
picture.LoadImage(image);
picture.Height = 100;
picture.Width = 100;
InlineContentControl pictureControl = paragraph.Items.LastItem as InlineContentControl;
pictureControl.ParagraphItems.Add(picture);
pictureControl.ContentControlProperties.Tag = "Picture control";
pictureControl.ContentControlProperties.Title = "picture control";
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText)
'Add new text to the content control
Dim textRange As New WTextRange(document)
textRange.Text = "Rich Text Content Control"
TryCast(paragraph.Items.LastItem, InlineContentControl).ParagraphItems.Add(textRange)
Dim richTextControl As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
richTextControl.ParagraphItems.Add(textRange)
richTextControl.ContentControlProperties.Appearance = ContentControlAppearance.Tags
richTextControl.ContentControlProperties.Color = Color.Gray
richTextControl.ContentControlProperties.LockContentControl = True
richTextControl.ContentControlProperties.Tag = "RichText"
richTextControl.ContentControlProperties.Title = "Rich text content control"
'Add new text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Text)
'Add new text to the content control
Dim textRange1 As New WTextRange(document)
textRange1.Text = "Text Content Control"
TryCast(paragraph.Items.LastItem, InlineContentControl).ParagraphItems.Add(textRange1)
Dim textControl As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
textControl.ParagraphItems.Add(textRange1)
textControl.ContentControlProperties.Appearance = ContentControlAppearance.Tags
textControl.ContentControlProperties.Color = Color.Gray
textControl.ContentControlProperties.LockContentControl = True
textControl.ContentControlProperties.LockContents = True
textControl.ContentControlProperties.Multiline = True
textControl.ContentControlProperties.Tag = "Text"
textControl.ContentControlProperties.Title = "Text content control"
'Add new date content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.[Date])
'Add new text to the content control
Dim textRange2 As New WTextRange(document)
textRange2.Text = "Date Content Control"
TryCast(paragraph.Items.LastItem, InlineContentControl).ParagraphItems.Add(textRange2)
Dim dateControl As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
dateControl.ParagraphItems.Add(textRange2)
dateControl.ContentControlProperties.Appearance = ContentControlAppearance.Tags
dateControl.ContentControlProperties.DateCalendarType = CalendarType.GregorianArabic
dateControl.ContentControlProperties.DateDisplayFormat = "dd yy MMMM"
dateControl.ContentControlProperties.DateDisplayLocale = LocaleIDs.en_US
dateControl.ContentControlProperties.DateStorageFormat = ContentControlDateStorageFormat.DateStorageDate
dateControl.ContentControlProperties.Tag = "Date control"
dateControl.ContentControlProperties.Title = "Date content control"
'Add new drop down list content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.DropDownList)
'Add new text to the content control
Dim textRange3 As New WTextRange(document)
textRange3.Text = "Drop down Content Control"
Dim dropDownList As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
'richTextControl.ParagraphItems.Add(textRange);
Dim item As New ContentControlListItem()
item.Value = "1"
item.DisplayText = "Ice cream"
dropDownList.ContentControlProperties.ContentControlListItems.Add(item)
item = New ContentControlListItem()
item.Value = "2"
item.DisplayText = "Cool drinks"
dropDownList.ContentControlProperties.ContentControlListItems.Add(item)
dropDownList.ContentControlProperties.Tag = "Drop down"
dropDownList.ContentControlProperties.Title = "Drop down list items"
'Add new picture content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Picture)
Dim image As Image = image.FromFile("Image.png")
Dim picture As IWPicture = New WPicture(document)
picture.LoadImage(image)
picture.Height = 100
picture.Width = 100
Dim pictureControl As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
pictureControl.ParagraphItems.Add(picture)
pictureControl.ContentControlProperties.Tag = "Picture control"
pictureControl.ContentControlProperties.Title = "picture control"
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new date picker content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Date);
InlineContentControl datePicker = paragraph.Items.LastItem as InlineContentControl;
WTextRange textRange = new WTextRange(document);
//Sets today's date to display.
textRange.Text = DateTime.Now.ToShortDateString();
datePicker.ParagraphItems.Add(textRange);
//Sets format for date to display.
datePicker.ContentControlProperties.DateDisplayFormat = "M/d/yyyy";
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new date picker content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.[Date])
Dim datePicker As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
Dim textRange As New WTextRange(document)
'Sets today's date to display.
textRange.Text = DateTime.Now.ToShortDateString()
datePicker.ParagraphItems.Add(textRange)
datePicker.ContentControlProperties.DateDisplayFormat = "M/d/yyyy"
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new date picker content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Date);
InlineContentControl datePicker = paragraph.Items.LastItem as InlineContentControl;
WTextRange textRange = new WTextRange(document);
//Sets today's date to display.
textRange.Text = DateTime.Now.ToShortDateString();
datePicker.ParagraphItems.Add(textRange);
//Sets the language format for the date.
datePicker.ContentControlProperties.DateDisplayLocale = LocaleIDs.en_US;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new date picker content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.[Date])
Dim datePicker As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
Dim textRange As New WTextRange(document)
'Sets today's date to display.
textRange.Text = DateTime.Now.ToShortDateString()
datePicker.ParagraphItems.Add(textRange)
'Sets the language format for the date.
datePicker.ContentControlProperties.DateDisplayLocale = LocaleIDs.en_US
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new date picker content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Date);
InlineContentControl datePicker = paragraph.Items.LastItem as InlineContentControl;
WTextRange textRange = new WTextRange(document);
//Sets today's date to display.
textRange.Text = DateTime.Now.ToShortDateString();
datePicker.ParagraphItems.Add(textRange);
//Sets the storage and retrieval format for the date.
datePicker.ContentControlProperties.DateStorageFormat = ContentControlDateStorageFormat.DateStorageDate;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new date picker content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.[Date])
Dim datePicker As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
Dim textRange As New WTextRange(document)
'Sets today's date to display.
textRange.Text = DateTime.Now.ToShortDateString()
datePicker.ParagraphItems.Add(textRange)
'Sets the storage and retrieval format for the date.
datePicker.ContentControlProperties.DateStorageFormat = ContentControlDateStorageFormat.DateStorageDate;
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new date picker content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Date);
InlineContentControl datePicker = paragraph.Items.LastItem as InlineContentControl;
WTextRange textRange = new WTextRange(document);
//Sets today's date to display.
textRange.Text = DateTime.Now.ToShortDateString();
datePicker.ParagraphItems.Add(textRange);
//Sets calendar type for the date picker control.
datePicker.ContentControlProperties.DateCalendarType = CalendarType.Gregorian;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new date picker content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.[Date])
Dim datePicker As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
Dim textRange As New WTextRange(document)
'Sets today's date to display.
textRange.Text = DateTime.Now.ToShortDateString()
datePicker.ParagraphItems.Add(textRange)
'Sets calendar type for the date picker control.
datePicker.ContentControlProperties.DateCalendarType = CalendarType.Gregorian
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText);
//Add new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Rich Text Content Control";
(paragraph.Items.LastItem as InlineContentControl).ParagraphItems.Add(textRange);
InlineContentControl richTextControl = paragraph.Items.LastItem as InlineContentControl;
richTextControl.ParagraphItems.Add(textRange);
// Enables content control lock.
richTextControl.ContentControlProperties.LockContentControl = true;
//Add new text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Text);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText)
'Add new text to the content control
Dim textRange As New WTextRange(document)
textRange.Text = "Rich Text Content Control"
TryCast(paragraph.Items.LastItem, InlineContentControl).ParagraphItems.Add(textRange)
Dim richTextControl As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
richTextControl.ParagraphItems.Add(textRange)
'Enables content control lock.
richTextControl.ContentControlProperties.LockContentControl = True
'Add new text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Text)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new rich text content control to the paragraph.
paragraph.AppendInlineContentControl(ContentControlType.RichText);
InlineContentControl richTextControl = paragraph.Items.LastItem as InlineContentControl;
//Add new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Rich Text Content Control";
richTextControl.ParagraphItems.Add(textRange);
//Protects the content control.
richTextControl.ContentControlProperties.LockContents = true;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new rich text content control to the paragraph.
paragraph.AppendInlineContentControl(ContentControlType.RichText)
Dim richTextControl As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
'Add new text to the content control
Dim textRange As New WTextRange(document)
textRange.Text = "Rich Text Content Control"
richTextControl.ParagraphItems.Add(textRange)
'Protects the content control.
richTextControl.ContentControlProperties.LockContents = True
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new plain text content control to the paragraph.
paragraph.AppendInlineContentControl(ContentControlType.Text);
InlineContentControl plainTextControl = paragraph.Items.LastItem as InlineContentControl;
//Enables multiline for plain text control.
plainTextControl.ContentControlProperties.Multiline = true;
//Add new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Plain Text Content Control";
plainTextControl.ParagraphItems.Add(textRange);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new plain text content control to the paragraph.
paragraph.AppendInlineContentControl(ContentControlType.Text)
Dim plainTextControl As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
'Enables multiline for plain text control.
plainTextControl.ContentControlProperties.Multiline = True
'Add new text to the content control
Dim textRange As New WTextRange(document)
textRange.Text = "Plain Text Content Control"
plainTextControl.ParagraphItems.Add(textRange)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText);
//Add new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Rich Text Content Control";
(paragraph.Items.LastItem as InlineContentControl).ParagraphItems.Add(textRange);
InlineContentControl richTextControl = paragraph.Items.LastItem as InlineContentControl;
richTextControl.ParagraphItems.Add(textRange);
//Sets Tag appearance for the content control.
richTextControl.ContentControlProperties.Appearance = ContentControlAppearance.Tags;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText)
'Add new text to the content control
Dim textRange As New WTextRange(document)
textRange.Text = "Rich Text Content Control"
TryCast(paragraph.Items.LastItem, InlineContentControl).ParagraphItems.Add(textRange)
Dim richTextControl As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
richTextControl.ParagraphItems.Add(textRange)
'Sets Tag appearance for the content control.
richTextControl.ContentControlProperties.Appearance = ContentControlAppearance.Tags
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText);
//Add new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Rich Text Content Control";
(paragraph.Items.LastItem as InlineContentControl).ParagraphItems.Add(textRange);
InlineContentControl richTextControl = paragraph.Items.LastItem as InlineContentControl;
richTextControl.ParagraphItems.Add(textRange);
// Sets the Color property of content control.
richTextControl.ContentControlProperties.Color = Color.Blue;
//Add new text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Text);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText)
'Add new text to the content control
Dim textRange As New WTextRange(document)
textRange.Text = "Rich Text Content Control"
TryCast(paragraph.Items.LastItem, InlineContentControl).ParagraphItems.Add(textRange)
Dim richTextControl As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
richTextControl.ParagraphItems.Add(textRange)
'Sets the Color property of content control.
richTextControl.ContentControlProperties.Color = Color.Blue
'Add new text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Text)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText);
//Add new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Rich Text Content Control";
(paragraph.Items.LastItem as InlineContentControl).ParagraphItems.Add(textRange);
InlineContentControl richTextControl = paragraph.Items.LastItem as InlineContentControl;
richTextControl.ParagraphItems.Add(textRange);
// Sets Title property of the content control.
richTextControl.ContentControlProperties.Title = "Rich text content control";
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText)
'Add new text to the content control
Dim textRange As New WTextRange(document)
textRange.Text = "Rich Text Content Control"
TryCast(paragraph.Items.LastItem, InlineContentControl).ParagraphItems.Add(textRange)
Dim richTextControl As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
richTextControl.ParagraphItems.Add(textRange)
'Sets Title property of the content control.
richTextControl.ContentControlProperties.Title = "Rich text content control"
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new drop down list content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.DropDownList);
InlineContentControl dropDownList = paragraph.Items.LastItem as InlineContentControl;
//Set default option in drop down list.
WTextRange textRange = new WTextRange(document);
textRange.Text = "Choose an item";
dropDownList.ParagraphItems.Add(textRange);
//Add item into drop down list.
ContentControlListItem item = new ContentControlListItem();
item.Value = "1";
item.DisplayText = "DocIO";
//Add item into collection of drop down list items.
dropDownList.ContentControlProperties.ContentControlListItems.Add(item);
//Add item into drop down list.
item = new ContentControlListItem();
item.Value = "2";
item.DisplayText = "PDF";
//Add item into collection of drop down list items.
dropDownList.ContentControlProperties.ContentControlListItems.Add(item);
//Add combo box control.
IInlineContentControl comboboxControl = paragraph.AppendInlineContentControl(ContentControlType.ComboBox);
//Set default option in Combo box.
textRange = new WTextRange(document);
textRange.Text = "Choose an item";
comboboxControl.ParagraphItems.Add(textRange);
//Add item into combo box list.
item = new ContentControlListItem();
item.Value = "1";
item.DisplayText = "Windows";
//Add item into collection of combo box list items.
comboboxControl.ContentControlProperties.ContentControlListItems.Add(item);
//Add another item into combo box list.
item = new ContentControlListItem();
item.Value = "2";
item.DisplayText = "Xamarin";
//Add item into collection of combo box list items.
comboboxControl.ContentControlProperties.ContentControlListItems.Add(item);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new drop down list content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.DropDownList)
Dim dropDownList As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
'Set default option in drop down list.
Dim textRange As New WTextRange(document)
textRange.Text = "Choose an item"
dropDownList.ParagraphItems.Add(textRange)
'Add item into drop down list.
Dim item As New ContentControlListItem()
item.Value = "1"
item.DisplayText = "DocIO"
'Add item into collection of drop down list items.
dropDownList.ContentControlProperties.ContentControlListItems.Add(item)
'Add item into drop down list.
item = New ContentControlListItem()
item.Value = "2"
item.DisplayText = "PDF"
'Add item into collection of drop down list items.
dropDownList.ContentControlProperties.ContentControlListItems.Add(item)
'Add combo box control.
Dim comboboxControl As IInlineContentControl = paragraph.AppendInlineContentControl(ContentControlType.ComboBox)
'Set default option in Combo box.
textRange = New WTextRange(document)
textRange.Text = "Choose an item"
comboboxControl.ParagraphItems.Add(textRange)
'Add item into combo box list.
item = New ContentControlListItem()
item.Value = "1"
item.DisplayText = "Windows"
'Add item into collection of combo box list items.
comboboxControl.ContentControlProperties.ContentControlListItems.Add(item)
'Add another item into combo box list.
item = New ContentControlListItem()
item.Value = "2"
item.DisplayText = "Xamarin"
'Add item into collection of combo box list items.
comboboxControl.ContentControlProperties.ContentControlListItems.Add(item)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("Plain Text");
//Add new plain text content control to the paragraph.
paragraph.AppendInlineContentControl(ContentControlType.Text);
InlineContentControl inlineContentControl = paragraph.Items.LastItem as InlineContentControl;
//Gets the type of content control.
ContentControlType controlType = inlineContentControl.ContentControlProperties.Type;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("Plain Text")
'Add new plain text content control to the paragraph.
paragraph.AppendInlineContentControl(ContentControlType.Text)
Dim inlineContentControl As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
'Gets the type of content control.
Dim controlType As ContentControlType = inlineContentControl.ContentControlProperties.Type
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText);
//Add new text to the content control
WTextRange textRange = new WTextRange(document);
textRange.Text = "Rich Text Content Control";
(paragraph.Items.LastItem as InlineContentControl).ParagraphItems.Add(textRange);
InlineContentControl richTextControl = paragraph.Items.LastItem as InlineContentControl;
richTextControl.ParagraphItems.Add(textRange);
// Sets Tag property of the content control.
richTextControl.ContentControlProperties.Tag = "RichText";
//Add new text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Text);
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new rich text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.RichText)
'Add new text to the content control
Dim textRange As New WTextRange(document)
textRange.Text = "Rich Text Content Control"
TryCast(paragraph.Items.LastItem, InlineContentControl).ParagraphItems.Add(textRange)
Dim richTextControl As InlineContentControl = TryCast(paragraph.Items.LastItem, InlineContentControl)
richTextControl.ParagraphItems.Add(textRange)
'Sets Tag property of the content control.
richTextControl.ContentControlProperties.Tag = "RichText"
'Add new text content control to the paragraph
paragraph.AppendInlineContentControl(ContentControlType.Text)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
//Create a new Word document
WordDocument document = new WordDocument();
//Add one section and one paragraph to the document
document.EnsureMinimal();
//Get the last paragraph.
WParagraph paragraph = document.LastParagraph;
//Add text to the paragraph
paragraph.AppendText("A new text is added to the paragraph. ");
//Append checkbox content control to the paragraph
InlineContentControl checkBox = paragraph.AppendInlineContentControl(ContentControlType.CheckBox) as InlineContentControl;
//Get checked state of checkbox
CheckBoxState checkBoxCheckedState = checkBox.ContentControlProperties.CheckedState;
//Set font for checked state value
checkBoxCheckedState.Font = "Calibri";
//Set symbol for checked state value
checkBoxCheckedState.Value = "C";
//Get unchecked state of checkbox
CheckBoxState checkBoxUncheckedState = checkBox.ContentControlProperties.UncheckedState;
//Set font for unchecked state value
checkBoxUncheckedState.Font = "Calibri";
//Set symbol for unchecked state value
checkBoxUncheckedState.Value = "U";
//Set the state for checkbox
checkBox.ContentControlProperties.IsChecked = true;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
'Create a new Word document
Dim document As WordDocument = New WordDocument
'Add one section and one paragraph to the document
document.EnsureMinimal
'Get the last paragraph.
Dim paragraph As WParagraph = document.LastParagraph
'Add text to the paragraph
paragraph.AppendText("A new text is added to the paragraph. ")
'Append checkbox content control to the paragraph
Dim checkBox As InlineContentControl = CType(paragraph.AppendInlineContentControl(ContentControlType.CheckBox), InlineContentControl)
'Get checked state of checkbox
Dim checkBoxCheckedState As CheckBoxState = checkBox.ContentControlProperties.CheckedState
'Set font for checked state value
checkBoxCheckedState.Font = "Calibri"
'Set symbol for checked state value
checkBoxCheckedState.Value = "C"
'Get unchecked state of checkbox
Dim checkBoxUncheckedState As CheckBoxState = checkBox.ContentControlProperties.UncheckedState
'Set font for unchecked state value
checkBoxUncheckedState.Font = "Calibri"
'Set symbol for unchecked state value
checkBoxUncheckedState.Value = "U"
'Set the state for checkbox
checkBox.ContentControlProperties.IsChecked = true
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add new XmlPart to the section
CustomXMLPart xmlPart = new CustomXMLPart(document);
//Load the xml code.
xmlPart.Load(@"F:\XmlFile.xml");
//Add new content control to the paragraph.
InlineContentControl control = paragraph.AppendInlineContentControl(ContentControlType.Text) as InlineContentControl;
control.ContentControlProperties.XmlMapping.SetMapping("/books/book/author", "", xmlPart);
//Select the single node.
CustomXMLNode node = xmlPart.SelectSingleNode(control.ContentControlProperties.XmlMapping.XPath);
//Append text to second paragraph.
control = paragraph.AppendInlineContentControl(ContentControlType.Text) as InlineContentControl;
//Save the Word document
document.Save("Sample.docx", FormatType.Docx);
//Close the document
document.Close();
Dim document As New WordDocument()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add new XmlPart to the section
Dim xmlPart As New CustomXMLPart(document)
'Load the xml code.
xmlPart.Load(@"F:\XmlFile.xml");
'Append text to second paragraph.
control = TryCast(paragraph.AppendInlineContentControl(ContentControlType.Text), InlineContentControl)
'Save the Word document
document.Save("Sample.docx", FormatType.Docx)
'Close the document
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Create a new list numbered list style
ListStyle listStyle = new ListStyle(document, ListType.Numbered);
//Set the name for the new list style
listStyle.Name = "UserdefinedList";
WListLevel levelOne = listStyle.Levels[0];
//Define the follow character, prefix, suffix, start index for level 0
levelOne.FollowCharacter = FollowCharacterType.Tab;
levelOne.NumberPrefix = "(";
levelOne.NumberSufix = ")";
levelOne.PatternType = ListPatternType.LowRoman;
levelOne.StartAt = 1;
levelOne.TabSpaceAfter = 5;
levelOne.NumberAlignment = ListNumberAlignment.Center;
document.ListStyles.Add(listStyle);
//Add new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Add text to the paragraph
paragraph.AppendText("The list of pets available:");
//Add other paragraphs and apply the created new list style
paragraph = section.AddParagraph();
//Apply default numbered list style
paragraph.ListFormat.ApplyStyle("UserdefinedList");
paragraph.AppendText("Dog");
paragraph = section.AddParagraph();
paragraph.ListFormat.ApplyStyle("UserdefinedList");
paragraph.AppendText("Cat");
//Continue last defined list
paragraph.ListFormat.ContinueListNumbering();
paragraph = section.AddParagraph();
paragraph.ListFormat.ApplyStyle("UserdefinedList");
paragraph.AppendText("Hamsters");
paragraph.ListFormat.ContinueListNumbering();
paragraph.ListFormat.ApplyStyle("UserdefinedList");
paragraph.AppendText("Turtles");
paragraph.ListFormat.ContinueListNumbering();
paragraph = section.AddParagraph();
paragraph.ListFormat.ApplyStyle("UserdefinedList");
paragraph.AppendText("Guinea Pigs");
paragraph.ListFormat.ContinueListNumbering();
paragraph = section.AddParagraph();
paragraph.ListFormat.ApplyStyle("UserdefinedList");
paragraph.AppendText("Ferrets");
paragraph.ListFormat.ContinueListNumbering();
paragraph = section.AddParagraph();
paragraph.ListFormat.ApplyStyle("UserdefinedList");
paragraph.AppendText("Fish");
paragraph.ListFormat.ContinueListNumbering();
//Save and close the Word 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()
'Add new section to the document
Dim section As IWSection = document.AddSection()
'Create a new list numbered list style
Dim listStyle As New ListStyle(document, ListType.Numbered)
'Set the name for the new list style
listStyle.Name = "UserdefinedList"
Dim levelOne As WListLevel = listStyle.Levels(0)
'Define the follow character, prefix, suffix, start index for level 0
levelOne.FollowCharacter = FollowCharacterType.Tab
levelOne.NumberPrefix = "("
levelOne.NumberSufix = ")"
levelOne.PatternType = ListPatternType.LowRoman
levelOne.StartAt = 1
levelOne.TabSpaceAfter = 5
levelOne.NumberAlignment = ListNumberAlignment.Center
document.ListStyles.Add(listStyle)
'Add new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Add text to the paragraph
paragraph.AppendText("The list of pets available:")
'Add other paragraphs and apply the created new list style
paragraph = section.AddParagraph()
'Apply default numbered list style
paragraph.ListFormat.ApplyStyle("UserdefinedList")
paragraph.AppendText("Dog")
paragraph = section.AddParagraph()
paragraph.ListFormat.ApplyStyle("UserdefinedList")
paragraph.AppendText("Cat")
'Continue last defined list
paragraph.ListFormat.ContinueListNumbering()
paragraph = section.AddParagraph()
paragraph.ListFormat.ApplyStyle("UserdefinedList")
paragraph.AppendText("Hamsters")
paragraph.ListFormat.ContinueListNumbering()
paragraph = section.AddParagraph()
paragraph.ListFormat.ApplyStyle("UserdefinedList")
paragraph.AppendText("Turtles")
paragraph.ListFormat.ContinueListNumbering()
paragraph = section.AddParagraph()
paragraph.ListFormat.ApplyStyle("UserdefinedList")
paragraph.AppendText("Guinea Pigs")
paragraph.ListFormat.ContinueListNumbering()
paragraph = section.AddParagraph()
paragraph.ListFormat.ApplyStyle("UserdefinedList")
paragraph.AppendText("Ferrets")
paragraph.ListFormat.ContinueListNumbering()
paragraph = section.AddParagraph()
paragraph.ListFormat.ApplyStyle("UserdefinedList")
paragraph.AppendText("Fish")
paragraph.ListFormat.ContinueListNumbering()
'Save and close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Creates a new Word document
WordDocument document = new WordDocument();
//Adds new section to the document
IWSection section = document.AddSection();
//Adds new list style to the document
ListStyle listStyle = document.AddListStyle(ListType.Numbered, "UserDefinedList");
WListLevel levelOne = listStyle.Levels[0];
//Defines the follow character, prefix, suffix, start index for level 0
levelOne.FollowCharacter = FollowCharacterType.Tab;
levelOne.NumberPrefix = "(";
levelOne.NumberSuffix = ")";
//Adds new paragraph to the section
IWParagraph paragraph = section.AddParagraph();
//Adds text to the paragraph
paragraph.AppendText("User defined list - Level 0");
//Applies default numbered list style
paragraph.ListFormat.ApplyStyle("UserDefinedList");
//Saves the Word document
document.Save("Sample.docx", FormatType.Docx);
//Closes the document
document.Close();
}
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs)
'Creates a new Word document
Dim document As New WordDocument()
'Adds new section to the document
Dim section As IWSection = document.AddSection()
'Adds new list style to the document
Dim listStyle As ListStyle = document.AddListStyle(ListType.Numbered, "UserDefinedList")
Dim levelOne As WListLevel = listStyle.Levels(0)
'Defines the follow character, prefix, suffix, start index for level 0
levelOne.FollowCharacter = FollowCharacterType.Tab
levelOne.NumberPrefix = "("
levelOne.NumberSuffix = ")"
'Adds new paragraph to the section
Dim paragraph As IWParagraph = section.AddParagraph()
'Adds text to the paragraph
paragraph.AppendText("User defined list - Level 0")
'Applies default numbered list style
paragraph.ListFormat.ApplyStyle("UserDefinedList")
'Saves the Word document
document.Save("Sample.docx", FormatType.Docx)
'Closes the document
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add new section to the document
IWSection section = document.AddSection();
//Creates Paragraph styles.
WParagraphStyle style = document.AddParagraphStyle("Heading 1") as WParagraphStyle;
//Applies the base style.
style.ApplyBaseStyle("Normal");
//Applies character formats.
style.CharacterFormat.FontName = "Calibri Light";
style.CharacterFormat.FontSize = 16f;
style.CharacterFormat.TextColor = System.Drawing.Color.FromArgb(46, 116, 181);
//Applies paragraph formats.
style.ParagraphFormat.BeforeSpacing = 12;
style.ParagraphFormat.AfterSpacing = 0;
style.ParagraphFormat.Keep = true;
style.ParagraphFormat.KeepFollow = true;
style.ParagraphFormat.OutlineLevel = OutlineLevel.Level1;
//Add new paragraph
WParagraph paragraph = section.AddParagraph() as WParagraph;
//Apply style
paragraph.ApplyStyle("Heading 1");
paragraph.AppendText("Applying paragraph style");
//Save and close the Word document
document.Save("Sample1.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 new section to the document
Dim section As IWSection = document.AddSection()
'Creates Paragraph styles.
Dim style As WParagraphStyle = TryCast(document.AddParagraphStyle("Heading 1"), WParagraphStyle)
'Applies the base style.
style.ApplyBaseStyle("Normal")
'Applies character formats.
style.CharacterFormat.FontName = "Calibri Light"
style.CharacterFormat.FontSize = 16.0F
style.CharacterFormat.TextColor = System.Drawing.Color.FromArgb(46, 116, 181)
'Applies paragraph formats.
style.ParagraphFormat.BeforeSpacing = 12
style.ParagraphFormat.AfterSpacing = 0
style.ParagraphFormat.Keep = True
style.ParagraphFormat.KeepFollow = True
style.ParagraphFormat.OutlineLevel = OutlineLevel.Level1
'Add new paragraph
Dim paragraph As WParagraph = TryCast(section.AddParagraph(), WParagraph)
'Apply style
paragraph.ApplyStyle("Heading 1")
paragraph.AppendText("Applying paragraph style")
'Save and close the Word document
document.Save("Sample1.docx", FormatType.Docx)
document.Close()
End Sub
using (WordDocument document = new WordDocument())
{
document.EnsureMinimal();
WTable table = document.LastSection.AddTable() as WTable;
table.ResetCells(3, 2);
table[0, 0].AddParagraph().AppendText("Hi");
table[0, 1].AddParagraph().AppendText("Hi");
//Adds a new custom table style
WTableStyle tableStyle = document.AddTableStyle("CustomStyle1") as WTableStyle;
//Applies conditional formatting for first row
ConditionalFormattingStyle firstRowStyle = tableStyle.ConditionalFormattingStyles.Add(ConditionalFormattingType.FirstRow);
firstRowStyle.CharacterFormat.Bold = true;
firstRowStyle.CharacterFormat.TextColor = Color.FromArgb(255, 255, 255, 255);
firstRowStyle.CellProperties.BackColor = Color.Blue;
//Applies conditional formatting for first column
ConditionalFormattingStyle firstColumnStyle = tableStyle.ConditionalFormattingStyles.Add(ConditionalFormattingType.FirstColumn);
firstColumnStyle.CharacterFormat.Bold = true;
//Applies conditional formatting for odd row
ConditionalFormattingStyle oddRowBandingStyle = tableStyle.ConditionalFormattingStyles.Add(ConditionalFormattingType.OddRowBanding);
oddRowBandingStyle.CellProperties.BackColor = Color.Red;
//Apply built in table style as base style for CustomStyle2
tableStyle.ApplyBaseStyle(BuiltinTableStyle.TableContemporary);
//Applies the custom table style to the table
table.ApplyStyle("CustomStyle1");
//Saves and closes the document instance
document.Save("TableStyle.docx", FormatType.Docx);
}
Dim document As WordDocument = New WordDocument()
document.EnsureMinimal()
Dim table As WTable = TryCast(document.LastSection.AddTable(), WTable)
table.ResetCells(3, 2)
table(0, 0).AddParagraph().AppendText("Hi")
table(0, 1).AddParagraph().AppendText("Hi")
'Adds a new custom table style
Dim tableStyle As WTableStyle = TryCast(document.AddTableStyle("CustomStyle1"), WTableStyle)
'Applies conditional formatting for first row
Dim firstRowStyle As ConditionalFormattingStyle = tableStyle.ConditionalFormattingStyles.Add(ConditionalFormattingType.FirstRow)
firstRowStyle.CharacterFormat.Bold = True
firstRowStyle.CharacterFormat.TextColor = Color.FromArgb(255, 255, 255, 255)
firstRowStyle.CellProperties.BackColor = Color.Blue
'Applies conditional formatting for first column
Dim firstColumnStyle As ConditionalFormattingStyle = tableStyle.ConditionalFormattingStyles.Add(ConditionalFormattingType.FirstColumn)
firstColumnStyle.CharacterFormat.Bold = True
'Applies conditional formatting for odd row
Dim oddRowBandingStyle As ConditionalFormattingStyle = tableStyle.ConditionalFormattingStyles.Add(ConditionalFormattingType.OddRowBanding)
oddRowBandingStyle.CellProperties.BackColor = Color.Red
'Apply built in table style as base style for CustomStyle2
tableStyle.ApplyBaseStyle(BuiltinTableStyle.TableContemporary)
'Applies the custom table style to the table
table.ApplyStyle("CustomStyle1")
'Saves and closes the document instance
document.Save("TableStyle.docx", FormatType.Docx)
document.Close()
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Create the bookmark navigator instance to access the bookmark
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
//Move the virtual cursor to the before the end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind");
//Get the bookmark content as a text body part.
TextBodyPart part = bookmarkNavigator.GetBookmarkContent();
//Convert the textbody part as a separate Word document.
WordDocument new_document = part.GetAsWordDocument();
//Save and close the document
new_document.Save("Sample.docx", FormatType.Docx);
document.Close();
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Create the bookmark navigator instance to access the bookmark
Dim bookmarkNavigator As New BookmarksNavigator(document)
'Move the virtual cursor to the before the end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind")
'Get the bookmark content as a text body part.
Dim part As TextBodyPart = bookmarkNavigator.GetBookmarkContent()
'Convert the textbody part as a separate Word document.
Dim new_document As WordDocument = part.GetAsWordDocument()
'Save and close the document
new_document.Save("Sample.docx", FormatType.Docx)
document.Close()
//Open the template document
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Create the bookmark navigator instance to access the bookmark
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
//Move the virtual cursor to the before the end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind");
//Get the bookmark content as a text body part.
TextBodyPart part = bookmarkNavigator.GetBookmarkContent();
//Paste the content as first item in the second paragraph.
part.PasteAt(document.Sections[0].Body, 1, 0);
//Save and close the document
document.Save("Result.docx", FormatType.Docx);
document.Close();
'Open the template document
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Create the bookmark navigator instance to access the bookmark
Dim bookmarkNavigator As New BookmarksNavigator(document)
'Move the virtual cursor to the before the end location of the bookmark "Northwind"
bookmarkNavigator.MoveToBookmark("Northwind")
'Get the bookmark content as a text body part.
Dim part As TextBodyPart = bookmarkNavigator.GetBookmarkContent()
'Paste the content as first item in the second paragraph.
part.PasteAt(document.Sections(0).Body, 1, 0)
'Save and close the document
document.Save("Result.docx", FormatType.Docx)
document.Close()
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Open a new Word document
WordDocument document = new WordDocument("Template.docx");
//Initialize a new instance of TextConverter class
TextConverter converter = new TextConverter();
//Get the text contents from the template document
string text = converter.GetText(document);
//Create new Word document
WordDocument textDocument = new WordDocument();
textDocument.EnsureMinimal();
//Add the text to the newly created document
textDocument.LastParagraph.AppendText(text);
//Save and close the document.
textDocument.Save("Sample.txt", FormatType.Txt);
document.Close();
textDocument.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Open a new Word document
Dim document As New WordDocument("Template.docx")
'Initialize a new instance of TextConverter class
Dim converter As New TextConverter()
'Get the text contents from the template document
Dim text As String = converter.GetText(document)
'Create new Word document
Dim textDocument As New WordDocument()
textDocument.EnsureMinimal()
'Add the text to the newly created document
textDocument.LastParagraph.AppendText(text)
'Save and close the document.
textDocument.Save("Sample.txt", FormatType.Txt)
document.Close()
textDocument.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
FileStream fs = new FileStream("Result.txt", FileMode.Open, FileAccess.Read);
StreamReader reader = new StreamReader(fs);
reader.BaseStream.Position = 0;
//Create the new TextConverter
TextConverter txtConverter = new TextConverter();
//Write the text file to document
txtConverter.Read(reader, document);
reader.Dispose();
fs.Dispose();
//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)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
Dim fs As New FileStream("Result.txt", FileMode.Open, FileAccess.Read)
Dim reader As New StreamReader(fs)
reader.BaseStream.Position = 0
'Create the new TextConverter
Dim txtConverter As New TextConverter()
'Write the text file to document
txtConverter.Read(reader, document)
reader.Dispose()
fs.Dispose()
'Save and close the Word document instance
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
FileStream fs = new FileStream("Result.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite);
StreamWriter writer = new StreamWriter(fs);
//Create the new TextConverter
TextConverter txtConverter = new TextConverter();
//Write the document to text file
txtConverter.Write(writer, document);
writer.Flush();
writer.Dispose();
fs.Dispose();
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
Dim fs As New FileStream("Result.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite)
Dim writer As New StreamWriter(fs)
'Create the new TextConverter
Dim txtConverter As New TextConverter()
'Write the document to text file
txtConverter.Write(writer, document)
writer.Flush()
writer.Dispose()
fs.Dispose()
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Open the template document
WordDocument document = new WordDocument("Bookmarks.docx", FormatType.Docx);
//Get the text body of first section
WTextBody textbody = document.Sections[0].Body;
//Gets the second paragraph
WParagraph paragraph = textbody.Paragraphs[1];
//Get the start and end items
ParagraphItem startItem = (ParagraphItem)paragraph.ChildEntities[0];
ParagraphItem endItem = (ParagraphItem)paragraph.ChildEntities[1];
//Selects the items in the text body
TextBodySelection selection = new TextBodySelection(startItem, endItem);
//Create new text body part
TextBodyPart textbodyPart = new TextBodyPart(document);
//Copy the selected items
textbodyPart.Copy(selection);
//Paste the selected items.
textbodyPart.PasteAt(textbody, 2);
//Save and close the document.
document.Save("Result.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Open the template document
Dim document As New WordDocument("Bookmarks.docx", FormatType.Docx)
'Get the text body of first section
Dim textbody As WTextBody = document.Sections(0).Body
'Gets the second paragraph
Dim paragraph As WParagraph = textbody.Paragraphs(1)
'Get the start and end items
Dim startItem As ParagraphItem = DirectCast(paragraph.ChildEntities(0), ParagraphItem)
Dim endItem As ParagraphItem = DirectCast(paragraph.ChildEntities(1), ParagraphItem)
'Selects the items in the text body
Dim selection As New TextBodySelection(startItem, endItem)
'Create new text body part
Dim textbodyPart As New TextBodyPart(document)
'Copy the selected items
textbodyPart.Copy(selection)
'Paste the selected items.
textbodyPart.PasteAt(textbody, 2)
'Save and close the document.
document.Save("Result.docx")
document.Close()
End Sub
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Open the template document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Get the text body of first section
WTextBody textbody = document.Sections[0].Body;
//Selects the items in the text body
TextBodySelection selection = new TextBodySelection(textbody, 0, 1, 0, 1);
//Create new text body part
TextBodyPart textbodyPart = new TextBodyPart(document);
//Copy the selected items
textbodyPart.Copy(selection);
//Paste the selected items.
textbodyPart.PasteAt(textbody, 2);
//Save and close the document.
document.Save("Sample.docx");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Open the template document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Get the text body of first section
Dim textbody As WTextBody = document.Sections(0).Body
'Selects the items in the text body
Dim selection As New TextBodySelection(textbody, 0, 1, 0, 1)
'Create new text body part
Dim textbodyPart As New TextBodyPart(document)
'Copy the selected items
textbodyPart.Copy(selection)
'Paste the selected items.
textbodyPart.PasteAt(textbody, 2)
'Save and close the document.
document.Save("Sample.docx")
document.Close()
End Sub