Independentsoft
Home
Products
Purchase
Support
Downloads
Company
Contact
ODF .NET
>
Tutorial
> Add field
The following example shows you how to add a standard or user-defined fields.
See screenshot
.
C# example
using System; using System.Drawing; using Independentsoft.Odf; using Independentsoft.Odf.Fields; namespace Sample { class Program { static void Main(string[] args) { TextDocument doc = new TextDocument(); Date dateField = new Independentsoft.Odf.Fields.Date(); FileName filNameField = new FileName(); Paragraph p1 = new Paragraph(); p1.Add("File name is: "); p1.Add(filNameField); Paragraph p2 = new Paragraph(); p2.Add("Current date is: "); p2.Add(dateField); doc.Body.Add(p1); doc.Body.Add(p2); doc.Save("c:\\test.odt"); } } }
VB example
Imports System Imports Independentsoft.Odf Imports Independentsoft.Odf.Fields Module Module1 Sub Main(ByVal args() As String) Dim doc As TextDocument = New TextDocument() Dim dateField As Independentsoft.Odf.Fields.Date = New Independentsoft.Odf.Fields.Date Dim filNameField As FileName = New FileName Dim p1 As Paragraph = New Paragraph p1.Add("File name is: ") p1.Add(filNameField) Dim p2 As Paragraph = New Paragraph p2.Add("Current date is: ") p2.Add(dateField) doc.Body.Add(p1) doc.Body.Add(p2) doc.Save("c:\test.odt") End Sub End Module