Split Contents in One Cell into Multiple Columns in Java

Import Dependency (2 Method)

<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>http://repo.e iceblue.com/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.xls.free</artifactId>
<version>5.1.0</version>
</dependency>
</dependencies>

Sample Code

import com.spire.xls.*;

public class splitDataIntoMultipleColumns {
public static void main(String[] args) {
//Load the sample document from file
Workbook workbook = new Workbook();
workbook.loadFromFile("source data.xlsx");

//Get the first worksheet.
Worksheet sheet = workbook.getWorksheets().get(0);

//Split data into separate columns by the delimiter characters of space.
String[] splitText = null;
String text = null;
for (int i = 1; i < sheet.getLastRow(); i++)
{
text = sheet.getRange().get(i + 1, 1).getText();
splitText = text.split(" ");
for (int j = 0; j < splitText.length; j++)
{
sheet.getRange().get(i + 1, 1 + j + 1).setText(splitText[j]);
}
}
//Save to file
workbook.saveToFile("SplitCell.xlsx", ExcelVersion.Version2013);
}
}

--

--

--

Sharing Java Code

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Creating a Modular Waypoint System in Unity.

How to Create a Multipage Dash App

Pixverse Game First Phase In-Depth Guide

Welcoming RabbitHouse team to Polestar Labs

Deploy WordPress on Kubernetes & AWS RDS using Terraform

Crowdsourcing Your Continuing Education

Grand fashions customer care number/8584892730//7001340188/Grand fashions customer care…

Hello World !

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andrew Wilson

Andrew Wilson

Sharing Java Code

More from Medium

Remove Excel Formulas but Keep Values in Java

Annotation in Java..!

TIL 0520 Java8 practice 2

How To Read Emails Using Java Imaps? — Devstringx

Java Imaps