Notes
Notes - notes.io |
APPLICATIONNAME="EXCEL処理用スクリプトサンプル"
BORDER="thick"
BORDERSTYLE="normal"
CAPTION="yes"
CONTEXTMENU="no"
ICON="value"
ID="value"
INNERBORDER="no"
MAXIMIZEBUTTON="yes"
MINIMIZEBUTTON="yes"
NAVIGABLE="no"
SCROLL="auto"
SCROLLFLAT="no"
SELECTION="yes"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="no"
SYSMENU="yes"
VERSION="value"
WINDOWSTATE="normal"/>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>EXCEL処理用スクリプトサンプル</title>
<script language="javascript">
/* ↓↓↓↓↓ここから↓↓↓↓↓ */
var PATH = function () {
var SEP = '\';
var p = document.location.pathname.replace(///g, SEP); // "/"と""の混在を統一
var a = p.split(SEP);
a.pop(); // 先頭の不要部分削除
a.shift(); // 末尾の不要部分削除
return a.join(SEP) + SEP;
}();
function Excel(filename) {
this.makeTmp(filename);
this.loadTmp();
}
Excel.prototype.getTmpName = function(ix) {
return PATH + ix + '.buf';
}
Excel.prototype.makeTmp = function(filename) {
var excel = new ActiveXObject("Excel.Application");
var wb = excel.Workbooks.Open(filename);
var xlCurrentPlatformText = -4158;
this.nofSht = wb.Sheets.Count;
for ( var i=1; i<=this.nofSht; i++) {
wb.Sheets.item(i).Activate();
wb.SaveAs(this.getTmpName(i), xlCurrentPlatformText); // タブ区切りで保存
}
wb.close(false);
}
Excel.prototype.loadTmp = function() {
var sep = function(data) {
var rows = data.split('rn');
var ret = [];
for ( var i in rows ) {
ret.push(rows[i].split('t'));
}
return ret;
};
var fso = new ActiveXObject("Scripting.FileSystemObject");
this.$ = [];
for ( var i=1; i<=this.nofSht; i++) {
var fn = this.getTmpName(i);
var stream = new ActiveXObject("ADODB.Stream");
stream.Mode = 3 // 読み取り/書き込みモード
stream.Type = 2 // テキストデータ
stream.Charset = "Shift_JIS" // 文字コードを指定
stream.Open();
stream.LoadFromFile(fn);
stream.Position = 0; // ポインタを先頭へ
var txt = stream.ReadText();
this.$.push(sep(txt));
stream.Close();
fso.DeleteFile(fn);
}
}
/* ↑↑↑↑↑ここまで↑↑↑↑↑ */
function exec() {
try {
var exl = new Excel(document.getElementById('path').value);
} catch(e) {
alert('読み込みに失敗しました。nn' + e);
return;
}
alert(exl.$.length);
for (var i in exl.$) {
alert(exl.$[i].length);
}
}
</script>
</head>
<body>
<div class="container">
<div class="container-fluid">
<h1>EXCEL処理用スクリプトサンプル</h1>
<hr>
<p>EXCELデータ全セルをメモリに読み込みます。</p>
<div class="alert alert-info" role="alert">
<tt>var exl = new Excel(ファイルパス);</tt>
</div>
<p>を実行すると、</p>
<div class="alert alert-info" role="alert">
<tt>exl.$[シート番号][行番号][列番号]</tt>
</div>
<p>の形で、3次元配列のデータが生成されます。</p>
<br>
<div class="input-group">
<input type="text" class="form-control" placeholder="ファイルパス(ペーストしてください)" aria-describedby="basic-addon1" id="path">
<button type="button" class="btn btn-primary" onclick="exec()">実行</button>
</div>
</div>
</div>
</body>
</html>
----------------------------------------------------------------------
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<hta:application applicationname="Neo's Memo" singleinstance="yes" showintaskbar="no" caption="no" border="none" innerborder="no" navigable="yes">
<title>Neo's Memo</title>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<style>
html,
body {
width:100%;
height:100%;
overflow:hidden;
}
body {
padding:10px;
}
#text {
height:141px;
margin-bottom:6px;
font-family:"MeiryoKe_Gothic", "MS Gothic", monospace;
background:#fcfcfc;
overflow-y:scroll;
}
#msg {
display:inline-block;
margin-left:2rem;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script>
/** File Location */
var FILE = location.href.replace("file:///", "").replace(location.href.split("/").pop(), "Memo_" + getDate() + ".md");
/** Indent : 2 Spaces */
var INDENT = " ";
$(function () {
setWindow();
loadText();
$("#save").on("click", saveText);
$(window).on("keydown", function(e) {
// Ctrl + S
// http://stackoverflow.com/questions/93695/best-cross-browser-method-to-capture-ctrls-with-jquery
if(e.ctrlKey && (e.keyCode === 115 || e.keyCode === 83)) {
saveText();
}
});
var textarea = document.getElementById("text");
$("#text").on("keydown", function(e) {
if(e.keyCode === 9) {
e.preventDefault();
var start = textarea.selectionStart;
var end = textarea.selectionEnd;
var before = textarea.value.substring(0, start);
var after = textarea.value.substring(end, textarea.value.length);
textarea.value = before + INDENT + after;
textarea.selectionStart = textarea.selectionEnd = end + INDENT.length - (end - start);
}
});
});
function setWindow() {
if(location.search === "") {
// Default Mode
// Position Center
var width = 750;
var height = 200 + 40; // Includes height of title-bar
window.resizeTo(width, height);
window.moveTo((screen.availWidth - width) / 2, (screen.availHeight - height) / 2);
}
else if(~location.search.indexOf("noborder")) {
// No Border Mode
// Draggable Window
// http://write-off.cside.com/scripts/hta/movewin.htm
var drag = false, posX, posY;
$("#control")
.on("mousedown", function(e) { drag = true; posX = e.clientX; posY = e.clientY; })
.on("mousemove", function(e) { if(drag) { window.moveTo(e.screenX - posX, e.screenY - posY); } })
.on("mouseup" , function() { drag = false; });
}
}
function loadText() {
var fso = new ActiveXObject("Scripting.FileSystemObject");
var file;
var msg = "";
try {
file = fso.OpenTextFile(FILE, 1, false, false);
// | | |
// | | +-- Tristate False : Open the file as ASCII.
// | +--------- Create False : Do not create new file.
// +------------ For Reading : Open a file for reading only.
msg += "File Opened, ";
}
catch(e) {
file = fso.CreateTextFile(FILE, false, false);
// | |
// | +-- Format ASCII : Create an ASCII file.
// +--------- Overwrite False : Do not permit overwriting of existing file.
msg += "File Created, ";
}
if(fso.GetFile(FILE).Size > 0) {
try {
var data = file.ReadAll();
$("#text").val(data);
msg += "Text Loaded."
}
catch(e) {
msg += "Load Error (" + e + ").";
}
}
else {
msg += "0 Byte File."
}
$("#msg").text(msg + " ... " + getDateTime());
file.Close();
file = null;
fso = null;
}
function saveText() {
var fso = new ActiveXObject("Scripting.FileSystemObject");
var file;
try {
file = fso.OpenTextFile(FILE, 2, false, false);
// | | |
// | | +-- Tristate False : Open the file as ASCII.
// | +--------- Create False : Do not create new file.
// +------------ For Writing : Open a file for writing.
}
catch(e) {
$("#msg").text("File Open Error (" + e + "). ... " + getDateTime());
return;
}
var msg = "";
var data = $("#text").val();
try {
file.Write(data);
msg += "File Saved.";
}
catch(e) {
msg += "Save Error (" + e + ")";
}
$("#msg").text(msg + " ... " + getDateTime());
file.Close();
file = null;
fso = null;
}
function getDate() {
var d = new Date();
return d.getFullYear()
+ "-" + ("0" + (d.getMonth() + 1)).slice(-2)
+ "-" + ("0" + d.getDate()).slice(-2);
}
function getDateTime() {
var d = new Date();
return d.getFullYear()
+ "-" + ("0" + (d.getMonth() + 1)).slice(-2)
+ "-" + ("0" + d.getDate()).slice(-2)
+ " " + ("0" + d.getHours()).slice(-2)
+ ":" + ("0" + d.getMinutes()).slice(-2)
+ ":" + ("0" + d.getSeconds()).slice(-2);
}
</script>
</head>
<body>
<div id="wrapper">
<textarea id="text" class="form-control"></textarea>
<div id="control">
<input id="save" class="btn btn-info" type="button" value="Save">
<span id="msg" class="text-muted"></span>
</div>
</div>
</body>
</html>
----------------------------------------------------------------
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=IE9">
<hta:application applicationname="Neo's Memo" singleinstance="yes" showintaskbar="no" caption="no" border="none" innerborder="no" navigable="yes">
<title>Execute Neo's Memo</title>
<style>
html,
body {
overflow:hidden;
text-align:center;
}
a {
color:#f0f0f0;
}
</style>
<script>
window.onload = function() {
var width = 750;
var height = 200;
window.resizeTo(width, height);
window.moveTo((screen.availWidth - width) / 2, (screen.availHeight - height) / 2);
// Always On Top (Using Excel)
// http://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q12151482357
try {
var excel = new ActiveXObject("Excel.Application");
var hwnd = excel.ExecuteExcel4Macro("CALL("user32", "FindWindowA", "JCC", "HTML Application Host Window Class", "" + document.title + "")");
excel.ExecuteExcel4Macro("CALL("user32", "SetWindowPos", "JJJJJJJJ", " + hwnd + ", -1, 0, 0, 0, 0, 3)");
excel = null;
}
catch(e) {
// Do nothing...
}
location.href = "Main.hta?mode=noborder";
}
</script>
</head>
<body>
<p><a href="Main.hta?mode=noborder">Move To Neo's Memo</a></p>
</body>
</html>
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team