Xlsread/xlswrite error: unable to find the specified .xlsx file using a deployed web app

3 ビュー (過去 30 日間)
Giulio Francesca
Giulio Francesca 2018 年 7 月 28 日
コメント済み: Giulio Francesca 2018 年 7 月 30 日
Hi all,
I have compiled a web app which reads and writes .xlsx file on the machine that is running the procedure. However, when run from the web, program throws the exception saying that the specified xlsx file is not present. I don't have the same issue when running the app directly from the code (not through the compiled app).
Thank you in advance
  1 件のコメント
Giulio Francesca
Giulio Francesca 2018 年 7 月 28 日
I tried also spreadsheetDatastore function, but I receive same error: the file specified does not exists

サインインしてコメントする。

回答 (1 件)

Kojiro Saito
Kojiro Saito 2018 年 7 月 28 日
It is because WebApps creates a work folder when accessed by a user. For example, my WebApps on Windows has created the following temporary folder, C:\Users\MATLABWebAppsGuest\AppData\Local\MathWorks\webapps\services\mdwas\sessions\6f6d3719-a001-4112-9ad5-aae1bba9736f and this is a current folder of WebApps. These temporary folders are different by accesses. You can confirm where is current folder by
pwd
on WebApps.
I think there are two options.
1. Specifying full path of the Excel sheet instead of relative path. For example,
readtable(fullfile('C:', 'full', 'path', 'to', 'your.xlsx'))
2. If your Excel file is constant, i.e, reading the same Excel file, you can add the file to WebApps when compiling by adding "Files required for your app to run".
I hope this helps.
  4 件のコメント
Kojiro Saito
Kojiro Saito 2018 年 7 月 29 日
Could you tell me the command for reading your Excel file?
Giulio Francesca
Giulio Francesca 2018 年 7 月 30 日
xlsread(filepath\filename.xlsx)
I tried with spreadsheet datastore and it seems to work properly... it's like xlsread cannot be used in compiled web app

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeUse COM Objects in MATLAB についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by