Hello All!
The main goal is fill excel template and attach file to the record. Solution has been developed and works fine on the online VM.
The code:
using (System.IO.Stream outputStream = new System.IO.MemoryStream()) { package.SaveAs(outputStream); FileUploadTemporaryStorageResult result = File::SendFileToTempStore_GetResult(outputStream, this.fileName()); using(System.IO.MemoryStream finalStream = result.openResult() as System.IO.MemoryStream) { finalStream.Position = 0; DocumentManagement::attachFileToCommon( callerWHSLoadTable, docuTypeId, finalStream, this.filename(), fileExtension, this.filename());
But it doesn't work on-prem version.
This code create attachment record, but preview pane do not shown Excel Workbook. And 'Open' button opens IE with this message:
This XML file does not appear to have any style information associated with it. The document tree is shown below. <Error> <Message>An error has occurred.</Message> </Error>
Unfortunatelly, I haven't access to the on-prem version to debug or analyze DB data.
Looks like attachment should be implemented by other way for on-prem version, but I didn't find any info about it.
I would be grateful for any hint.
Thanks.