# Text to Columns

Learn how to use the Text to Columns feature to convert text into separate columns with suitable delimiters or column width options. Find out how to separate full names into first and last names using this method.

## Content

**Text to Columns** is used to convert simple text or sentences having multiple words into separate columns. It enables us to get the tabular structure of data using a suitable delimiter or column width option.
For example, when you want to separate a list of full names into first and last names, you can use Text to Columns feature.

### Using Code

You can set the **TextToColumns** method from the **IRange** interface to parse the text from one cell or column into many columns.
![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/text-to-column-first.png)

```csharp
IWorksheet TestActiveSheet = fpSpread1.AsWorkbook().ActiveSheet;
TestActiveSheet.Cells["A1"].Value = "Jacob Dev SpreadWin";
TestActiveSheet.Cells["A2"].Value = "Steve Dev Raykit";
TestActiveSheet.Cells["A3"].Value = "Serena Tester SpreadWin";
TestActiveSheet.Cells["A4"].Value = "Keira Tester Raykit";
TestActiveSheet.Cells["A1:A4"].TextToColumns("A5", TextParsingType.Delimited, TextQualifier.None, false, false, false, false, true);
```

```vbnet
Dim TestActiveSheet As IWorksheet = FpSpread1.AsWorkbook().ActiveSheet
TestActiveSheet.Cells("A1").Value = "Jacob Dev SpreadWin"
TestActiveSheet.Cells("A2").Value = "Steve Dev Raykit"
TestActiveSheet.Cells("A3").Value = "Serena Tester SpreadWin"
TestActiveSheet.Cells("A4").Value = "Keira Tester Raykit"
TestActiveSheet.Cells("A1:A4").TextToColumns("A5", TextParsingType.Delimited, TextQualifier.None, False, False, False, False, True)
```

### Using Runtime UI

You can enable the built-in TextToColumn dialog box using **BuiltInDialogs** class at run-time to the end-user with the specified range.
![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/text-to-column-wizard.png)
The following code example shows how to use the runtime dialog box in a Spread worksheet:

```csharp
IWorksheet TestActiveSheet = fpSpread1.AsWorkbook().ActiveSheet;
TestActiveSheet.Cells["A1"].Value = "Red,Blue,Green,Black,White,Yellow";
FarPoint.Win.Spread.Dialogs.BuiltInDialogs.TextToColumns(fpSpread1).Show(fpSpread1);
```

```vbnet
Dim TestActiveSheet As IWorksheet = FpSpread1.AsWorkbook().ActiveSheet
TestActiveSheet.Cells("A1").Value = "Red,Blue,Green,Black,White,Yellow"
FarPoint.Win.Spread.Dialogs.BuiltInDialogs.TextToColumns(fpSpread1).Show(FpSpread1)
```

### Using Spread Designer

Spread for WinForms designer provides the **"Text to Columns"** ribbon button in the "**Data Tools**" group of the "**Data**" tab.
![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/text2columns-strip.png)

## Steps to Convert Text to Columns

### Using Delimiters

This method splits the text using the present delimiter in a cell or range. You can define your delimiter as well. Only one character is considered a delimiter.
Follow the steps below to convert the sample text using the comma delimiter.

1. Select the cell or range containing text.
    ![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/text2columns-delimiter-text.png)
2. Click "**Text to Columns**" from the "Data Tools" group in the "Data" tab. The "Convert Text to Columns Wizard" window opens.
3. Select the **Delimited** option from the "Original data type" section.
    ![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/text2columns-delimiter-step1.png)
    Click **Next** to open the "**Convert Text to Columns Wizard- Step 2 for 3**" window.
4. Set the delimiter from the pre defined list of delimiters or you can enter your delimiter by specifying the desired character in the "Other" option.
    ![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/text2columns-delimiter-step2.png)

    > !type=note
    > **Note:** 
    > The delimiter in the **""** or **''** will be ignored.
    > Check **"Treat consecutive delimiters as one"** option to allow if multiple characters **";;;;"** are specified, they will be treated as one **";"** only.
5. Click **Next** to open the "**Convert Text to Columns wizard-Step 3 of 3**" window. Now, set the Data format for each column.
    You can select the **Destination** for the text. The default destination is the original cell.
    ![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/text2columns-format.png)
6. Click **Finish** to convert the text to the cell into columns.
    ![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/text2columns-delimiter-result.png)

### Using Fixed Widths

This method splits the text using the fixed width between text. You can set column breaks to separate the text into columns.
Follow the steps below to convert the sample text using the fixed width:

1. Select the cell or range where you want to convert the text into columns.
<br>
    ![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/text2columns-fixed-text.png)
2. Click "**Text to Columns**" from the "**Data Tools**" group in the "**Data**" tab. The "**Convert Text to Columns Wizard**" window opens.
3. Select the **Fixed width** option from the "**Original data type**" section.
    ![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/text2columns-fixed-step1.png)
    Click **Next** to open the "**Convert Text to Columns Wizard- Step 2 for 3**" window.
4. Create fixed-width column breaks using the instructions mentioned on the window.
    ![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/text2columns-fixed-step2.png)
    Click **Next** to open the "**Convert Text to Columns wizard-Step 3 of 3**" window.
5. Set the **Data format** for each column.
    You can select the **Destination** for the text. The default destination is the original cell.
    ![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/text2columns-fixed-step3.png)
6. Click **Finish** to convert the text to the cell into columns.
    ![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/text2columns-fixed-result.png)

### Warnings

A warning is displayed in the following scenarios:

1. If the selected cell or range has no data.
    ![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/text2columns-warning1.png)
2. If the selection contains more than one column.
    ![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/text2columns-warning2.png)