I want to write many values in the Excel sheet with two different color based on the condition. So I am using for loop. with in the for loop xlswrite used for write the value in xls and Excel = actxserver('Excel.Application') used for color the particular cell based on the condition. But I am getting the error that ".xls is not writable.It may be locked by another process." could you help me to resolve the issue. help me to use xlswrite and Excel = actxserver('Excel.Application') together (or) how to write a value in the particular cell by Excel = actxserver('Excel.Application')
The code is below
for intration1=1:row for intration2=1:column % logic for Calculate the values
% logic for Calculate the values range_ip=strcat(sprintf('%c','D'+(intration2)),num2str(10+intration1)); if condition Excel = actxserver('Excel.Application'); Excel.Workbooks.Open(strcat(pwd,'\',file)); Range= Excel.Range(range_ip); Range.Interior.ColorIndex = 4; else Excel = actxserver('Excel.Application'); Excel.Workbooks.Open(strcat(pwd,'\',file)); Range= Excel.Range(range_ip); Range.Interior.ColorIndex = 3; end endend
Thanks in Advance,
Regards, Suresh.S
Best Answer