<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년 전 | 417 | ||
| 7929 | 9년 전 | 338 | ||
| 7928 | 9년 전 | 432 | ||
| 7927 | 9년 전 | 345 | ||
| 7926 | 9년 전 | 672 | ||
| 7925 | 9년 전 | 364 | ||
| 7924 | 9년 전 | 342 | ||
| 7923 | 9년 전 | 352 | ||
| 7922 | 9년 전 | 389 | ||
| 7921 | 9년 전 | 404 | ||
| 7920 | 9년 전 | 324 | ||
| 7919 | 9년 전 | 337 | ||
| 7918 | 9년 전 | 494 | ||
| 7917 | 9년 전 | 342 | ||
| 7916 | 9년 전 | 419 | ||
| 7915 | 9년 전 | 411 | ||
| 7914 | 9년 전 | 431 | ||
| 7913 | 9년 전 | 589 | ||
| 7912 | 9년 전 | 428 | ||
| 7911 | 9년 전 | 372 | ||
| 7910 | 9년 전 | 416 | ||
| 7909 | 9년 전 | 514 | ||
| 7908 | 9년 전 | 437 | ||
| 7907 | 9년 전 | 382 | ||
| 7906 | 9년 전 | 400 | ||
| 7905 | 9년 전 | 383 | ||
| 7904 | 9년 전 | 368 | ||
| 7903 | 9년 전 | 357 | ||
| 7902 | 9년 전 | 567 | ||
| 7901 |
|
9년 전 | 745 | |
| 7900 | 9년 전 | 598 | ||
| 7899 | 9년 전 | 394 | ||
| 7898 | 9년 전 | 396 | ||
| 7897 | 9년 전 | 355 | ||
| 7896 | 9년 전 | 366 | ||
| 7895 | 9년 전 | 475 | ||
| 7894 | 9년 전 | 401 | ||
| 7893 | 9년 전 | 356 | ||
| 7892 | 9년 전 | 406 | ||
| 7891 | 9년 전 | 773 | ||
| 7890 | 9년 전 | 1202 | ||
| 7889 | 9년 전 | 752 | ||
| 7888 |
limsy1987
|
9년 전 | 555 | |
| 7887 | 9년 전 | 560 | ||
| 7886 | 9년 전 | 456 | ||
| 7885 | 9년 전 | 420 | ||
| 7884 | 9년 전 | 420 | ||
| 7883 | 9년 전 | 417 | ||
| 7882 | 9년 전 | 469 | ||
| 7881 | 9년 전 | 451 | ||
| 7880 | 9년 전 | 587 | ||
| 7879 | 9년 전 | 473 | ||
| 7878 | 9년 전 | 1229 | ||
| 7877 | 9년 전 | 759 | ||
| 7876 | 9년 전 | 495 | ||
| 7875 | 9년 전 | 568 | ||
| 7874 |
|
9년 전 | 813 | |
| 7873 | 9년 전 | 526 | ||
| 7872 | 9년 전 | 688 | ||
| 7871 | 9년 전 | 491 | ||
| 7870 | 9년 전 | 616 | ||
| 7869 | 9년 전 | 439 | ||
| 7868 | 9년 전 | 461 | ||
| 7867 | 9년 전 | 436 | ||
| 7866 | 9년 전 | 504 | ||
| 7865 | 9년 전 | 462 | ||
| 7864 | 9년 전 | 520 | ||
| 7863 | 9년 전 | 519 | ||
| 7862 | 9년 전 | 474 | ||
| 7861 | 9년 전 | 650 | ||
| 7860 | 9년 전 | 634 | ||
| 7859 | 9년 전 | 421 | ||
| 7858 | 9년 전 | 708 | ||
| 7857 | 9년 전 | 1087 | ||
| 7856 | 9년 전 | 536 | ||
| 7855 | 9년 전 | 761 | ||
| 7854 | 9년 전 | 735 | ||
| 7853 | 9년 전 | 591 | ||
| 7852 | 9년 전 | 519 | ||
| 7851 | 9년 전 | 519 | ||
| 7850 | 9년 전 | 594 | ||
| 7849 | 9년 전 | 361 | ||
| 7848 | 9년 전 | 422 | ||
| 7847 | 9년 전 | 663 | ||
| 7846 | 9년 전 | 465 | ||
| 7845 | 9년 전 | 430 | ||
| 7844 | 9년 전 | 400 | ||
| 7843 | 9년 전 | 425 | ||
| 7842 | 9년 전 | 408 | ||
| 7841 | 9년 전 | 392 | ||
| 7840 | 9년 전 | 413 | ||
| 7839 | 9년 전 | 440 | ||
| 7838 | 9년 전 | 522 | ||
| 7837 | 9년 전 | 361 | ||
| 7836 | 9년 전 | 404 | ||
| 7835 | 9년 전 | 482 | ||
| 7834 |
|
9년 전 | 1199 | |
| 7833 | 9년 전 | 443 | ||
| 7832 | 9년 전 | 427 | ||
| 7831 | 9년 전 | 573 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기