Tuesday, 10 March 2020 08:51

Java find and highlight data in Excel

Written by  support iceblue
Rate this item
(0 votes)

With Spire.XLS for java, we could find and replace data in Excel easily. This article will demonstrate how to find and highlight data in Excel.

Firstly, view the sample document:

Java find and highlight data in Excel

import com.spire.xls.*;
import java.awt.*;

public class FindandHighlight {
    public static void main(String[] args) {

        //Load the sample document
        Workbook workbook = new Workbook();

        //Get the second worksheet
        Worksheet worksheet = workbook.getWorksheets().get(1);

        //Find the text string "Mexico"
        CellRange[] ranges = worksheet.findAllString("Mexico", true, true);

        for (CellRange range : ranges)
            //Set the color to highlight the text
        //Save the document to file
        workbook.saveToFile("output/FindandHighlight.xlsx", ExcelVersion.Version2010);


Effective screenshot after find and highlight the data in Excel:

Java find and highlight data in Excel

Additional Info

  • tutorial_title: