jsp页面怎么导出excel?
发布网友
发布时间:2022-05-06 17:13
我来回答
共2个回答
热心网友
时间:2023-11-04 03:19
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script>
//全部打印到excel表
function AutomateExcelall()
{
var i,j;
// Start Excel and get Application object.
var oXL = new ActiveXObject("Excel.Application");
oXL.Visible = true;
// Get a new workbook.
var oWB = oXL.Workbooks.Add();
var oSheet = oWB.ActiveSheet;
// Add table headers going cell by cell.
oSheet.Cells(1, 1).Value = "编号";
oSheet.Cells(1, 2).Value = "姓名";
oSheet.Cells(1, 3).Value = "地址";
for(i=1;i<tblout.rows.length;i++)
{
for(j=1;j<tblout.rows(i).cells.length;j++)
{
oSheet.Cells(i+1, j).Value = tblout.rows(i).cells(j).innerText
}
}
oXL.Visible = true;
oXL.UserControl = true;
}
//选种打印到excel表
function AutomateExcel()
{
var i=0;
// var j=0; //i是行,j是列
var oXL = new ActiveXObject("Excel.Application");
oXL.Visible = true;
var oWB = oXL.Workbooks.Add();
var oSheet = oWB.ActiveSheet;
oSheet.Cells(1, 2).Value = "编号";
oSheet.Cells(1, 3).Value = "姓名";
oSheet.Cells(1, 4).Value = "地址";
var s=0;
for(i=1;i<tblout.rows.length+1;i++)
{
if(document.myform.mybox[i].checked==true)
{
s=s+1;
for(j=0;j<tblout.rows(i).cells.length;j++)
{
oSheet.Cells(s+1, j+1).Value = tblout.rows(i).cells(j).innerText
}
}
}
oXL.Visible = true;
oXL.UserControl = true;
}
//得到选种的复选框
function check()
{
var checkboxvalue=0;
for(var i=0;i<document.myform.mybox.length;i++)
{
if(document.myform.mybox[i].checked==true)
{
checkboxvalue=checkboxvalue+1;
}
}
document.myform.dayin.value=checkboxvalue;
}
</script>
</head>
<body>
<form action="" method="post" name="myform">
<table width="577" border="1" id="tblout">
<tr>
<td width="49" align="center">选项</td>
<td width="100" align="center">编号</td>
<td width="100" align="center">姓名</td>
<td width="101" align="center">地址</td>
<td colspan="3" align="center">操作</td>
</tr>
<tr>
<td align="left"><input type="checkbox" value="1" name="mybox" onclick="check()"/></td>
<td align="center">aa</td>
<td align="center">bb</td>
<td align="center">cc</td>
<td width="61" align="center">删除</td>
<td width="60" align="center">a</td>
<td width="60" align="center">修改</td>
</tr>
<tr>
<td align="left"><input type="checkbox" value="2" id="mybox" onclick="check()" /></td>
<td align="center">ee</td>
<td align="center">ff</td>
<td align="center">gg</td>
<td align="center">删除</td>
<td align="center">a</td>
<td align="center">修改</td>
</tr>
<tr>
<td><input type="checkbox" value="2" id="mybox" onclick="check()" /></td>
<td align="center">asdas</td>
<td align="center">fdsfsd</td>
<td align="center">sdfsdfsd</td>
<td align="center">删除</td>
<td align="center">a</td>
<td align="center">修改</td>
</tr>
<tr>
<td><input type="checkbox" value="2" id="mybox" onclick="check()" /></td>
<td align="center">fsdfs</td>
<td align="center">sdf/</td>
<td align="center">gsdfsdfg</td>
<td align="center">删除</td>
<td align="center">a</td>
<td align="center">修改</td>
</tr>
<tr>
<td><input type="checkbox" value="2" id="mybox" onclick="check()" /></td>
<td align="center">edsdse</td>
<td align="center">fsdasdaf</td>
<td align="center">gdasdag</td>
<td align="center">删除</td>
<td align="center">a</td>
<td align="center">修改</td>
</tr>
<tr>
<td><input type="checkbox" value="2" id="mybox" onclick="check()" /></td>
<td align="center">edsdse</td>
<td align="center">fsdasdaf</td>
<td align="center">gdasdag</td>
<td align="center">删除</td>
<td align="center">a</td>
<td align="center">修改</td>
</tr>
<tr>
<td><input type="checkbox" value="2" id="mybox" onclick="check()" /></td>
<td align="center">edsdse</td>
<td align="center">fsdasdaf</td>
<td align="center">gdasdag</td>
<td align="center">删除</td>
<td align="center">a</td>
<td align="center">修改</td>
</tr>
<tr>
<td><input type="checkbox" value="2" id="mybox" onclick="check()" /></td>
<td align="center">edsdse</td>
<td align="center">fsdasdaf</td>
<td align="center">gdasdag</td>
<td align="center">删除</td>
<td align="center">a</td>
<td align="center">修改</td>
</tr>
<tr>
<td><input type="checkbox" value="2" id="mybox" onclick="check()" /></td>
<td align="center">edsdse</td>
<td align="center">fsdasdaf</td>
<td align="center">gdasdag</td>
<td align="center">删除</td>
<td align="center">a</td>
<td align="center">修改</td>
</tr>
<tr>
<td><input type="checkbox" value="2" id="mybox" onclick="check()" /></td>
<td align="center">edsdse</td>
<td align="center">fsdasdaf</td>
<td align="center">gdasdag</td>
<td align="center">删除</td>
<td align="center">a</td>
<td align="center">修改</td>
</tr>
<tr>
<td><input type="checkbox" value="2" id="mybox" onclick="check()" /></td>
<td align="center">edsdse</td>
<td align="center">fsdasdaf</td>
<td align="center">gdasdag</td>
<td align="center">删除</td>
<td align="center">a</td>
<td align="center">修改</td>
</tr>
</table>
<input type="text" name="dayin" />
<input type="button" onclick="AutomateExcelall()" value="打印全部"/>
<input type="button" onclick="AutomateExcel()" value="选中全部"/>
</form>
</body>
</html>
热心网友
时间:2023-11-04 03:19
http://zhidao.baidu.com/question/118599073.html
热心网友
时间:2023-10-13 02:21
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script>
//全部打印到excel表
function AutomateExcelall()
{
var i,j;
// Start Excel and get Application object.
var oXL = new ActiveXObject("Excel.Application");
oXL.Visible = true;
// Get a new workbook.
var oWB = oXL.Workbooks.Add();
var oSheet = oWB.ActiveSheet;
// Add table headers going cell by cell.
oSheet.Cells(1, 1).Value = "编号";
oSheet.Cells(1, 2).Value = "姓名";
oSheet.Cells(1, 3).Value = "地址";
for(i=1;i<tblout.rows.length;i++)
{
for(j=1;j<tblout.rows(i).cells.length;j++)
{
oSheet.Cells(i+1, j).Value = tblout.rows(i).cells(j).innerText
}
}
oXL.Visible = true;
oXL.UserControl = true;
}
//选种打印到excel表
function AutomateExcel()
{
var i=0;
// var j=0; //i是行,j是列
var oXL = new ActiveXObject("Excel.Application");
oXL.Visible = true;
var oWB = oXL.Workbooks.Add();
var oSheet = oWB.ActiveSheet;
oSheet.Cells(1, 2).Value = "编号";
oSheet.Cells(1, 3).Value = "姓名";
oSheet.Cells(1, 4).Value = "地址";
var s=0;
for(i=1;i<tblout.rows.length+1;i++)
{
if(document.myform.mybox[i].checked==true)
{
s=s+1;
for(j=0;j<tblout.rows(i).cells.length;j++)
{
oSheet.Cells(s+1, j+1).Value = tblout.rows(i).cells(j).innerText
}
}
}
oXL.Visible = true;
oXL.UserControl = true;
}
//得到选种的复选框
function check()
{
var checkboxvalue=0;
for(var i=0;i<document.myform.mybox.length;i++)
{
if(document.myform.mybox[i].checked==true)
{
checkboxvalue=checkboxvalue+1;
}
}
document.myform.dayin.value=checkboxvalue;
}
</script>
</head>
<body>
<form action="" method="post" name="myform">
<table width="577" border="1" id="tblout">
<tr>
<td width="49" align="center">选项</td>
<td width="100" align="center">编号</td>
<td width="100" align="center">姓名</td>
<td width="101" align="center">地址</td>
<td colspan="3" align="center">操作</td>
</tr>
<tr>
<td align="left"><input type="checkbox" value="1" name="mybox" onclick="check()"/></td>
<td align="center">aa</td>
<td align="center">bb</td>
<td align="center">cc</td>
<td width="61" align="center">删除</td>
<td width="60" align="center">a</td>
<td width="60" align="center">修改</td>
</tr>
<tr>
<td align="left"><input type="checkbox" value="2" id="mybox" onclick="check()" /></td>
<td align="center">ee</td>
<td align="center">ff</td>
<td align="center">gg</td>
<td align="center">删除</td>
<td align="center">a</td>
<td align="center">修改</td>
</tr>
<tr>
<td><input type="checkbox" value="2" id="mybox" onclick="check()" /></td>
<td align="center">asdas</td>
<td align="center">fdsfsd</td>
<td align="center">sdfsdfsd</td>
<td align="center">删除</td>
<td align="center">a</td>
<td align="center">修改</td>
</tr>
<tr>
<td><input type="checkbox" value="2" id="mybox" onclick="check()" /></td>
<td align="center">fsdfs</td>
<td align="center">sdf/</td>
<td align="center">gsdfsdfg</td>
<td align="center">删除</td>
<td align="center">a</td>
<td align="center">修改</td>
</tr>
<tr>
<td><input type="checkbox" value="2" id="mybox" onclick="check()" /></td>
<td align="center">edsdse</td>
<td align="center">fsdasdaf</td>
<td align="center">gdasdag</td>
<td align="center">删除</td>
<td align="center">a</td>
<td align="center">修改</td>
</tr>
<tr>
<td><input type="checkbox" value="2" id="mybox" onclick="check()" /></td>
<td align="center">edsdse</td>
<td align="center">fsdasdaf</td>
<td align="center">gdasdag</td>
<td align="center">删除</td>
<td align="center">a</td>
<td align="center">修改</td>
</tr>
<tr>
<td><input type="checkbox" value="2" id="mybox" onclick="check()" /></td>
<td align="center">edsdse</td>
<td align="center">fsdasdaf</td>
<td align="center">gdasdag</td>
<td align="center">删除</td>
<td align="center">a</td>
<td align="center">修改</td>
</tr>
<tr>
<td><input type="checkbox" value="2" id="mybox" onclick="check()" /></td>
<td align="center">edsdse</td>
<td align="center">fsdasdaf</td>
<td align="center">gdasdag</td>
<td align="center">删除</td>
<td align="center">a</td>
<td align="center">修改</td>
</tr>
<tr>
<td><input type="checkbox" value="2" id="mybox" onclick="check()" /></td>
<td align="center">edsdse</td>
<td align="center">fsdasdaf</td>
<td align="center">gdasdag</td>
<td align="center">删除</td>
<td align="center">a</td>
<td align="center">修改</td>
</tr>
<tr>
<td><input type="checkbox" value="2" id="mybox" onclick="check()" /></td>
<td align="center">edsdse</td>
<td align="center">fsdasdaf</td>
<td align="center">gdasdag</td>
<td align="center">删除</td>
<td align="center">a</td>
<td align="center">修改</td>
</tr>
<tr>
<td><input type="checkbox" value="2" id="mybox" onclick="check()" /></td>
<td align="center">edsdse</td>
<td align="center">fsdasdaf</td>
<td align="center">gdasdag</td>
<td align="center">删除</td>
<td align="center">a</td>
<td align="center">修改</td>
</tr>
</table>
<input type="text" name="dayin" />
<input type="button" onclick="AutomateExcelall()" value="打印全部"/>
<input type="button" onclick="AutomateExcel()" value="选中全部"/>
</form>
</body>
</html>
热心网友
时间:2023-10-13 02:22
http://zhidao.baidu.com/question/118599073.html