楼主这个好像是从Excel或数据库中导出来的?其实用原生方法更简单,为什么要变成文本?- @set @n=0//&cscript.exe -e:jscript "%~f0"&exit /b
-
- file = "考勤.txt";
-
- fso = new ActiveXObject("Scripting.FileSystemObject");
- s = fso.OpenTextFile(file).ReadAll();
- s = s.replace(/^\s+|\s*\n\s*/g,'\r\n').replace(/ +/g,',');
- temp = '#'+file;
- ts = fso.OpenTextFile(temp, 2, true);
- ts.write(s); ts.close();
-
- strConnect = 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.;'
- + 'Extended Properties="text;HDR=yes;FMT=Delimited;";';
- AdoCnn = new ActiveXObject("ADODB.Connection");
- AdoCnn.ConnectionString = strConnect;
- AdoCnn.Open();
- s = "姓名,日期,上班时间,下班时间\r\n";
- AdoRs = new ActiveXObject("ADODB.Recordset");
- AdoRs.Open("SELECT [a.姓名],[a.日期],[a.打卡时间],[b.打卡时间] from ["+temp+"] as a inner join ["+temp+"] as b ON (a.[姓名]=b.[姓名] AND a.[日期]=b.[日期] AND a.[打卡时间]<b.[打卡时间])", AdoCnn, 3);
- s += AdoRs.GetString(2, AdoRs.RecordCount, ",", "\r\n");
- fso.OpenTextFile('result.csv', 2, true).write(s);
- AdoRs.Close();
- AdoCnn.Close();
- fso.DeleteFile(temp);
复制代码
|