MATLAB Answers

0

an element of a cell array doesn't appear when I send to excel file

Asked by Amine ELMOUATAMID on 30 Apr 2019
Latest activity Commented on by Amine ELMOUATAMID on 30 Apr 2019
dddddd.PNG I want to change out(8,2) to be 'S-PC-K6301'
rrrrr.PNG I use this trick
ggggg.PNG it becomes like this
but when I send the cell array to my excel file it appears like this rerrrrr.PNG
can someone explain why this happens ?

  2 Comments

Could you share the section of code that changes the cell value and writes to the excel file?
%% put data from RMS to out
j=1;
i=2;
while i <= sizeOut(1,1)
if all(~isnan(out{i,2}))&& contains(out{i,2},serie)
for j=j+1 : rowRMS(1,1)
if all(~isnan(out{i,1})) && contains(out{i,1},RMS{j,1})
for k=9:16
if all(~isnan(out{i,k})) && contains(out{i,k},PointName)
if all(~isnan(out{i+1,8})) && contains(out{i+1,8},MeasTypeID)
out{i+1,k}=RMS{j,2};
break
else
if all(~isnan(out{i+2,8})) && contains(out{i+2,8},MeasTypeID)
out{i+2,k}=RMS{j,2};
break
else
if all(~isnan(out{i+3,8})) && contains(out{i+3,8},MeasTypeID)
out{i+3,k}=RMS{j,2};
break
end
end
end
end
end
else
for n=2 : sizeOut(1,1)
if all(~isnan(out{n,1})) && contains(out{n,1},RMS{j,1})
out=insertrows(out,out(n:7,1:27),n+5);
for k=9:16
if all(~isnan(out{n+6,k})) && contains(out{n+6,k},PointName)
if all(~isnan(out{n+7,8})) && contains(out{n+7,8},MeasTypeID)
out{n+7,k}=RMS{j,2};
break
else
if all(~isnan(out{n+8,8})) && contains(out{n+8,8},MeasTypeID)
out{n+8,k}=RMS{j,2};
break
else
if all(~isnan(out{n+9,8})) && contains(out{n+9,8},MeasTypeID)
out{n+9,k}=RMS{j,2};
break
end
end
end
end
end
closeexcel;
data=zeros(6,27);
xlsappend(File,data,'relevés journalier');
Excel = actxserver('Excel.Application');
Workbooks = Excel.Workbooks;
% Open Excel file
Workbook=Workbooks.Open(File);
% Tell it to not wait and pop up alerts like "This file exists. Do you want to overwrite it.
Excel.DisplayAlerts = false;
% Specify sheet number,and range to write to
%%sheetnum = InputBox(Excel,'numero de fenêtre :','Ma boite de dialogue',[],[],[],[],[],1)
%%range = 'A1:AA3458';
% Make the first sheet active
Sheets = Excel.ActiveWorkBook.Sheets;
sheet1 = get(Sheets, 'Item','relevés journalier');
invoke(sheet1, 'Activate');
Activesheet = Excel.Activesheet;
DataRange = Excel.ActiveSheet.UsedRange;
r = DataRange.Address;
r1 = regexp(r, ':', 'split');
end_cell = regexprep(r1{2}, '\$', '');
start_cell = 'A1';
range = [start_cell ':' end_cell];
break
end
end
C='S-PC-';
serie=cellstr(serie);
out{n+6,2}=strcat(C,serie);
%%out{n+6,2}=cellstr(out{n+6,2});
end
break
end
end
sizeOut=size(out);
i = i+1;
end
%%
%Put MATLAB data into Excel
ActivesheetRange = get(Activesheet,'Range',range);
set(ActivesheetRange, 'Value', out);
Excel.ActiveWorkbook.Save;
%%
ActivesheetRange = get(Activesheet,'Range',range);%%
set(ActivesheetRange, 'Value',out);
%%
%Close Excel and clean up
closeexcel;
%%clear all;

Sign in to comment.

0 Answers