Search for Rows Containing a Specified String

Problem description & analysis

Below is data in Excel file assignment.xlsx:

1234

qwer

asdf

zxcv

ghjk

tyui

4567

xcvb

zgheib

dfgdfh

1111

hjkl

2222

5rw34

11zgheib22

25twq

qqqq

eeee

2222

33333

123

zgh

eib

4321

We are trying to find all cells whose values contain string zgheib and output the rows containing these cells. Below is the desired result:

zgheib   dfgdfh   1111      hjkl

2222      5rw34    11zgheib22  25twq

Solution

We write the following script p1.dfx in esProc:

A

1

=file("assignment.xlsx").xlsimport@s()

2

=A1.split("\n").select(pos(~,"zgheib")).concat@n()

3

>output(A2)

Explanation:

A1  Import the Excel table as a string where column values are separated by tab and row values are separated by line break.

A2  Split A1’s string into a sequence by line break, find members in the current string that contain substring zgheib, and concatenate result sequences into a string with line break.

A3  Output A2’s result to console.

Read How to Call an SPL Script in Java to learn about the integration of an SPL script with a Java program.

Q & A Collection

https://stackoverflow.com/questions/61406631/search-algorithm-for-excel-document-in-java