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.
https://stackoverflow.com/questions/61406631/search-algorithm-for-excel-document-in-java
SPL Official Website 👉 https://www.esproc.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProc_Desktop/
SPL Learning Material 👉 https://c.esproc.com
Discord 👉 https://discord.gg/sxd59A8F2W
Youtube 👉 https://www.youtube.com/@esProcDesktop
Linkedin Group 👉 https://www.linkedin.com/groups/14419406/