1

I am building an Excel Add-in and would like to create a new workbook that is a copy of the currently open workbook.

I am able to create an empty workbook using Excel.createWorkbook(), I am able to read the currently open file as plaintext using Office.context.document.getFileAsync(), and I am even able to create a duplicate of an existing file using Excel.createWorkbook(base64) where base64 is the output of an online converter like this one.

However, I am unable to connect these pieces together. In particular, I've found that Office.context.document.getFileAsync() and its documentation don't clearly explain how to get the necessary base64 format of the file. As I said, I can load the file as plaintext or a byte array, but not base64. I believe that once I can figure this part out, I can use the base64 to create a duplicate of the currently open file.

In the docs, there is a section about creating a copy of an existing workbook. The docs go on to say that:

You can get your add-in's current workbook as a base64-encoded string by using file slicing.

The docs claim that we can get the current workbook as a base64-encoded string, but the function mentioned requires a FileType which only has 3 options: Text, Compressed Byte Array, and PDF. None of these are base64 encoded. Do I have to manually convert these myself? The documentation is a bit lacking in this area.

Sunderam Dubey
  • 1
  • 11
  • 20
  • 40
Pablo V
  • 11
  • 4

0 Answers0