Read-Only in Excel

2 次查看(过去 30 天)
Philosophaie
Philosophaie 2013-9-18
When I execute the code below it prints out in Excel ok but it is in "Read-Only". How do I stop "Read-Only"?
exl = actxserver('excel.application');
exlWkbk = exl.Workbooks;
exlFile = exlWkbk.Open(['C:/MATLAB7/work/file.xls']);
exlSheet1 = exlFile.Sheets.Item('Sheet1');
mm=2
for t = 0:500:10000
mm=mm+1
vx1=6*t-800
vy1=3*t-300
vz1=2*t-100
vr1=(vx1^2+vy1^2+vz1^2)^.5
exlSheet1.Range(['B' num2str(mm)]).value = vx1;
exlSheet1.Range(['C' num2str(mm)]).value = vy1;
exlSheet1.Range(['D' num2str(mm)]).value = vz1;
exlSheet1.Range(['E' num2str(mm)]).value = vr1;
end
exl.visible = true;
exlWkbk.Close;
exl.Quit;

回答(1 个)

Titus Edelhofer
Titus Edelhofer 2013-9-18
Hi, I'm not sure what your question is. But in any case you will need to call
exlWkbk.Save
before you close it, since you modified it before. Second, if you get an error of "Read only", the natural question is: is your file read only (i.e., write protected)?
Titus

标签

Community Treasure Hunt

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

Start Hunting!

Translated by