Why do I get an error when using XLSREAD in a BATCH job submitted to a Windows cluster managed by MathWorks Job Scheduler in MATLAB Distributed Computing Server 6.0 (R2012a)?

8 views (last 30 days)
I am using a Windows cluster managed by MathWorks Job Scheduler.
I have a 'xlsReadTest.m' file is a script that contains a call to XLSREAD as follows:
[numData,textData,rawData] = xlsread('Test_SR.xlsx');
numProc = numel(numData);
results = NaN(size(numData));
parfor loopProc = 1:numProc
results(loopProc) = numData(loopProc) + 20;
end
When I run the 'xlsReadTest.m' script as a batch job with the following command:
batch(schedObj,'xlsReadTest','Matlabpool',31,'FileDependencies', {'xlsReadTest.m','Test.xlsx'});
I obtain the following error message: ERROR: ErrorIdentifier: MATLAB:COM:E2148140012 ErrorMessage: Invoke Error, Dispatch Exception: : Source: Microsoft Office Excel : Description: Microsoft Office Excel cannot access the file '..\..\Test.xlxs'.
If I use XLSREAD in basic mode, I am able to read the data.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 25 Jul 2017
Edited: MathWorks Support Team on 25 Jul 2017
Note that XLSREAD makes use of Excel's COM Automation Server. Further, MDCS Workers typically run under the SYSTEM account on Windows systems. Unfortunately, Excel's COM Automation Server by default does not work well when called from a process running under the SYSTEM account. There are two things which you may need to configure for Excel's COM Server to work well:
1. Excel requires the profile of the user account under which it runs to have a "Desktop" directory. The SYSTEM account does not have this by default and you will need to manually create it. If working with 32-bit Excel, create:
c:\Windows\SysWOW64\config\systemprofile\Desktop
If working with 64-bit Excel, create:
C:\Windows\System32\config\systemprofile\Desktop
2. Depending on your Excel version you may also need to configure the COM security settings correctly:
a. Navigation to Adminstrative Tools->Component Services->MyComputer->DCOM->Microsoft Excel Application
b. Right Click on Microsoft Excel Application and select Properties
c. Click the Security tab
d. Change Launch and Activation Permissions to Customize
e. Click Edit
f.  Add SYSTEM
g. Check Local Launch and Local Activation
  1 Comment
Arthur Roué
Arthur Roué on 13 Jun 2023
Edited: Arthur Roué on 13 Jun 2023
I have the same issue while using the Jenkins' Matlab Plugin. Matlab is executed in batch mode.
Neither of this tests work on my Jenkins Server :
function test_LectureXLSX(tc)
num = xlsread(tc.ficXLSX);
tc.assertEqual(num, [1 2 3 4])
end
function test_OuvertureExcel(tc)
which('actxserver');
hExcel = actxserver('Excel.Application');
hExcel.Visible = true;
hWorkBooks = hExcel.WorkBooks;
invoke(hWorkBooks, 'Open', tc.ficXLSX); % Error at this
invoke(hExcel, 'Quit');
end
I attached an example. If I run run_matlab_command.bat "runnerScript" in command Windows on my server, these tests passed. But if I run it through Jenkins with runMATLABTests command, they fail (it's the same account, with the same privilege running the same MATLAB executable.)
[poc-ci-pipeline@2] $ cmd.exe /C .matlab\eTmfKo77\run_matlab_command.bat '"addpath('C:\Users\runner\AppData\Local\Jenkins\.jenkins\workspace\poc-ci-pipeline@2/.matlab/eTmfKo77'); runner_eTmfKo77,delete('.matlab/eTmfKo77/runner_eTmfKo77.m'),runnerScript,rmdir(tmpDir,'s')"'
The error :
Error occurred in test_Jenkins/test_LectureXLSX and it did not run to completion.
---------
Error ID:
---------
'MATLAB:COM:E2148140012'
--------------
Error Details:
--------------
Error using xlsread (line 257)
Invoke Error, Dispatch Exception:
Source: Microsoft Excel
Description: Microsoft Excel ne peut acc�der au fichier
��C:\Users\runner\AppData\Local\Jenkins\.jenkins\workspace\poc-ci-pipeline@2\Jenkins\UnClasseur.xlsx��.
Plusieurs raisons sont possibles�:
Le nom du fichier ou le chemin d'acc�s n�existe pas.
Ce fichier est actuellement utilis� par un autre programme.
Le classeur que vous essayez d�enregistrer porte le m�me nom qu�un classeur actuellement ouvert.
Help File: xlmain11.chm
Help Context ID: 0
Error in test_Jenkins/test_LectureXLSX (line 42)
num = xlsread(tc.ficXLSX);
Any idea why ?

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Products


Release

R2012a

Community Treasure Hunt

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

Start Hunting!