All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
Delphi管理sql server数据库和数据表
在PHP动态网页开发过程中实现支持页面回跳的方法_php资料_编程技术
PHP实现发表文章时自动保存图片_[PHP教程]
设计ASP.NET应用程序的七大绝招_[Asp.Net教程]
全面接触SQL语法(6)_mssql学习_编程技术
ASP.NET实现投票结果的图片进度条显示代码_.net资料_编程技术
PHP技巧:PHP脚本中关于拼写检查函数库_[PHP教程]
SQL,Server数据库性能优化_[SQL,Server教程]
PHP实例:用PHP实现表单验证码登陆校验_[PHP教程]
今年最新PHP实用类精华总结_[PHP教程]
Reading number is top 10 pictures
初吻给了谁?
漂亮脸蛋魔鬼身材2
The real super beauty1
Poor doll, hand job was caught the currently in effect by his dad
The money of more than 100 countries and regions8
传奇套装
9.3阅兵全景图8-航空梯队
Men's and women's orgasms
中国女孩大胆自拍,显露完美身材2
这张图有两句话,你看出来了吗?
Download software ranking
WebService在.NET中的实战应用教学视频 → 第1集
Eclipse 4.2.2 For Win64
Tram sex maniac 2 (H) rar bag13
Sora aoi, the maid, students' uniforms
网络管理员第三版
asp.net技术内幕
Unix video tutorial20
Such love down(擒爱记)
C#与.NET技术平台实战演练
Twenty piece of palm leaf
delv published in(发表于) 2014/1/24 9:08:13 Edit(编辑)
ASP.NET的HTMLTable原样导出到Excel_[Asp.Net教程]

ASP.NET的HTMLTable原样导出到Excel_[Asp.Net教程]

ASP.NET的HTMLTable原样导出到Excel_[Asp.Net教程]

function PrintTableToExcelEx(objTab)
{
try
{
var xls = new ActiveXObject( "Excel.Application" );
}
catch(e)
{
alert( "您必须安装Excel电子表格软件,同时浏览器须使用“ActiveX 控件”,您的浏览器须允许执行控件。 请点击【帮助】了解浏览器设置方法!");
return false;
}
xls.visible = true;


var xlBook = xls.Workbooks.Add;
var xlsheet = xlBook.Worksheets(1);

var CurX = 1;
var CurY = 1;

for (var i = 0; i < objTab.rows.length; i++)
{
for (var j = 0; j < objTab.rows[i].cells.length; j++)
{
var cell = objTab.rows[i].cells[j];

var v = cell.outerText;

if ( cell.children != null && cell.children.length != 0 )
{
v = "";
for ( var k = 0; k < cell.children.length; k++ )
{
var cc = cell.children[k];

switch (cc.type)
{
case "select-one":
for ( var l = 0; l < cc.options.length; l++ )
if ( cc.options[l].selected ) v += cc.options[l].text;
break;
case "text":
v += cc.value;
break;
case "checkbox":
v += cc.checked ? "是" : "否";
break;
case undefined:
v += cell.outerText;
break;
case "hidden":
break;
default:
//v += cc.id + "/";
//v += cc.tagname + "/";
//v += cc.type + "/"
v += cc.value;
break;
}
}
}


while ( xlsheet.Cells(CurX,CurY).MergeCells ) CurY++;

xlsheet.Cells(CurX, CurY).HorizontalAlignment = 2;
var align = cell.getAttribute("align");
switch ( align )
{
case "left":
xlsheet.Cells(CurX, CurY).HorizontalAlignment = 2;//XlHalign.xlHalignLeft;
break;
case "center":
xlsheet.Cells(CurX, CurY).HorizontalAlignment = 3;;//XlHalign.xlHalignCenter;
break;
case "right":
xlsheet.Cells(CurX, CurY).HorizontalAlignment = 4;//XlHalign.xlHalignRight;
break;
}
xlsheet.Cells(CurX, CurY).WrapText = true;
xlsheet.Cells(CurX, CurY).VerticalAlignment = 2;
xlsheet.Cells(CurX, CurY).Value = v;
xlsheet.Cells(CurX, CurY).Borders.LineStyle = 1;


var rowSpan = cell.getAttribute("RowSpan");
var colSpan = cell.getAttribute("ColSpan");
if ( rowSpan >= 2 || colSpan >= 2 )
{
var R = xls.Range(xls.Cells(CurX, CurY), xls.Cells(CurX + rowSpan - 1, CurY + colSpan - 1));
R.MergeCells = true;
R.Borders.LineStyle = 1;
}
CurY++;
}

CurX++;
CurY = 1;
}
xlsheet.Columns.AutoFit; //自动适应大小
return;
}


调用:



onclick="javascript:PrintTableToExcelEx(Table1)" type="button"
value="导 出" class="input">


来源:网络







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.