将表格设为单元矩阵,然后使用 xlswrite 将其保存到 xls
这将允许您导出具有混合内容类型(数字和文本)的表格。
[~,~,input] = xlsread('your_file.xls') % Read in your xls file to a cell array (input)
new_data = {'john', 22, 44, 3.53} % This is a cell array of the new line you want to add
output = cat(1,input,new_data); % Concatinate your new data to the bottom of input
xlswrite('output_file_name.xls',output); % Write to the new excel file.
如果你想保持相同的文件名,那么你可以稍微改变一下,就像这样
file = 'file_to_update.xls';
[~,~,input] = xlsread(file) % Read in your xls file to a cell array (input)
new_data = {'john', 22, 44, 3.53} % This is a cell array of the new line you want to add
output = cat(1,input,new_data); % Concatinate your new data to the bottom of input
xlswrite('file',output); % Write to the new excel file.
这样更有帮助吗?