日期:2014-05-16 浏览次数:20443 次
<%@ page contentType="application/vnd.ms-excel;charset=gb2312" %>
<html>
<head>
<style media=print mce_bogus="1"> .Noprint{display:none;} .PageNext{page-break-after:always;} </style>
</head>
<link rel="stylesheet" type="text/css" href="file:///D|/soft/ext-3.0.3/resources/css/ext-all.css" />
<script language="javascript" type="text/javascript" src="file:///D|/soft/ext-3.0.3/adapter/ext/ext-base.js"></script>
<script language="javascript" type="text/javascript" src="file:///D|/soft/ext-3.0.3/ext-all.js"></script>
<script language="javascript" type="text/javascript">
Ext.onReady(function(){
var data=[ [1, 'EasyJWeb', 'EasyJF','www.easyjf.com'],
[2, 'jfox', 'huihoo','www.huihoo.org'],
[3, 'jdon', 'jdon','www.jdon.com'],
[4, 'springside', 'springside','www.springside.org.cn'] ];
var sm=new Ext.grid.CheckboxSelectionModel();
var store=new Ext.data.SimpleStore({data:data,fields:["id","name","organization","homepage"]});
var grid = new Ext.grid.GridPanel({
renderTo:"hello",
title:"中国Java开源产品及团队",
height:150,
width:600,
columns:[sm,{header:"项目名称",dataIndex:"name"},
{header:"开发团队",dataIndex:"organization"},
{header:"网址",dataIndex:"homepage"}],
sm:sm,
store:store,
autoExpandColumn:2
});
});
</script>
<body >
<br />
<div id="hello"></div>
<br/><br>
<div id="newTable" style="font-size:12px;" ></div>
<br><br>
<span class="Noprint">
<input type="button" onClick="javascript:AllAreaExcel();" value="导出Excel">
<input type="button" onClick="javascript:OpenWord();" value="导出Word">
<input type=button value=打印 onclick=document.all.WebBrowser.ExecWB(6,1)> <input type=button value=页面设置 onclick=document.all.WebBrowser.ExecWB(8,1)>
<input name=Button onclick=document.all.WebBrowser.ExecWB(7,1) type="button" value="打印预览"><OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
<input type="file" name="file" id="file"/><input type="button" id="excelimport" name="excelimport" value="Excel导入" onClick="javascript:readExcel()" />
</span>
</div>
<script language="javascript" type="text/javascript">
function readExcel()
{
if(document.getElementById("file").value.split(".")[1]=="xls"){
var oXL = new ActiveXObject("Excel.Application");
try{
var oWB = oXL.Workbooks.open(document.getElementById("file").value);
}catch(e){
? alert('打开文件失败!');
}
var oSheet = oWB.ActiveSheet;
var table=document.createElement("table");
table.setAttribute("border","1");
table.setAttribute("cellpadding","0");
table.setAttribute("cellspacing","0");
table.setAttribute("border-collapse","collapse");
table.setAttribute("width","60%");
//table.setAttribute("style-fontSize","12");
table.setAttribute("id","mytable");
document.body.appendChild(table);
for(var i=0;i<oSheet.usedrange.rows.count;i++){
var row=table.insertRow(i);
for(var j=0;j<(oSheet.usedrange.cells.count/oSheet.usedrange.rows.count);j++){
//oSheet.Cells(i,j).Font.Size = 10;
//alert(oSheet.Cells(i+1,j+1).value);
if(oSheet.Cells(i+1,j+1).value==null){
row.insertCell(j).appendChild(document.createTextNode(""));
}
else{
row.insertCell(j).appendChild(document.createTextNode(oSheet.Cells(i+1,j+1).value));
}
}
}
var div=document.getElementById("newTable");
div.appendChild(table);
//alert(oSheet.Rows.rows);
// alert(oSheet.Cells(1,1).value);//cell的值
// alert(oSheet.usedrange.cells.count);//cell的值
// alert(oSheet.usedrange.rows.count);//使用的行数
// alert(oWB.Workshee