您的位置:首页 > Web前端 > JavaScript

将后台数据读取到前台的EXCEL文件中去,用javascript实现,asp.net,javacript(发一个原创)

2007-05-18 22:04 1226 查看
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!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 runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">

<%
Response.Write("请加入信任站点");
%>
<script language="javascript" type="text/javascript">
var xlApp,xlBook,xlSheet;
xlApp = new ActiveXObject("Excel.Application");
xlBook = xlApp.Workbooks.Add();
xlBook.Worksheets.Add();
xlBook.Worksheets.Add();
var quArray = new Array(" ","1","2","3","4","5");
var i;
for( i=1;i<quArray.length;i++)
{
xlSheet = xlBook.Worksheets(i);
xlSheet.Name = quArray[i];
}

<%
for(int j=1;j<=5;j++)
{
%>
xlSheet = xlBook.Worksheets(quArray[<%=j%>]);
i=1;
xlSheet.Cells(i++,1).Value = "小名";
xlSheet.Cells(1,2).Value = "d";
xlSheet.Cells(1,3).Value = "a";
xlSheet.Cells(1,4).Value = "c";

var con = i-1;
xlSheet.Rows("1:"+con).Font.Size = 9;
xlSheet.Rows("1:"+con).RowHeight = 15;
xlSheet.Range("A1:D1").Interior.ColorIndex = 15;
xlSheet.Range("A1:D1").Interior.Pattern = 1;
xlSheet.Range("A1:D1").Font.ColorIndex = 1;
xlSheet.Range("A1:D1").HorizontalAlignment = 3;
xlSheet.Range("A1:D"+con).Borders.Weight = 2;
xlSheet.Range("A1:D"+con).Borders.ColorIndex = 1;
xlSheet.Columns("A:D").EntireColumn.AutoFit;

<%
}
%>

xlApp.Visible = true;
idTmr = window.setInterval("Cleanup();",1);
function Cleanup() {
window.clearInterval(idTmr);
CollectGarbage();
}
window.opener=null;
window.close();

</script>

</form>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐