<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>文件操作</title> <style>
</style>
<script type="text/javascript" src="jquery-1.9.1.js"></script> <script type="text/javascript" language="javascript">
try{ var file=new ActiveXObject("Scripting.FileSystemObject"); var text=file.CreateTextFile("d://CHS.xml",true); text.WriteLine("<?xml version=‘1.0‘ encoding=‘utf-8‘?>"); text.WriteLine("<StringTable>"); var excelName="d://test.xls"; var excl=new ActiveXObject("Excel.application"); var ob=excl.Workbooks.open(excelName); ob.worksheets(1).select();
var activeSheets=ob.ActiveSheet; var rowCount=activeSheets.rows.count;
for(var i=2;i<rowCount;i++) { if(activeSheets.Cells(i,1).value==null) break; var str="<string id=‘"+activeSheets.Cells(i,1).value+"‘>"+activeSheets.Cells(i,2).value+"</string>"; text.WriteLine(str);
}
text.WriteLine("</StringTable>") text.Close(); ob.Application.Quit(); //手动调用垃圾收集器 CollectGarbage();
} catch(e) { ob.Application.Quit(); //手动调用垃圾收集器 CollectGarbage(); text.Close(); }
</script> </head>
<body>
</body> </html>