Home > database >  Mulesoft: How can I apply the {header:false} option when getting an Excel file from server
Mulesoft: How can I apply the {header:false} option when getting an Excel file from server

Time:04-08

In DataWeave when using the readUrl() function, I can utilize the {"header":false} option as shown below to give the column as the key and cell as the value in a JSON object:

var myInput = readUrl("classpath://examples/Test.xlsx", "application/xlsx", {"header":false})

JSON

{
        A: "A1",
        B: "B1",
        C: "",
        D: "",
        E: "E1"
}

I'm using a REST API call to Salesforce to retrieve an Excel file. Is there a way to apply a similar option of {"header":false} to be able to provide the content of the Excel file in similar way as JSON above?

CodePudding user response:

Use this mule docs references to see supported read properties.

https://docs.mulesoft.com/dataweave/2.4/dataweave-formats-excel

You can use a transform message and use the same value as shown below

   %dw 2.0
input payload application/xlsx header=false
output application/json
---

CodePudding user response:

You should set the correct data format and properties in the operation or source where the payload is created with the outputMimeType attribute. This is explained in the documentation. In this case the operation is the <http:request>.

Example:

<http:request ... outputMimeType="application/csv; header=false">
  • Related