最多支援26*26列資料記錄;
在**後面增加新資料。
測試程式
%寫資料到excel**
filename = ['./data/udp_truestates-',datestr(now,30),'.xls'];
v = [1 2 3];
p = [4 5 6];
headers = ;
num_length = length(headers);% 定義**的列數,**的列數與headers的長度相同
xls_row = num2str(1);
xls_colume_start = 'a'; %初始列。'a'表示從**的第一列開始寫起
%計算最後一列。excel列的命名方式是:a-z,ba-bz,...,za,-zz
%所以這裡最多支援26*26列
if rem(num_length,26) == 0
xls_colume_end = char('a' + mod(num_length,26) - 1);
else
colume_26 = rem(num_length,26);
xls_colume_first = char('a' + colume_26);
xls_colume_second = char('a' + mod(num_length,26) - 1);
xls_colume_end = [xls_colume_first, xls_colume_second];
endstart_point= [xls_colume_start, xls_row];
end_point = [xls_colume_end, xls_row];
xlrange = [start_point,':',end_point];
data = headers;
if length(data) < num_length
data = [data,zeros(1, num_length - length(data))];
endxlswrite(filename, data,xlrange);
for i = 1:10
xls_row = num2str(i+1); %更新行
data = ones(1,5)*i;
my_xlswrite(filename, xls_row, xls_colume_start, xls_colume_end, data, num_length)
endfunction my_xlswrite(filename, xls_row, xls_colume_start, xls_colume_end, data, norm_length)
start_point= [xls_colume_start, xls_row];
end_point = [xls_colume_end, xls_row];
xlrange = [start_point,':',end_point]; %更新寫入excel中的範圍
if length(data) < norm_length %給定的資料少於**的列數,少的資料用0補齊
data = [data,zeros(1, norm_length - length(data))];
endxlswrite(filename, data, xlrange);
end
效果
VC匯出CListCtrl資料到Excel兩種方法
vc匯出clistctrl資料到excel兩種方法 方法1 使用mfc的cdatabase類直接執行sql命令的方式實現 在檔案中包含標頭檔案 include include include void exportlisttoexcel clistctrl plist,cstring celfile...
VC匯出CListCtrl資料到Excel兩種方法
方法1 使用mfc的cdatabase類直接執行sql命令的方式實現 在檔案中包含標頭檔案 include include include void exportlisttoexcel clistctrl plist,cstring celfile cstring ssheetname 建立進行訪問...
使用HTML,CSS快速匯出資料到Excel
在head中加入css定義 mso number format 0 no decimals mso number format 0 000 3 decimals mso number format 0 000 comma with 3 dec mso number format mm dd yy d...