js读取本地excel文档数据
2008-08-18 16:58
344 查看
浏览器:IE
安全设置:默认
代码:
<script>
function readThis(){
var tempStr = "";
var filePath= document.all.upfile.value;
var oXL = new ActiveXObject("Excel.application");
var oWB = oXL.Workbooks.open(filePath);
oWB.worksheets(1).select();
var oSheet = oWB.ActiveSheet;
try{
for(var i=2;i<46;i++){
if(oSheet.Cells(i,2).value =="null" || oSheet.Cells(i,3).value =="null" )
break;
var a = oSheet.Cells(i,2).value.toString()=="undefined"?"":oSheet.Cells(i,2).value;
tempStr+=(" "+oSheet.Cells(i,2).value+
" "+oSheet.Cells(i,3).value+
" "+oSheet.Cells(i,4).value+
" "+oSheet.Cells(i,5).value+
" "+oSheet.Cells(i,6).value+"/n");
}
}catch(e){
//alert(e);
document.all.txtArea.value = tempStr;
}
document.all.txtArea.value = tempStr;
oXL.Quit();
CollectGarbage();
}
</script>
<html>
<input type="file" id="upfile" /><input type="button" onclick="readThis();" value="读取">
<br>
<textarea id="txtArea" cols=50 rows=10></textarea>
</html>
安全设置:默认
代码:
<script>
function readThis(){
var tempStr = "";
var filePath= document.all.upfile.value;
var oXL = new ActiveXObject("Excel.application");
var oWB = oXL.Workbooks.open(filePath);
oWB.worksheets(1).select();
var oSheet = oWB.ActiveSheet;
try{
for(var i=2;i<46;i++){
if(oSheet.Cells(i,2).value =="null" || oSheet.Cells(i,3).value =="null" )
break;
var a = oSheet.Cells(i,2).value.toString()=="undefined"?"":oSheet.Cells(i,2).value;
tempStr+=(" "+oSheet.Cells(i,2).value+
" "+oSheet.Cells(i,3).value+
" "+oSheet.Cells(i,4).value+
" "+oSheet.Cells(i,5).value+
" "+oSheet.Cells(i,6).value+"/n");
}
}catch(e){
//alert(e);
document.all.txtArea.value = tempStr;
}
document.all.txtArea.value = tempStr;
oXL.Quit();
CollectGarbage();
}
</script>
<html>
<input type="file" id="upfile" /><input type="button" onclick="readThis();" value="读取">
<br>
<textarea id="txtArea" cols=50 rows=10></textarea>
</html>
相关文章推荐
- js读取本地excel文档数据的代码
- js读取本地excel文档数据的代码
- js读取本地excel文档数据的代码
- 测试js读取本地excel文档数据
- js读取本地excel文档数据
- js读取本地excel文档数据
- js读取本地excel文档数据
- js读取本地excel文档数据
- js读取本地excel文档数据
- 怎样读取本地Excel数据,并保存到时服务器
- 关于js读取本地excel文件的问题。。纠结好久了
- js 读取本地excel 内容
- 用C#编程从数据库中读取图片数据导进Excel文件的方法(如何从数据库中读取保存的文件,直接打开,中间不保存到本地)
- 网页端中将表格数据和JSON数据读取(导出)到本地的excel和csv文件中
- JS读取本地excel文件
- js读取本地磁盘文本文件并保存为JSON数据(有格式的文本)
- 最近整理了个js,解决了excel导入读取数据遇到的种种问题
- DataTable To Excel File,Create Excel, Create Local Floder 从数据库中读取数据存到本地指定文件夹的Excel中
- js读取Excel的数据(仅IE有效)
- 用js导出数据到Excel文档