<script>
function gbid(s) {
return document.getElementById(s);
}
function GetData(cell,row){
var excel = new ActiveXObject("Excel.Application");
var excel_file = excel.Workbooks.Open("Someexcelfile.xlsx");
var excel_sheet = excel.Worksheets("Sheet1");
gbid('span1').innerText = excel_sheet.Cells(3,3).Value;
gbid('span2').innerText = excel_sheet.Cells(4,3).Value;
gbid('span3').innerText = excel_sheet.Cells(5,3).Value;
gbid('span4').innerText = excel_sheet.Cells(8,3).Value;
gbid('span6').innerText = excel_sheet.Cells(10,3).Value;
gbid('span7').innerText = excel_sheet.Cells(11,3).Value;
gbid('span8').innerText = excel_sheet.Cells(12,3).Value;
gbid('span11').innerText = excel_sheet.Cells(14,3).Value;
gbid('span12').innerText = excel_sheet.Cells(15,3).Value;
gbid('span13').innerText = excel_sheet.Cells(16,3).Value;
gbid('span14').innerText = excel_sheet.Cells(17,3).Value;
}
function RetrieveMember(cell,row){
var excel = new ActiveXObject("Excel.Application");
var excel_file = excel.Workbooks.Open("Someexcelfile.xlsx");
var excel_sheet = excel.Worksheets("Sheet1");
var searchMember = document.getElementById('searchMember').value;
var Name = document.getElementById('searchMember').value;
gbid('span9').innerText = excel_sheet.Cells(11,7).Value;
gbid('span10').innerText = excel_sheet.Cells(12,7).Value;
gbid('span15').innerText = excel_sheet.Cells(15,7).Value;
gbid('span16').innerText = excel_sheet.Cells(16,7).Value;
gbid('span17').innerText = excel_sheet.Cells(17,7).Value;
gbid('span18').innerText = excel_sheet.Cells(7,3).Value;
excel_file.Close()
excel.Application.Quit()
}
</script>
<body onload="GetData()" />
<body bgcolor="#000000">
<table width="450">
<tr>
<td colspan="2" bgcolor="#fafafa"><center>
<span id="span1" width:'100%'; ></span><br />
<span id="span2" width:'100%'; ></span><br />
<span id="span3" width:'100%'; ></span></center>
</tr>
<tr>
<td colspan="2" bgcolor="#B6D7E6" >
<b> <span id="span4" width:'100%'; ></span> : </b>
<input type="text" name="searchMember" id="searchMember" /> <a href="javascript: RetrieveMember();">Search</a>
<br />
<br />
<span id="span6" width:"100%; ></span> <b><u><span id="span18" width:"100%; ></span></b></u>
</td>
</tr>
<tr>
<td bgcolor="#fafafa" >
<span id="span7" width:"100%; ></span> <br />
<span id="span8" width:"100%; ></span> <br /> <br />
<span id="span11" width:"100%; ></span> <br />
</td>
<td bgcolor="#B6D7E6" >
<span id="span9" width:"100%; ></span> <br />
<span id="span10" width:"100%; ></span> <br /><br /><br />
</td>
</tr>
<tr>
<td bgcolor="#B6D7E6" > <span id="span12" width:"100%; ></span><br />
<span id="span13" width:"100%; ></span><br />
<span id="span14" width:"100%; ></span><br /><br />
</td>
<td bgcolor="#fafafa" >
<span id="span15" width:"100%; ></span><br />
<span id="span16" width:"100%; ></span><br />
<span id="span17" width:"100%; ></span><br /><br />
</td>
</tr>
好的,到目前为止,这段代码几乎完成了我想做的所有事情。它从同一个 excel 文件中提取现有信息,我会很好地使用。我试图让它做的是将信息从输入框/文本框发送到 excel 中的特定单元格(然后让它自动按回车键)。而已。我是 javascript 新手,想知道是否可以得到一些帮助。穆哈斯·格拉西亚斯!