xlswrite fails to write an excel file when a Matlab process is ran from Jenkins.

We have a series of tests here that puts their results into an excel spreadsheet. We have been running these test for a few years by hand inside of a Matlab interactive session. I have been brought in to automate the process and I have set up jenkins and configured a jenkins job to run the matlab session on a local test server.
1) I can log into the system start up a matlab session and the tests will run fine and the excel spreadsheets get created correctly.
2) The jenkins client process on the test server is running as a service using my name and password.
3) When running under Jenkins the same set of tests will fail withe the following exception:
pre-formated
Error using xlswrite (line 220)
Invoke Error, Dispatch Exception:
Source: Microsoft Excel
Description: SaveAs method of Workbook class failed
Help File: xlmain11.chm
Help Context ID: 0
I debug the code and it appears that the Excel datatype is getting created and then a empty workbook is added. Then when the saveas is done it fails. If anyone has any ideas on what is going on, I appreciate it.
MATLAB Version: 8.1.0.604 (R2013a)
Operating System: Microsoft Windows 7 Version 6.1 (Build 7601: Service Pack 1)
Java Version: Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot(TM) Client VM mixed mode
------------------------------------------------------------------------------------------------
MATLAB Version 8.1 (R2013a)
Embedded Coder Version 6.4 (R2013a)
MATLAB Coder Version 2.4 (R2013a)
MATLAB comment stripping toolbox Version 1.0
Signal Processing Toolbox Version 6.19 (R2013a)
>>

2 Comments

Is it possible that the jenkins job is in a different directory than you expect and you have not given a full path for the file to save?
The path to the excel file is a full path and is stored on the network. I also went into the xlswrite routine itself and hardcoded it to always use c:\temp\joe.xls and got the same issue.

Sign in to comment.

 Accepted Answer

I was running into the same issue and fixed it with the following solution. The automatic process that launches MATLAB from Jenkins calls Excel when using xlswrite. It uses a Windows system user account to launch the process and Excel is looking for the 'Desktop' directory within this system account.
For x64 processes create the following folder:
C:\Windows\SysWOW64\config\systemprofile\Desktop
For x86 processes create the following folder:
C:\Windows\System32\config\systemprofile\Desktop

2 Comments

Thanks! I was having the same problem and this fixed it. I spent hours trying to figure it out.
I have created the desktop folder and still i am not able to edit the excel file using Matlab script in Jenkins, Is there any other solution?

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!