How to export data to excel in a grid with more than 50 columns?

Certified Senior Developer

I am using a read-only grid to show data for reports. I need to export the data to excel but the grid has more than 50 columns. I have already tried default export to excel feature and a!exportDataStoreEntityToExcel() function but none of these worked. 

FYI:

  • Data is in SQL.
  • Appian version is 23.2.
  • Columns cannot be merged or it's count can't be reduced

Is there any way I can export the data to excel?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    Hello  ,

    I would suggest you to use OOTB of appian to achieve this. We created xlsx file using below approach to create more than 50 columns to be exportable.

    Create Web API:
    Parse request using  a!fromJson( http!request.body)  and retrieve information to query data for which identifier.
    Retrieves data using queryEntity from your database using request identifier.
    Encodes the generated Excel data in Base64 format using exportDataSubsetToBase64 function.
    Sends the Base64 encoded data as the response body in the HTTP response with appropriate headers.

    a!localVariables(
        /*Create Helper CDT of Request Type*/
      local!request: a!fromJson( http!request.body),/*Parse Request Here and cast to helper cdt*/
      local!entities: /*Retrive Data Here from DB using local!request parameters*/
      local!export:exportdatasubsettobase64(
        datasubset:todatasubset(  local!entities),
        fieldLabels:{} /*The labels of header to set in Excel*/,
        fieldNames: {} /*The names of the datasubset fields to add to Excel*/,
      ),
      a!httpResponse(
        statusCode: 200,
        headers: 
          a!httpHeader(name: "Content-Type", value: "application/xlsx"),
       
          body: a!toJson(value: local!export)
      ),
      a!httpResponse(
        statusCode: 400,
        headers: 
        a!httpHeader(name: "Content-Type", value: "application/xlsx"),
    
        body: {}
      )
    )

    Create Integration:
    Calls the Web API using a POST method.
    Send request as for which identifier you want data(Create Request).
    Parses the JSON response from the Web API.
    Extracts the Base64 encoded data from the response body (likely from fv!result.body.base64Document).
    Decodes the Base64 data back into its original Excel format.
    Saves the decoded Excel data as an Appian document in the specified directory.




    Let me know if you have any questions.

Reply
  • 0
    Certified Senior Developer

    Hello  ,

    I would suggest you to use OOTB of appian to achieve this. We created xlsx file using below approach to create more than 50 columns to be exportable.

    Create Web API:
    Parse request using  a!fromJson( http!request.body)  and retrieve information to query data for which identifier.
    Retrieves data using queryEntity from your database using request identifier.
    Encodes the generated Excel data in Base64 format using exportDataSubsetToBase64 function.
    Sends the Base64 encoded data as the response body in the HTTP response with appropriate headers.

    a!localVariables(
        /*Create Helper CDT of Request Type*/
      local!request: a!fromJson( http!request.body),/*Parse Request Here and cast to helper cdt*/
      local!entities: /*Retrive Data Here from DB using local!request parameters*/
      local!export:exportdatasubsettobase64(
        datasubset:todatasubset(  local!entities),
        fieldLabels:{} /*The labels of header to set in Excel*/,
        fieldNames: {} /*The names of the datasubset fields to add to Excel*/,
      ),
      a!httpResponse(
        statusCode: 200,
        headers: 
          a!httpHeader(name: "Content-Type", value: "application/xlsx"),
       
          body: a!toJson(value: local!export)
      ),
      a!httpResponse(
        statusCode: 400,
        headers: 
        a!httpHeader(name: "Content-Type", value: "application/xlsx"),
    
        body: {}
      )
    )

    Create Integration:
    Calls the Web API using a POST method.
    Send request as for which identifier you want data(Create Request).
    Parses the JSON response from the Web API.
    Extracts the Base64 encoded data from the response body (likely from fv!result.body.base64Document).
    Decodes the Base64 data back into its original Excel format.
    Saves the decoded Excel data as an Appian document in the specified directory.




    Let me know if you have any questions.

Children
No Data