相思资源网 Design By www.200059.com
复制代码 代码如下:
function AutomateExcel() {
try {
//Start Excel and get Application object.
var oXL;
try
{
oXL = new ActiveXObject("Excel.Application");
}
catch(e)
{
alert("无法启动Excel!\n\n如果您确信您的电脑中已经安装了Excel," + "那么请调整IE的安全级别。\n\n具体操作:\n\n" + "工具 → Internet选项 → 安全 → 自定义级别 → 对没有标记为安全的ActiveX进行初始化和脚本运行 → 启用");
return false;
}
//Get a new workbook.
var oWB = oXL.Workbooks.Add();
var oSheet = oWB.ActiveSheet;
var table = $("#GridView1")[0];
var rows = table.rows;
var columns = table.rows(0).cells;
var codes = "";
//设置标题
var name = "第 <%= _CurrentPage %> 页";
oXL.Caption = name;
oSheet.Name = name;
//设置表头
oSheet.Cells(1, 1).Value = "申请单编号";
oSheet.Cells(1, 2).Value = "出货金额";
oSheet.Cells(1, 3).Value = "营销部门";
oSheet.Cells(1, 4).Value = "业务人员";
oSheet.Cells(1, 5).Value = "内部合同号";
oSheet.Cells(1, 6).Value = "客户名称";
oSheet.Cells(1, 7).Value = "币种";
oSheet.Cells(1, 8).Value = "客户船期";
oSheet.Cells(1, 9).Value = "国别";
oSheet.Cells(1, 10).Value = "核销单号";
oSheet.Cells(1, 11).Value = "发票号码";
oSheet.Cells(1, 12).Value = "报关日期";
//获取当前页申请单编号
for (var i = 2; i <= rows.length; i++) {
codes += "'" + rows(i - 1).cells(0).innerText + "',";
}
codes += "''";
//获取数据并填充数据到EXCEL
$.post("../Handlers/ShippingApplyHandler.ashx",
{ Action: "ExportData", ExportCondition: codes },
function (views) {
if (views != null) {
var beginindex = 1;
var endindex = 1;
for (var i = 0; i < views.length; i++) {
endindex++;
oSheet.Cells(i + 2, 1).Value = views[i].SACode;
oSheet.Cells(i + 2, 2).Value = views[i].AmountSum;
oSheet.Cells(i + 2, 3).Value = views[i].Department;
oSheet.Cells(i + 2, 4).Value = views[i].SalesName;
oSheet.Cells(i + 2, 5).Value = views[i].ContractNo;
oSheet.Cells(i + 2, 6).Value = views[i].CustomerName;
oSheet.Cells(i + 2, 7).Value = views[i].CurrencyCode;
if (views[i].CustomerSchedule != null) {
oSheet.Cells(i + 2, 8).Value = ConvertToJSDate(views[i].CustomerSchedule).Format("yyyy-MM-dd");
}
oSheet.Cells(i + 2, 9).Value = views[i].Country;
oSheet.Cells(i + 2, 10).Value = views[i].VerificationNumber;
oSheet.Cells(i + 2, 11).Value = views[i].InvoiceNumber;
if (views[i].CustomsDate != null) {
oSheet.Cells(i + 2, 12).Value = ConvertToJSDate(views[i].CustomsDate).Format("yyyy-MM-dd");
}
if (i > 0 && views[i - 1].SACode == views[i].SACode) {
oSheet.Range(oSheet.Cells(beginindex, 1), oSheet.Cells(endindex, 1)).Merge();
oSheet.Range(oSheet.Cells(beginindex, 2), oSheet.Cells(endindex, 2)).Merge();
oSheet.Range(oSheet.Cells(beginindex, 3), oSheet.Cells(endindex, 3)).Merge();
oSheet.Range(oSheet.Cells(beginindex, 4), oSheet.Cells(endindex, 4)).Merge();
oSheet.Range(oSheet.Cells(beginindex, 5), oSheet.Cells(endindex, 5)).Merge();
oSheet.Range(oSheet.Cells(beginindex, 6), oSheet.Cells(endindex, 6)).Merge();
oSheet.Range(oSheet.Cells(beginindex, 7), oSheet.Cells(endindex, 7)).Merge();
oSheet.Range(oSheet.Cells(beginindex, 8), oSheet.Cells(endindex, 8)).Merge();
beginindex = endindex;
}
else {
beginindex++;
}
}
}
}, "json");
//设置自动列宽
oSheet.Columns.AutoFit();
//设置excel为可见
oXL.Visible = true;
//将Excel交由用户控制
oXL.UserControl = true;
//禁止提示
oXL.DisplayAlerts = false;
//释放资源
//oXL = null;
//oWB = null;
//oSheet = null;
}
catch (e) {
}
}
function AutomateExcel() {
try {
//Start Excel and get Application object.
var oXL;
try
{
oXL = new ActiveXObject("Excel.Application");
}
catch(e)
{
alert("无法启动Excel!\n\n如果您确信您的电脑中已经安装了Excel," + "那么请调整IE的安全级别。\n\n具体操作:\n\n" + "工具 → Internet选项 → 安全 → 自定义级别 → 对没有标记为安全的ActiveX进行初始化和脚本运行 → 启用");
return false;
}
//Get a new workbook.
var oWB = oXL.Workbooks.Add();
var oSheet = oWB.ActiveSheet;
var table = $("#GridView1")[0];
var rows = table.rows;
var columns = table.rows(0).cells;
var codes = "";
//设置标题
var name = "第 <%= _CurrentPage %> 页";
oXL.Caption = name;
oSheet.Name = name;
//设置表头
oSheet.Cells(1, 1).Value = "申请单编号";
oSheet.Cells(1, 2).Value = "出货金额";
oSheet.Cells(1, 3).Value = "营销部门";
oSheet.Cells(1, 4).Value = "业务人员";
oSheet.Cells(1, 5).Value = "内部合同号";
oSheet.Cells(1, 6).Value = "客户名称";
oSheet.Cells(1, 7).Value = "币种";
oSheet.Cells(1, 8).Value = "客户船期";
oSheet.Cells(1, 9).Value = "国别";
oSheet.Cells(1, 10).Value = "核销单号";
oSheet.Cells(1, 11).Value = "发票号码";
oSheet.Cells(1, 12).Value = "报关日期";
//获取当前页申请单编号
for (var i = 2; i <= rows.length; i++) {
codes += "'" + rows(i - 1).cells(0).innerText + "',";
}
codes += "''";
//获取数据并填充数据到EXCEL
$.post("../Handlers/ShippingApplyHandler.ashx",
{ Action: "ExportData", ExportCondition: codes },
function (views) {
if (views != null) {
var beginindex = 1;
var endindex = 1;
for (var i = 0; i < views.length; i++) {
endindex++;
oSheet.Cells(i + 2, 1).Value = views[i].SACode;
oSheet.Cells(i + 2, 2).Value = views[i].AmountSum;
oSheet.Cells(i + 2, 3).Value = views[i].Department;
oSheet.Cells(i + 2, 4).Value = views[i].SalesName;
oSheet.Cells(i + 2, 5).Value = views[i].ContractNo;
oSheet.Cells(i + 2, 6).Value = views[i].CustomerName;
oSheet.Cells(i + 2, 7).Value = views[i].CurrencyCode;
if (views[i].CustomerSchedule != null) {
oSheet.Cells(i + 2, 8).Value = ConvertToJSDate(views[i].CustomerSchedule).Format("yyyy-MM-dd");
}
oSheet.Cells(i + 2, 9).Value = views[i].Country;
oSheet.Cells(i + 2, 10).Value = views[i].VerificationNumber;
oSheet.Cells(i + 2, 11).Value = views[i].InvoiceNumber;
if (views[i].CustomsDate != null) {
oSheet.Cells(i + 2, 12).Value = ConvertToJSDate(views[i].CustomsDate).Format("yyyy-MM-dd");
}
if (i > 0 && views[i - 1].SACode == views[i].SACode) {
oSheet.Range(oSheet.Cells(beginindex, 1), oSheet.Cells(endindex, 1)).Merge();
oSheet.Range(oSheet.Cells(beginindex, 2), oSheet.Cells(endindex, 2)).Merge();
oSheet.Range(oSheet.Cells(beginindex, 3), oSheet.Cells(endindex, 3)).Merge();
oSheet.Range(oSheet.Cells(beginindex, 4), oSheet.Cells(endindex, 4)).Merge();
oSheet.Range(oSheet.Cells(beginindex, 5), oSheet.Cells(endindex, 5)).Merge();
oSheet.Range(oSheet.Cells(beginindex, 6), oSheet.Cells(endindex, 6)).Merge();
oSheet.Range(oSheet.Cells(beginindex, 7), oSheet.Cells(endindex, 7)).Merge();
oSheet.Range(oSheet.Cells(beginindex, 8), oSheet.Cells(endindex, 8)).Merge();
beginindex = endindex;
}
else {
beginindex++;
}
}
}
}, "json");
//设置自动列宽
oSheet.Columns.AutoFit();
//设置excel为可见
oXL.Visible = true;
//将Excel交由用户控制
oXL.UserControl = true;
//禁止提示
oXL.DisplayAlerts = false;
//释放资源
//oXL = null;
//oWB = null;
//oSheet = null;
}
catch (e) {
}
}
标签:
数据导出,Excel
相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com
暂无通过Javascript将数据导出到外部Excel文档的函数代码的评论...
稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!
昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。
这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。
而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?