can xlsread read everything as strings ? if not, are there any other options ?
7 次查看(过去 30 天)
显示 更早的评论
it seems xlsread will distinguish between numbers and strings, thus unable to read EVERYTHING as strings. am i correct? If so, i can only think of using actxserver and reading the content cell-by-cell. However, it requires that the cell displays the full content, that is, it cannot display something like '#####' which is what you'll see in excel if the number is too long. is there any easier option ? thanks so much
1 个评论
Guillaume
2014-11-25
编辑:Guillaume
2014-11-25
Your premise is wrong. What is displayed in the cell by excel in no way prevents you from reading the full content of the cell. The two are completely independent.
What is displayed is the Text property of the Range object, the value of the cell is the value property of the Range object.
回答(2 个)
Guillaume
2014-11-25
Note that it is excel returning numbers as numbers and text as text (xlsread uses actxserver behind the scene), so if you want numbers as strings, you'll have to do the conversion yourself:
[~, ~, raw] = xlsread('somefile');
for idx = 1:numel(raw)
if isnumeric(raw{idx})
raw{idx} = num2str(raw{idx});
end
end
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!