• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    Saving Excel Report returned from API call

    User help
    1
    1
    270
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • cbyrneC
      cbyrne
      last edited by cbyrne

      I'm trying to save an excel report returned after calling /rest/latest/excel-reports/download/{XID}

      My first attempt doubles the file size so it looks like I'm saving bytes as chars.

              saveExcelFile(data, report_filename) {
                  let link = document.createElement("a");
                  let blob = new Blob([data], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'})
                  link.href = URL.createObjectURL(blob);
                  link.download = report_filename;
                  link.click();
                  URL.revokeObjectURL(link.href)
                  link.remove();
              }
      

      The response payload looks to be base64 encoded but calling atob fails.

      I've also played around with a string to array buffer function to convert the data which gives me the correct filesize but still not a completely correct conversion.
      https://stackoverflow.com/questions/34993292/how-to-save-xlsx-data-to-file-as-a-blob

      A comparison of the hexdumps: (working file on left, file from original code snippet above on right)

      91190d97-56ea-486c-8d0d-f08e3c3de08c-image.png

      From the hexdump I can see that the first ~49 bytes are are correct but then the encoding changes

      Software Developer for GLAS Energy Technology, Ireland

      1 Reply Last reply Reply Quote 0
      • First post
        Last post