CSV excel文件写入

时间:2016-10-07 23:00:44

标签: matlab

我在CSV excel文件中的数据格式为:

Column1    Column2    Column3    Column4
   23         45         67         56 
   34         456        54         58
   56         32         53         56

我想再添加一列,即Column5,只有1或0个值:

Column1    Column2    Column3    Column4    Column5
   23         45         67         56         0
   34         456        54         58         0
   56         32         53         56         1

有可能写吗?怎么做这个任务?

1 个答案:

答案 0 :(得分:0)

h = actxserver('Excel.Application');  % Open Activex Server
e = h.Workbooks.Open('test.csv');     % Open file
% Give full path if your path is not set like this: 'D:\Assignment\test.csv'

e.ActiveSheet.Range('E1:E3').Value = round(rand(3,1)); %Writing required data
e.Save           % Saving the changes
e.Close(false)   % Closing the file
h.Quit           % Quitting the Activex server

<强>比较

test file