Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
ODF .NET
>
Tutorial
> Add field
The following example shows you how to add a standard or user-defined fields.
C# example
using System; using System.Drawing; using Independentsoft.Office.Odf; using Independentsoft.Office.Odf.Fields; namespace Sample { class Program { static void Main(string[] args) { TextDocument doc = new TextDocument(); Date dateField = new Independentsoft.Office.Odf.Fields.Date(); FileName fileNameField = new FileName(); Paragraph p1 = new Paragraph(); p1.Add("File name is: "); p1.Add(fileNameField); Paragraph p2 = new Paragraph(); p2.Add("Current date is: "); p2.Add(dateField); doc.Body.Add(p1); doc.Body.Add(p2); doc.Save("c:\\test\\output.odt", true); } } }
VB example
Imports System Imports Independentsoft.Office.Odf Imports Independentsoft.Office.Odf.Fields Module Module1 Sub Main(ByVal args() As String) Dim doc As TextDocument = New TextDocument() Dim dateField As Independentsoft.Office.Odf.Fields.Date = New Independentsoft.Office.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\output.odt", True) End Sub End Module
Need help? Ask our developers:
Name*
Email*
Message*