-1

I'm new to Excel Web Add-Ins and want to figure out if it's possible to make an add-in that can export a custom file.

I've looked around and all I find are Excel specific commands like Workbook.SaveAs() but I can't find anything on making custom export functions. I need to convert the file into XML but a specific XML setup and so, I could just work the data before I save it to XML. But again, can't find much of anything to suggest that this is supported.

How would I go about writing a file to disk from Excel that isn't just the Workbook?

OmniOwl
  • 5,477
  • 17
  • 67
  • 116
  • You know tag spamming is not recommended. It generally attracts downvotes from more people. – Andreas Feb 19 '21 at 09:19
  • Since XML is just text, I assume this will be what you need: https://stackoverflow.com/questions/11503174/how-to-create-and-write-to-a-txt-file-using-vba – Andreas Feb 19 '21 at 09:21
  • @Andreas It was not an attempt at tag spamming honestly. I didn't really know which tags were most useful for my problem. I've done Add-ins for Office 2013 but those were more or less pure C#. I haven't tried to make Excel Web Add-Ins and when I google for the subject, I get a ton of noise on how to install add-ins and very little useful information on Add-in Development. – OmniOwl Feb 19 '21 at 09:25
  • @Andreas I checked out your answer and it's not what I need. It's VBA and seems to be using .NET classes and as far as I can tell Excel Web Add-Ins use Javascript. – OmniOwl Feb 19 '21 at 09:28

2 Answers2

1

There's no such API to support exporting custom file to disk. It seems we can have workaround to do this work, this workaround just works for excel online. Please see this link: How to create a file in memory for user to download, but not through server?

Jinghui-MSFT
  • 121
  • 4
0

The closest thing there is for what you want to do is:

Office.context.document.getFileAsync(Office.FileType.Compressed, (result) => {
  const file = result.value;
  // do whatever ...
});

The file variable in this case contains the entire document in Office Open XML (OOXML) format as a byte array.

CodingAnxiety
  • 206
  • 2
  • 13