<style>
#excel {width: 800px; height: 400px; overflow: auto; border: 1px solid #ccc}
#excel table { width: 2000px; border-spacing:0 }
#excel table th {font-weight: normal; background-color: #eee}
#excel table th, #excel table td { height: 20px; border: 1px solid #ddd; }
#excel table td {text-align: right; padding: 0; }
#excel table input {border:none; border-right:0px; border-top:0px; boder-left:0px; boder-bottom:0px; outline-style: none; font-size: 1em }
</style>
<div id="excel"></div>
<script>
function Excel(label, rows, cols) {
this.div = document.getElementById(label);
this.table = document.createElement('table');
this.rows = rows;
this.cols = cols;
this.clicked = null;
this.cells = [];
}
Excel.prototype.init = function() {
var tr = {}, el = {}, r = 0, c = 0, tr = document.createElement('tr')
for (c=0; c<this.cols; c++) {
el = document.createElement('th');
el.style.width = Math.round(100 / this.cols * 10) / 10 + '%';
if (c != 0) el.textContent = String.fromCharCode(64 + c);
tr.appendChild(el);
}
this.table.appendChild(tr);
for (r=1; r<this.rows; r++) {
tr = document.createElement('tr');
for (c=0; c<this.cols; c++) {
if (c !=0) el= document.createElement('td');
else {
el= document.createElement('th');
el.textContent = r;
}
tr.appendChild(el);
}
this.table.appendChild(tr);
}
this.div.appendChild(this.table);
};
Excel.prototype.getPos = function(obj) {
var pos = {};
pos.r = obj.parentNode.rowIndex;
pos.c = obj.cellIndex;
return pos;
}
Excel.prototype.click = function() {
var td = this, textbox, text, pos = excel.getPos(this);
if (excel.clicked != null) excel.clicked.style.border = '1px solid #ddd';
this.style.border = '1px solid blue';
excel.clicked = this;
textbox = document.createElement('input');
if (this.hasChildNodes()) {
if (this.firstChild.nodeName == 'INPUT') return;
else {
text = this.firstChild.textContent;
textbox.value = excel.cells[pos.r + ',' + pos.c];
this.removeChild(this.firstChild);
}
}
textbox.type = 'text';
textbox.style.width = (this.offsetWidth - 2) + 'px';
textbox.style.height = (this.offsetHeight - 4) + 'px';
this.appendChild(textbox);
this.firstChild.focus();
textbox.onblur = function(){
text = this.value;
this.remove(0);
excel.cells[pos.r + ',' + pos.c] = text;
if (text.match(/^=/)) text = eval( text.replace('=', '') );
td.textContent = text;
};
}
Excel.prototype.edit = function() {
var table, tr = {}, el = {}, r = 0, c = 0,
table = this.div.childNodes[0];
for (r=1; r<this.rows; r++) {
for (c=1; c<this.cols; c++) {
el = table.rows[r].cells[c];
el.onclick = this.click;
el.onkeydown = this.keydown;
}
}
};
Excel.prototype.keydown = function(e) {
var pos = excel.getPos(this), e = e || window.event;
switch (e.keyCode) {
case 38 : pos.r -= 1; break;
case 40 : case 13: pos.r += 1; break;
case 37 : pos.c -= 1; break;
case 39 : pos.c += 1; break;
}
if (pos.r < 1 || pos.r > excel.rows-1 || pos.c < 1 || pos.c > excel.cols-1) return;
excel.table.rows[pos.r].cells[pos.c].click();
};
var excel = new Excel('excel', 40, 27);
excel.init();
excel.edit();
</script>
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7930 | 9년 전 | 421 | ||
| 7929 | 9년 전 | 348 | ||
| 7928 | 9년 전 | 437 | ||
| 7927 | 9년 전 | 356 | ||
| 7926 | 9년 전 | 673 | ||
| 7925 | 9년 전 | 375 | ||
| 7924 | 9년 전 | 355 | ||
| 7923 | 9년 전 | 357 | ||
| 7922 | 9년 전 | 392 | ||
| 7921 | 9년 전 | 408 | ||
| 7920 | 9년 전 | 328 | ||
| 7919 | 9년 전 | 342 | ||
| 7918 | 9년 전 | 496 | ||
| 7917 | 9년 전 | 349 | ||
| 7916 | 9년 전 | 422 | ||
| 7915 | 9년 전 | 422 | ||
| 7914 | 9년 전 | 435 | ||
| 7913 | 9년 전 | 598 | ||
| 7912 | 9년 전 | 439 | ||
| 7911 | 9년 전 | 379 | ||
| 7910 | 9년 전 | 419 | ||
| 7909 | 9년 전 | 524 | ||
| 7908 | 9년 전 | 446 | ||
| 7907 | 9년 전 | 391 | ||
| 7906 | 9년 전 | 410 | ||
| 7905 | 9년 전 | 387 | ||
| 7904 | 9년 전 | 372 | ||
| 7903 | 9년 전 | 362 | ||
| 7902 | 9년 전 | 570 | ||
| 7901 |
|
9년 전 | 751 | |
| 7900 | 9년 전 | 608 | ||
| 7899 | 9년 전 | 405 | ||
| 7898 | 9년 전 | 404 | ||
| 7897 | 9년 전 | 364 | ||
| 7896 | 9년 전 | 371 | ||
| 7895 | 9년 전 | 482 | ||
| 7894 | 9년 전 | 409 | ||
| 7893 | 9년 전 | 363 | ||
| 7892 | 9년 전 | 412 | ||
| 7891 | 9년 전 | 781 | ||
| 7890 | 9년 전 | 1206 | ||
| 7889 | 9년 전 | 755 | ||
| 7888 |
limsy1987
|
9년 전 | 559 | |
| 7887 | 9년 전 | 573 | ||
| 7886 | 9년 전 | 467 | ||
| 7885 | 9년 전 | 428 | ||
| 7884 | 9년 전 | 428 | ||
| 7883 | 9년 전 | 426 | ||
| 7882 | 9년 전 | 480 | ||
| 7881 | 9년 전 | 458 | ||
| 7880 | 9년 전 | 593 | ||
| 7879 | 9년 전 | 480 | ||
| 7878 | 9년 전 | 1237 | ||
| 7877 | 9년 전 | 768 | ||
| 7876 | 9년 전 | 505 | ||
| 7875 | 9년 전 | 578 | ||
| 7874 |
|
9년 전 | 819 | |
| 7873 | 9년 전 | 530 | ||
| 7872 | 9년 전 | 693 | ||
| 7871 | 9년 전 | 495 | ||
| 7870 | 9년 전 | 625 | ||
| 7869 | 9년 전 | 443 | ||
| 7868 | 9년 전 | 470 | ||
| 7867 | 9년 전 | 452 | ||
| 7866 | 9년 전 | 514 | ||
| 7865 | 9년 전 | 465 | ||
| 7864 | 9년 전 | 531 | ||
| 7863 | 9년 전 | 527 | ||
| 7862 | 9년 전 | 479 | ||
| 7861 | 9년 전 | 661 | ||
| 7860 | 9년 전 | 636 | ||
| 7859 | 9년 전 | 427 | ||
| 7858 | 9년 전 | 715 | ||
| 7857 | 9년 전 | 1095 | ||
| 7856 | 9년 전 | 543 | ||
| 7855 | 9년 전 | 769 | ||
| 7854 | 9년 전 | 736 | ||
| 7853 | 9년 전 | 598 | ||
| 7852 | 9년 전 | 527 | ||
| 7851 | 9년 전 | 525 | ||
| 7850 | 9년 전 | 600 | ||
| 7849 | 9년 전 | 372 | ||
| 7848 | 9년 전 | 432 | ||
| 7847 | 9년 전 | 676 | ||
| 7846 | 9년 전 | 469 | ||
| 7845 | 9년 전 | 438 | ||
| 7844 | 9년 전 | 408 | ||
| 7843 | 9년 전 | 433 | ||
| 7842 | 9년 전 | 418 | ||
| 7841 | 9년 전 | 398 | ||
| 7840 | 9년 전 | 416 | ||
| 7839 | 9년 전 | 445 | ||
| 7838 | 9년 전 | 525 | ||
| 7837 | 9년 전 | 370 | ||
| 7836 | 9년 전 | 413 | ||
| 7835 | 9년 전 | 488 | ||
| 7834 |
|
9년 전 | 1203 | |
| 7833 | 9년 전 | 452 | ||
| 7832 | 9년 전 | 434 | ||
| 7831 | 9년 전 | 582 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기