Hi Lalit ,
You can use below snippet code
XSSFWorkbook workbook = new XSSFWorkbook ();
// In between lot of code exist
ByteArrayOutputStream bytearraystream = new ByteArrayOutputStream();
workbook.write(bytearraystream);
// Convert to ByteArray
byte[] barray = bytearraystream.toByteArray();
InputStream is = new ByteArrayInputStream(barray);
workbook.close();
// Store the input stream to file document object.
Core.storeFileDocumentContent(getContext(), Yourfiledocumentobject, is);
Yourfiledocumentobject.setHasContents(true);
As Fabian mentioned, you need to the storeFileDocumentContent method to save to a Mendix FileDocument. As you have an OutputStream, you need to convert this to an InputStream before you can use it with this method. You also need to create a FileDocument object for the method to use before you can store your data.
Assuming you have created your FileDocument and passed it into your Java Action in a variable called yourFileDocument, the following should work. It will convert your fileOut OutputStream into a ByteArrayInputStream that you can use with soreFileDocumentContent.
ByteArrayInputStream inStream = new ByteArrayInputStream(fileOut.toByteArray());
Core.storeFileDocumentContent(this.getContext(), yourFileDocument, inStream);
Hi there,
use the Core method
public static void storeFileDocumentContent(IContext context, IMendixObject fileDocument, java.io.InputStream inputStream)
to write to a mendix FileDocument.
regards