xlswrite error is " The document may be read-only or encrypted"

6 次查看(过去 30 天)
I am try to store the data in excel sheet. But after some data entered into excel file it showing an error is
Error using xlswrite (line 220)
Invoke Error, Dispatch Exception:
Source: Microsoft Excel
Description: Excel cannot access '1.xls'. The document may be read-only or encrypted.
Help File: xlmain11.chm
Help Context ID: 0
Error in A (line 12)
xlswrite('1.xls',n{j},'1',cellRef);
my code is
i=1;
x=cell(1,281);
n=cell(1,281);
for j=26:281
cellRef = sprintf('A%d:BC%d',j,j);
x{j} = imread(sprintf('E:/apps/project/TELUGU data/telugu sep/%d/ (%d).jpg',i,j))
n{j} = feature_extractor_2d(x{j});
xlswrite('1.xls',n{j},'1',cellRef);
end

回答(1 个)

Walter Roberson
Walter Roberson 2016-5-24
If you are using any version before R2016a then I recommend you use xlswrite1 from the File Exchange. Currently each of those xlswrite() within the loop is establishing and closing an ActiveX connection, which is slow enough that sometimes it has not quite finished by the time you want to establish the next connection.
Be sure to read the instructions for xlswrite1
  1 个评论
Image Analyst
Image Analyst 2016-5-24
Yes, definitely. You would not want to call xlswrite 255 times (before R2016a)! It will take forever even if it did work. Most likely reason I think is that Excel still has the file open and you're trying to write to it again, which means it launches Excel and tries to open it again when it's already open.
Better is to just build up your cell arrays first and call xlswrite once, or else use ActiveX (like I do).

请先登录,再进行评论。

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by