Note: This repo is archived and no longer actively maintained. Security vulnerabilities may exist in the project, or its dependencies. If you plan to reuse or run any code from this repo, be sure to perform appropriate security checks on the code or dependencies first. Do not use this project as the starting point of a production Office Add-in. Always start your production code by using the Office/SharePoint development workload in Visual Studio, or the Yeoman generator for Office Add-ins, and follow security best practices as you develop the add-in.
This code sample teaches you the different techniques for downloading files programmatically in an Office Add-in. Different Office hosts and browsers (when using Office Online) may handle files differently. If you'd like to provide a uniform file download experience, use the techniques demonstrated in this code sample. This code sample also shows you how you can provide a fallback mechanism if the Office host or browser does not support one of the other methods.
- Change History
- Prerequisites
- Design templates used in this add-in
- Get the FileSaver library
- Run the project
- Questions and comments
- Additional resources
November 3, 2016:
- Initial version.
- Word 2016 for Windows (build 16.0.6727.1000 or later), Word Online, or Word for Mac (build 15.26 or later).
- Visual Studio 2015
- Landing page
For more information about the design patterns, see UX design pattern templates for Office Add-ins. And for sample implementations, see Office-Add-in-UX-Design-Patterns-Code.
This code sample uses the FileSaver.js library. Take the following steps after you have cloned this repo.
- Clone the FileSaver.js repo.
- Copy the FileSaver.min.js file to the Scripts folder of this code sample.
- In Home.html, add a script tag to reference the FileSaver.min.js file.
- Open the Visual Studio solution file.
- Press F5.
- When Word opens, click the File download button on the right end of the Home ribbon. The add-in opens in a task pane.
- Choose the Download file or Insert download link buttons.
We'd love to get your feedback about this sample. You can send your feedback to us in the Issues section of this repository.
Questions about Microsoft Office 365 development in general should be posted to Stack Overflow. If your question is about the Office JavaScript APIs, make sure that your questions are tagged with [office-js] and [API].
- Office add-in documentation
- Office Dev Center
- More Office Add-in samples at OfficeDev on Github
Copyright (c) 2016 Microsoft Corporation. All rights reserved.
This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.