Search code examples
excelsalesforcedataweavemulesoftmule4

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


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?


Solution

  • 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
    ---