
(* 設定目錄 *)
home=SetDirectory["~/Temp"];
(* 新增目錄 *)
CreateDirectory["new"];
(* 將副檔名為xls的檔案取出 *)
fn=FileNames["*.xls"];
exceltrans[file_String,cell1_String,cell2_String]:=Block[{data},
(* 資料輸入 *)
data=Import[file,"Data"][[1]];
(* 加上自訂字元 *)
data[[1]]=cell2<>#&/@data[[1]];
data[[1,1]]=cell1;
(* 資料輸出 *)
Export[home<>"/new/"<>StringReplace[file,".xls"->""]<>"-head.xls",data]
]
(* 全部轉換 *)
Map[exceltrans[#,"Name","Score"]&,fn]
讀者回應 ( 0 意見 )
訂閱發佈留言 (Atom)
發佈留言
Please leave your name and tell me what you thought about this site. Comments, suggestions and views are welcomed.
如果這篇文章對你有幫助,那請留個訊息給我~