Knowledgebase (2343)
Children categories
Spire.Presentation as a powerful PowerPoint library, enables developers to create SmartArt, add text to SmartArt and format SmartArt in a flexible way (Reference: How to Create and Format SmartArt in PowerPoint in C#, VB.NET). In this article, we will further introduce how to extract text from SmartArt in PowerPoint in C# and VB.NET by using Spire.Presentation for .NET.
Please look at the appearance of the sample PPT file first:

Detail steps and code snippets are as below:
Step 1: Create a new instance of Presentation class and load the sample PPT file.
Presentation ppt = new Presentation();
ppt.LoadFromFile("Sample.pptx");
Step 2: Create a new instance of StringBulider class, traverse through all the slides of the PPT file, find the SmartArt shapes, and then extract text from SmartArt shape Nodes and append to the StringBuilder object.
StringBuilder st = new StringBuilder();
for (int i = 0; i < ppt.Slides.Count; i++)
{
for (int j = 0; j < ppt.Slides[i].Shapes.Count; j++)
{
if (ppt.Slides[i].Shapes[j] is ISmartArt)
{
ISmartArt smartArt = ppt.Slides[i].Shapes[j] as ISmartArt;
for (int k = 0; k < smartArt.Nodes.Count; k++)
{
st.Append(smartArt.Nodes[k].TextFrame.Text);
}
}
}
}
Step 3: Create a new text file and write the extracted text to the text file.
File.WriteAllText("Result.txt", st.ToString());
The result text file:

Full codes:
using System.IO;
using System.Text;
using Spire.Presentation;
using Spire.Presentation.Diagrams;
namespace Extract_text_from_SmartArt_in_PPT
{
class Program
{
static void Main(string[] args)
{
Presentation ppt = new Presentation();
ppt.LoadFromFile("Sample.pptx");
StringBuilder st = new StringBuilder();
for (int i = 0; i < ppt.Slides.Count; i++)
{
for (int j = 0; j < ppt.Slides[i].Shapes.Count; j++)
{
if (ppt.Slides[i].Shapes[j] is ISmartArt)
{
ISmartArt smartArt = ppt.Slides[i].Shapes[j] as ISmartArt;
for (int k = 0; k < smartArt.Nodes.Count; k++)
{
st.Append(smartArt.Nodes[k].TextFrame.Text);
}
}
}
}
File.WriteAllText("Result.txt", st.ToString());
}
}
}
Imports System.IO
Imports System.Text
Imports Spire.Presentation
Imports Spire.Presentation.Diagrams
Namespace Extract_text_from_SmartArt_in_PPT
Class Program
Private Shared Sub Main(args As String())
Dim ppt As New Presentation()
ppt.LoadFromFile("Sample.pptx")
Dim st As New StringBuilder()
For i As Integer = 0 To ppt.Slides.Count - 1
For j As Integer = 0 To ppt.Slides(i).Shapes.Count - 1
If TypeOf ppt.Slides(i).Shapes(j) Is ISmartArt Then
Dim smartArt As ISmartArt = TryCast(ppt.Slides(i).Shapes(j), ISmartArt)
For k As Integer = 0 To smartArt.Nodes.Count - 1 st.Append(smartArt.Nodes(k).TextFrame.Text)
Next
End If
Next
Next
File.WriteAllText("Result.txt", st.ToString())
End Sub
End Class
End Namespace
With the help of Spire.PDF, developers can easily draw texts on the PDF files in C#. We have already introduced how to draw text in PDF with different styles. Usually the texts are left to right format, for some languages, such as Hebrew, Arabic, etc. the texts are from right to left. Spire.PDF offers a property to enable developers to set RightToLeft as true to draw right to left text on PDF in C#. Here comes to the steps of how to draw the Hebrew texts from right to left.
Step 1: Define the text string in Hebrew:
string value = "וַיֹּאמֶר אֱלֹהִים, יְהִי אוֹר; וַיְהִי-אוֹר.";
Step 2: Create a new PDF document.
PdfDocument doc = new PdfDocument();
Step 3: Add a new page to the PDF document.
PdfPageBase page = doc.Pages.Add(PdfPageSize.A4, new PdfMargins());
Step 4: Set the font and position for the text.
PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Alef-Regular.ttf", 16f, FontStyle.Bold), true);
RectangleF labelBounds = new RectangleF(20, 20, 400, font.Height);
Step 5: Draw the text and set the value to indicate the text direction mode.
page.Canvas.DrawString(value, font, PdfBrushes.Black, labelBounds, new PdfStringFormat() { RightToLeft = true });
Step 6: Save the document to file.
doc.SaveToFile("result.pdf");
Effective screenshot:

Full codes:
using Spire.Pdf;
using Spire.Pdf.Graphics;
using System.Drawing;
namespace RightToLeftText
{
class Program
{
static void Main(string[] args)
{
string value = "וַיֹּאמֶר אֱלֹהִים, יְהִי אוֹר; וַיְהִי-אוֹר.";
PdfDocument doc = new PdfDocument();
PdfPageBase page = doc.Pages.Add(PdfPageSize.A4, new PdfMargins());
PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Alef-Regular.ttf", 16f, FontStyle.Bold), true);
RectangleF labelBounds = new RectangleF(20, 20, 400, font.Height);
page.Canvas.DrawString(value, font, PdfBrushes.Black, labelBounds, new PdfStringFormat() { RightToLeft = true });
labelBounds = new RectangleF(20, 50, 400, font.Height);
page.Canvas.DrawString(value, font, PdfBrushes.Black, labelBounds, new PdfStringFormat() { RightToLeft = false });
doc.SaveToFile("result.pdf");
}
}
}
When working with spreadsheets, you may find that certain cells contain combined information that need to be split for further sorting, filtering, or analyzing. MS Excel provides the “Text to Columns” feature to help users handle such situation, but manually processing large datasets is tedious and error prone. Using Spire.XLS, a robust .NET library, you can automate splitting data into columns efficiently.
This article will guide you through the process of splitting Excel data into multiple columns with C#, saving you time and ensuring accuracy.
- Why Use Spire.XLS for Splitting Excel Data?
- How to Install the .NET Excel Library?
- Split Excel Data into Multiple Columns with C# (Steps & Code)
Why Use Spire.XLS for Splitting Excel Data?
- No Office Dependency: Manipulate Excel files without installing Microsoft Office.
- Rich Features: Beyond splitting data, Spire.XLS also allows to edit, format, or export split data to other formats.
- .NET Integration: Seamlessly embed Excel automation into .NET applications.
How to Install the .NET Excel Library?
To follow along with the examples in this article, you'll need to have the Spire.XLS for .NET library installed. The product package can be downloaded from the official website and then imported manually. Or you can install it directly via NuGet:
PM> Install-Package Spire.XLS
Split Excel Data into Multiple Columns with C# (Steps & Code)
With Spire.XLS, you can first retrieve the content in a cell, then split the cell content based on specific delimiter, and finally write the split data into different columns. The detailed steps are as follows:
- Load Excel and get a worksheet.
- Create a Workbook object and use its LoadFromFile() method to load an Excel file.
- Access a specified worksheet through the Workbook.Worksheets[index] property.
- Retrieve and split cell data.
- Iterate through each row in the sheet.
- Access a specified cell and then get its content using the CellRange.Text property.
- Call the string.Split(params char[] separator) method to split the content based on a specified separator (e.g., comma, space, semicolon, etc.).
- Write data into multiple columns and save.
- Iterate through each split data.
- Write the split data into different columns.
- Save the modified workbook to a new file using the Workbook.SaveToFile() method.
Below is the sample code:
- C#
using Spire.Xls;
namespace ConvertTextToColumns
{
class Program
{
static void Main(string[] args)
{
// Create a Workbook object
Workbook workbook = new Workbook();
// Load an Excel file
workbook.LoadFromFile("Data.xlsx");
// Get the first worksheet
Worksheet sheet = workbook.Worksheets[0];
// Loop through each row in the worksheet
for (int i = 0; i < sheet.LastRow; i++)
{
// Get the text of the first cell in the current row
string cellText = sheet.Range[i + 1, 1].Text;
// Split the text by comma
string[] splitText = cellText.Split(',');
// Iterate through each split value
for (int j = 0; j < splitText.Length; j++)
{
// Write the split data into different columns
sheet.Range[i + 1, j + 3].Text = splitText[j];
}
}
// Autofit column widths
sheet.AllocatedRange.AutoFitColumns();
// Save the result file
workbook.SaveToFile("SplitExcelData.xlsx", ExcelVersion.Version2016);
}
}
}

Get a Free License
To fully experience the capabilities of Spire.XLS for .NET without any evaluation limitations, you can request a free 30-day trial license.
Conclusion
Splitting text into columns in Excel using C# streamlines data processing and reduces the risk of errors. With Spire.XLS, you can automate complex tasks while maintaining data integrity, making data management easier.