specifying cells in xlswrite with excel syntax
1 次查看(过去 30 天)
显示 更早的评论
Hi, Is it possible to call excel cells as:
xlswrite('C:\Users\mpaulosk\Desktop\Folder\File.xls',{new},'Batch Data', cell)
where cell = (m, anew) and m and anew are updated in a for loop?
[~, ~, read] = xlsread('C:\Users\mpaulosk\Desktop\folder\prelim_gui.xls','Sheet1');
[~, ~, read2write] = xlsread('C:\Users\mpaulosk\Desktop\folder\file.xls','Batch Data');
paramtext = vertcat(read(1:7,1));
file2write = (read2write);
b = 350;
d = 375;
n = 1 ;
m = 1;
a = 10;
numcol = size (read2write)
for ii = 1:84
a = a + 1
if cellfun(@isnan,read2write(2,a)) == 1
store = read2write(2,a)
newa = a
break
elseif cellfun(@isnan,read2write(2,a)) == 0
a = a
else
error = uicontrol('Style', 'text', 'String', 'Error: Unable to locate empty column')
end
end
for ii = 1:6
b = b - 50
d = d-50
n = n + 1
m = m + 1
tparamnew = paramtext(n,1)
tparamnew = uicontrol('Style','text','String', tparamnew, ...
'Position',[100 b 150 40])
eparamnew = uicontrol('Style', 'edit', ...
'Position',[350 d 100 20], 'Callback', @write)
end
%cell = (m, newa)
function write(hObject,event)
current_string = get(hObject,'String');
new = str2num(current_string)
xlswrite('C:\Users\mpaulosk\Desktop\Quartette\Levo_EE.xls',{new},'Batch Data', cell)
tl;dr I need matlab to recognize something like (4,18) instead of D18
Thanks!
0 个评论
回答(2 个)
Image Analyst
2013-5-31
cell is the name of a built-in function so don't use it for your variable. Call it cellReference instead. cellReference has to be a string. According to the help:
xlRange — Rectangular portion of the worksheet to writestring
Rectangular portion of the worksheet to write, specified asa string.
Specify xlRange using the syntax 'C1:C2',where C1 and C2 are two opposingcorners that define the region to write. For example, 'D2:H4' representsthe 3-by-5 rectangular region between the two corners D2 and H4 onthe worksheet. The xlRange input is not case sensitive,and uses Excel A1 reference style (see Excel help). xlswrite doesnot recognize named ranges.
If you do not specify sheet, then xlRange mustinclude both corners and a colon character, even for a single cell(such as 'D2:D2'). Otherwise, xlswrite interpretsthe input as a worksheet name (such as 'D2').
If you specify sheet, then xlRange canspecify only the first cell (such as 'D2'). xlswrite writesinput array A beginning at this cell.
If xlRange is larger than the sizeof input array A, Excel software fills theremainder of the region with #N/A. If xlRange issmaller than the size of A, then xlswrite writesonly the subset that fits into xlRange to the file.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!