Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Spreadsheet .NET
>
Tutorial
> Get Rich Inline Text
The following example shows you how to get text from RichTextInline.
C# example
using System; using Independentsoft.Office.Spreadsheet; namespace Sample { class Program { static void Main(string[] args) { Workbook book = new Workbook("c:\\test\\input.xlsx"); Worksheet sheet1 = (Worksheet)book.Sheets[0]; Cell b1 = sheet1["B1"]; String text = ""; if(b1.RichTextInline != null) { RichTextInline inlineText = b1.RichTextInline; foreach(Run run in inlineText.Runs) { if(run.Text != null && run.Text.Value != null) { text += run.Text.Value; } } Console.WriteLine(text); } Console.Read(); } } }
VB example
Imports System Imports Independentsoft.Office Imports Independentsoft.Office.Spreadsheet Module Module1 Sub Main(ByVal args As String()) Dim book As New Workbook("c:\test\input.xlsx") Dim sheet1 As Worksheet = DirectCast(book.Sheets(0), Worksheet) Dim b1 As Cell = sheet1("B1") Dim text As [String] = "" If b1.RichTextInline IsNot Nothing Then Dim inlineText As RichTextInline = b1.RichTextInline For Each run As Run In inlineText.Runs If run.Text IsNot Nothing AndAlso run.Text.Value IsNot Nothing Then text += run.Text.Value End If Next Console.WriteLine(text) End If Console.Read() End Sub End Module
Need help? Ask our developers:
Name*
Email*
Message*