Support Questions

Find answers, ask questions, and share your expertise

Nifi + Groovy + Apache POI for excel in outputStream

New Contributor

Hi everybody,

i'm new to Nifi, and i try to understand how the in/out streams works in groovy.


I've created one processor to generate flowfile, one to run a groovy script and a third one to putfile.


I've tried many many things but for now my groovy script (not working) look like this:





import org.apache.poi.hssf.usermodel.*
import org.apache.poi.xssf.usermodel.*
import org.apache.poi.hssf.extractor.*
import java.nio.charset.*

def flowFile = session.get()

if(!flowFile) return

flowFile = session.write(flowFile, {inputStream, outputStream ->
    try {

FileOutputStream out = new FileOutputStream("workbook.xls");
//is not working.

// def record = "toto"
// outputStream.write(record.getBytes(StandardCharsets.UTF_8))
//is working and giving me a txt file with toto in it.

    } catch(e) {
     log.error("Error during processing", e)
     session.transfer(flowFile, REL_FAILURE)
} as StreamCallback)

session.transfer(flowFile, REL_SUCCESS)




the error i get is : 
It says to me that the ProcessSession.write(FlowFile) has not been closed.
When i do outpustream.write of a string, it works, but with a excel file it doesn't work
At this point i really don't know what i'm missing.
My modules are well imported and class path had been setup.
I looked all over the internet but there is no ressource about writing an excel file in the output stream of nifi.
I 'm open to any other way to treat this problem.


Hi @ollie_  did you find a solution ?

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.