How to open a Word document from a MATLAB Web App

8 visualizzazioni (ultimi 30 giorni)
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 Commenti
NVSL
NVSL il 21 Apr 2025
Modificato: NVSL il 21 Apr 2025
I suggest upgrading to the latest release of MATLAB and try again
Walter Roberson
Walter Roberson il 21 Apr 2025
AppDesigner did not exist in R2006a.

Accedi per commentare.

Risposte (1)

Ruchika Parag
Ruchika Parag il 11 Giu 2025
Hi @David Seddon, thank you for reaching out.
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.

Categorie

Scopri di più su MATLAB Web App Server in Help Center e File Exchange

Prodotti


Release

R2006a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by