익스플로우의 보안에 허용만 가능하면 자바스크립트 상에서도 읽기/쓰기가 가능하다.
우선 text파일 읽고 쓰는 예제이다.(C:\\book1.txt를 읽고 씀)
=====================================================================================================================
<html>
<head>
<title>file save/load</title>
<script type="text/javascript">
var fso=new ActiveXObject("Scripting.FileSystemObject");
var filename="C:\\book1.txt";
function savefile() {
if (!fso.FileExists(filename)) {
fso.CreateTextFile(filename,true);
}
var f=fso.OpenTextFile(filename,2,true);
f.Write(myarea.innerHTML);
f.Close();
}
function loadfile() {
if (!fso.FileExists(filename)) {
fso.CreateTextFile(filename,true);
}
var f=fso.OpenTextFile(filename,1);
r=f.ReadAll();
f.Close();
myarea.innerHTML=r;
}
//function window.onload() {
// loadfile(filename);
//}
</script>
</head>
<body>
<table>
<tr>
<td>
<div id=myarea contenteditable=true style="width:320;height:240;border:solid 2 inset;overflow:scroll;background-color:silver;"></div>
<br><input type=button value=load onclick=loadfile()><input type=button value=save onclick=savefile()>
</td>
</tr>
</table>
</form>
</body>
</html>
======================================Excel 파일 열고 쓰기 =================================================
- 쓰기 -
<script type="text/javascript">
// Declare the variables
var Excel, Book;
// Create the Excel application object.
Excel = new ActiveXObject("Excel.Application");
// Make Excel visible.
Excel.Visible = true;
// Create a new work book.
Book = Excel.Workbooks.Add()
// Place some text in the first cell of the sheet.
Book.ActiveSheet.Cells(1,1).Value = "This is column A, row 1";
// Save the sheet.
Book.SaveAs("C:\\book1.xls");
// Close Excel with the Quit method on the Application object.
Excel.Application.Quit();
</script>
- 열기 -
function StartExcel() {
var oExcel;
var oWBook;
oExcel = new ActiveXObject("Excel.Application");
oExcel.Visible = true;
oExcel.workbooks.open("C:/test.xls");
oExcel.Quit();
oExcel = null;
}
간단한 파일 읽기의 경우 상당히 유용할 수 있겠다..
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7830 | 10년 전 | 462 | ||
| 7829 |
|
10년 전 | 649 | |
| 7828 | 10년 전 | 573 | ||
| 7827 | 10년 전 | 476 | ||
| 7826 | 10년 전 | 498 | ||
| 7825 | 10년 전 | 529 | ||
| 7824 | 10년 전 | 487 | ||
| 7823 | 10년 전 | 431 | ||
| 7822 | 10년 전 | 406 | ||
| 7821 | 10년 전 | 348 | ||
| 7820 | 10년 전 | 370 | ||
| 7819 |
|
10년 전 | 770 | |
| 7818 | 10년 전 | 428 | ||
| 7817 | 10년 전 | 608 | ||
| 7816 | 10년 전 | 447 | ||
| 7815 | 10년 전 | 642 | ||
| 7814 | 10년 전 | 479 | ||
| 7813 | 10년 전 | 434 | ||
| 7812 | 10년 전 | 444 | ||
| 7811 | 10년 전 | 419 | ||
| 7810 | 10년 전 | 622 | ||
| 7809 | 10년 전 | 553 | ||
| 7808 | 10년 전 | 434 | ||
| 7807 | 10년 전 | 445 | ||
| 7806 |
프로그래머7
|
10년 전 | 1364 | |
| 7805 | 10년 전 | 1310 | ||
| 7804 |
zahir1312
|
10년 전 | 805 | |
| 7803 |
|
10년 전 | 1405 | |
| 7802 | 10년 전 | 507 | ||
| 7801 | 10년 전 | 885 | ||
| 7800 | 10년 전 | 1111 | ||
| 7799 | 10년 전 | 594 | ||
| 7798 | 10년 전 | 541 | ||
| 7797 | 10년 전 | 561 | ||
| 7796 | 10년 전 | 399 | ||
| 7795 | 10년 전 | 550 | ||
| 7794 | 10년 전 | 592 | ||
| 7793 | 10년 전 | 1090 | ||
| 7792 | 10년 전 | 519 | ||
| 7791 | 10년 전 | 612 | ||
| 7790 | 10년 전 | 537 | ||
| 7789 |
fbastore
|
10년 전 | 1488 | |
| 7788 | 10년 전 | 592 | ||
| 7787 | 10년 전 | 449 | ||
| 7786 | 10년 전 | 655 | ||
| 7785 | 10년 전 | 629 | ||
| 7784 | 10년 전 | 693 | ||
| 7783 | 10년 전 | 513 | ||
| 7782 | 10년 전 | 538 | ||
| 7781 | 10년 전 | 938 | ||
| 7780 | 10년 전 | 847 | ||
| 7779 | 10년 전 | 799 | ||
| 7778 | 10년 전 | 393 | ||
| 7777 | 10년 전 | 506 | ||
| 7776 | 10년 전 | 502 | ||
| 7775 | 10년 전 | 437 | ||
| 7774 | 10년 전 | 648 | ||
| 7773 | 10년 전 | 404 | ||
| 7772 | 10년 전 | 778 | ||
| 7771 | 10년 전 | 437 | ||
| 7770 | 10년 전 | 674 | ||
| 7769 | 10년 전 | 434 | ||
| 7768 | 10년 전 | 655 | ||
| 7767 | 10년 전 | 1207 | ||
| 7766 | 10년 전 | 537 | ||
| 7765 | 10년 전 | 599 | ||
| 7764 |
잘살아보자
|
10년 전 | 455 | |
| 7763 |
|
10년 전 | 1505 | |
| 7762 |
Tosea
|
10년 전 | 1089 | |
| 7761 | 10년 전 | 692 | ||
| 7760 |
잘살아보자
|
10년 전 | 765 | |
| 7759 |
잘살아보자
|
10년 전 | 605 | |
| 7758 |
잘살아보자
|
10년 전 | 660 | |
| 7757 | 10년 전 | 1293 | ||
| 7756 |
ITBANK
|
10년 전 | 1290 | |
| 7755 | 10년 전 | 1945 | ||
| 7754 | 10년 전 | 1106 | ||
| 7753 | 10년 전 | 923 | ||
| 7752 | 10년 전 | 1426 | ||
| 7751 |
잘살아보자
|
10년 전 | 581 | |
| 7750 |
잘살아보자
|
10년 전 | 510 | |
| 7749 |
잘살아보자
|
10년 전 | 536 | |
| 7748 |
잘살아보자
|
10년 전 | 561 | |
| 7747 |
잘살아보자
|
10년 전 | 639 | |
| 7746 |
잘살아보자
|
10년 전 | 702 | |
| 7745 |
잘살아보자
|
10년 전 | 951 | |
| 7744 |
잘살아보자
|
10년 전 | 442 | |
| 7743 | 10년 전 | 972 | ||
| 7742 |
starbros
|
10년 전 | 867 | |
| 7741 |
잘살아보자
|
10년 전 | 709 | |
| 7740 |
잘살아보자
|
10년 전 | 599 | |
| 7739 |
잘살아보자
|
10년 전 | 488 | |
| 7738 |
잘살아보자
|
10년 전 | 565 | |
| 7737 |
잘살아보자
|
10년 전 | 543 | |
| 7736 |
잘살아보자
|
10년 전 | 563 | |
| 7735 |
잘살아보자
|
10년 전 | 900 | |
| 7734 |
잘살아보자
|
10년 전 | 456 | |
| 7733 |
잘살아보자
|
10년 전 | 566 | |
| 7732 |
잘살아보자
|
10년 전 | 731 | |
| 7731 |
잘살아보자
|
10년 전 | 655 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기