How to open a Word document from a MATLAB Web App
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have built a MATLAB app using AppDesigner and deployed it to the development web server. The app creates a Word document as part of its functionality and I now want to open it. This is not supported in report builder and I am trying to find an alternative that works. I have tried the web function but it reports that the app is being blocked by Edge and I cannot find a way around it. Any suggestions are welcome.
2 commentaires
Réponses (1)
Ruchika Parag
le 11 Juin 2025
You're correct that direct interaction with Word documents (such as opening them) from a deployed MATLAB Web App is not supported in the same way as desktop-based MATLAB applications, particularly due to browser sandboxing and security restrictions—such as those enforced by Microsoft Edge.
Here are a few alternatives and suggestions that may help:1. Offer File as a Download
Instead of trying to open the Word document directly:
- Save the file to a known location on the development server.
- Provide the user with a link or button in the app that triggers a download of the document.
You can use:
web('http://<server-path>/GeneratedReport.docx', '-browser')
Make sure the server is configured to serve static files from that path and that the browser is allowed to download from it.2. Embed via HTML (Optional Workaround)
In some setups, you may be able to embed the document inside an iframe or using Google Docs viewer, although this is limited and may not work consistently across environments.
Example (if hosted publicly):
web('https://docs.google.com/gview?url=http://<your-server>/GeneratedReport.docx&embedded=true', '-browser')
3. Client-Side Scripting (Advanced)
For more advanced deployments, consider implementing a lightweight front-end script or redirect that enables the document to be handled as a download, rather than opened inline, which can help bypass browser restrictions.
Note on Browser Blocking
If Microsoft Edge is explicitly blocking your action, this is likely due to:
- Cross-origin restrictions
- Automatic file opening behavior
- File type associations
In most cases, forcing a download is more reliable and secure than attempting to open the file directly from the web app.
0 commentaires
Voir également
Catégories
En savoir plus sur MATLAB Web App Server dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!