cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Returning Excel with a CAP service

TheWind
Explorer
0 Kudos
102

Hello, I am trying this feature in order to download a dynamically generated excel from a UI5 app: https://cap.cloud.sap/docs/node.js/best-practices#custom-streaming-beta

The way this:

const readable = Readable.from(buffer)
return {
  value: readable,
  $mediaContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  $mediaContentDispositionFilename: `${fileName}.xlsx`,
}

Where readable is of type stream.Readable and the buffer comes from ExcelJS.

When I trigger it in the browser, it correctly downloads an attachment of type XLSX, but the content is:

{
@odata.context: "$metadata#Edm.Binary"
value: {
  value: "[object Readable]"
  $mediaContentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  $mediaContentDispositionFilename: "DCT - 212 - TEST TAX - SSD 2024-10-05.xlsx"
  }
}

So somehow, the readable stream it not used correctly down the line. Am I doing something wrong?

Accepted Solutions (0)

Answers (0)