※作成中
#ソース
CSVファイル表示.hta
<html>
<head>
<title>Title</title>
<hta:application
id="myApp"
applicationname="myApp"
border="thick"
borderstyle="normal"
caption="yes"
icon=""
maximizebutton="yes"
minimizebutton="yes"
showintaskbar="yes"
singleinstance="no"
sysmenu="yes"
version="1.0"
windowstate="normal"/>
<script type="text/javascript">
var fso = new ActiveXObject("Scripting.FileSystemObject"),
thisScriptPath = myApp.commandLine.replace(/^"|"$/g, ""),
folderPath = fso.GetParentFolderName(thisScriptPath),
fileName = "data.csv";
function init() {
var con = null, rs = null;
try {
con = openConnection(folderPath);
rs = con.Execute("select * from [" + fileName + "]");
writeCsvData(rs);
} catch (e) {
alert(e.description);
// throw e;
} finally {
if (rs != null) {
rs.Close();
}
if (con != null) {
con.Close();
}
}
}
function openConnection(folderPath) {
var con = new ActiveXObject("ADODB.Connection");
con.Provider = "Microsoft.Jet.OLEDB.4.0";
con.Properties("Extended Properties") = "Text;HDR=Yes;FMT=Delimited";
con.CursorLocation = 3;
con.Open(folderPath);
return con;
}
function writeCsvData(rs) {
document.write("<table border=1>");
// ヘッダー行
document.write("<tr>");
for (var f = 0; f < rs.Fields.Count; f++) {
document.write("<td>");
document.write(escapeHtml(rs.Fields(f).Name));
document.write("</td>");
}
document.write("</tr>");
// データ行
while (!rs.EOF) {
document.write("<tr>");
for (var f = 0; f < rs.Fields.Count; f++) {
document.write("<td>");
document.write(escapeHtml(rs.Fields(f).Value));
document.write("</td>");
}
document.write("</tr>");
rs.MoveNext();
}
document.write("</table>");
}
function escapeHtml(str) {
// ここでエスケープ処理を入れる予定
return str;
}
</script>
</head>
<body onload="init()">
</body>
</html>