Independentsoft
Professional software libraries for developers
Home
Purchase
Support
Company
Contact
ODF .NET
>
Tutorial
> Strikethrough text
The following example shows how to apply strikethrough formatting to text.
C# example
using System; using Independentsoft.Office.Odf; using Independentsoft.Office.Odf.Styles; namespace Sample { class Program { static void Main(string[] args) { TextDocument doc = new TextDocument(); TextStyle strikeStyle = new TextStyle("Strike"); strikeStyle.TextLineThrough = LineType.Single; strikeStyle.TextLineThroughStyle = LineStyle.Solid; doc.AutomaticStyles.Styles.Add(strikeStyle); TextStyle doubleStrike = new TextStyle("DoubleStrike"); doubleStrike.TextLineThrough = LineType.Double; doubleStrike.TextLineThroughStyle = LineStyle.Solid; doc.AutomaticStyles.Styles.Add(doubleStrike); AttributedText strickenSpan = new AttributedText(); strickenSpan.Add("This text is struck through"); strickenSpan.Style = "Strike"; AttributedText doubleSpan = new AttributedText(); doubleSpan.Add("Double strikethrough"); doubleSpan.Style = "DoubleStrike"; Paragraph p1 = new Paragraph(); p1.Add(strickenSpan); doc.Body.Add(p1); Paragraph p2 = new Paragraph(); p2.Add(doubleSpan); doc.Body.Add(p2); doc.Save("c:\\test\\output.odt", true); } } }
VB example
Imports System Imports Independentsoft.Office.Odf Imports Independentsoft.Office.Odf.Styles Module Module1 Sub Main(ByVal args() As String) Dim doc As TextDocument = New TextDocument Dim strikeStyle As New TextStyle("Strike") strikeStyle.TextLineThrough = LineType.Single strikeStyle.TextLineThroughStyle = LineStyle.Solid doc.AutomaticStyles.Styles.Add(strikeStyle) Dim doubleStrike As New TextStyle("DoubleStrike") doubleStrike.TextLineThrough = LineType.Double doubleStrike.TextLineThroughStyle = LineStyle.Solid doc.AutomaticStyles.Styles.Add(doubleStrike) Dim strickenSpan As New AttributedText strickenSpan.Add("This text is struck through") strickenSpan.Style = "Strike" Dim doubleSpan As New AttributedText doubleSpan.Add("Double strikethrough") doubleSpan.Style = "DoubleStrike" Dim p1 As New Paragraph p1.Add(strickenSpan) doc.Body.Add(p1) Dim p2 As New Paragraph p2.Add(doubleSpan) doc.Body.Add(p2) doc.Save("c:\test\output.odt", True) End Sub End Module
Need help? Ask our developers:
Name*
Email*
Message*