Extract Text from Textbox in Excel Using Java

Installation (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>

Steps and Sample Code

  1. Create a Workbook instance.
  2. Load a sample Excel file using Workbook.loadFromFile() method.
  3. Get a specified worksheet using Workbook.getWorksheets().get() method.
  4. Get a specified textbox using Worksheet.getTextBoxes().get() method.
  5. Get the text in the specified textbox using XlsTextBoxShape.getText() method.
import com.spire.xls.Workbook;
import com.spire.xls.Worksheet;
import com.spire.xls.core.spreadsheet.shapes.XlsTextBoxShape;

public class ExtractTextFromTextbox {

public static void main(String[] args) {

//Create a Workbook instance
Workbook workbook = new Workbook();

//Load a sample Excel file
workbook.loadFromFile("input.xlsx");

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

//Get the first textbox
XlsTextBoxShape shape = (XlsTextBoxShape)sheet.getTextBoxes().get(0);

//Get the text inside the textbox
String text = shape.getText();
System.out.print(text);
}
}

--

--

--

Sharing Java Code

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

Recommended from Medium

How to set up separate testing and production environments by integrating Github-Jenkins-Docker.

PointPay Wednesday Update

Make your own APNS pusher 🔔

How To Setup Docker for Symfony 4 Applications

Scheduling Backups on an Oracle Cloud VPS

Featured

Tutorial Fuzzy Logic Mamdani for Arduino

Tutorial Fuzzy Logic Mamdani for Arduino

OpsGenie’s secret for delivering a great product

Mocaserver usage and options for RedPrairie/JDA WMS

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

Apply or Remove Data Validation in Excel Using Java

Beginners Guide to Java Programming

Database!

Multiple classes in a single Java source file