Skip to content

How do I create a copy of my add-in's current workbook? #2224

Answered by PabloXV
PabloXV asked this question in Q&A
Discussion options

You must be logged in to vote

Well, I finally broke down and pasted this entire question into ChatGPT. It worked. The key was to combine all of the byte arrays using file slicing (basically just concatenating the slices into one large array) and then throwing it into Buffer.from(new Uint8Array(fileContent)).toString('base64');.

  Office.context.document.getFileAsync(Office.FileType.Compressed, { sliceSize: 65536 },
    function(result) {
      if (result.status == "succeeded") {
        const file = result.value;
        const sliceCount = file.sliceCount;
        let slicesReceived = 0;
        const fileContent = [];

        function readFile(sliceIndex) {
          file.getSliceAsync(sliceIndex, (sliceResult) => {…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@MalikSamiAwan
Comment options

@PabloXV
Comment options

Answer selected by PabloXV
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants