• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

c#EPPlus.dll

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
using OfficeOpenXml;

        private void TaskCalculatePBOCScore(byte[] buffer, string fileId)
        {
            using (var stream = new MemoryStream(buffer))
            {
                using (var package = new ExcelPackage(stream))
                {
                    var sheet = package.Workbook.Worksheets.FirstOrDefault();
                    if (sheet != null)
                    {
                        sheet.Cells[1, 12].Value = "PA(Total_Fraud_Score)";
                        sheet.Cells[1, 13].Value = "PA(Fraud_Score_Grade)";
                        sheet.Cells[1, 14].Value = "PA(Blacklist_Type_Name)";
                        sheet.Cells[1, 15].Value = "PA(Blacklist_Type_Discription)";
                        
                        var dimension = sheet.Dimension;
                        var index = dimension.Start.Row + 1;
                        var end = dimension.End.Row + 1;
                        while (index < end)
                        {
                            sheet.Cells[index, 12].Value = "individualFraudScore.Total_Fraud_Score.ToString()";
                            sheet.Cells[index, 13].Value = "individualFraudScore.Fraud_Score_Grade.ToString()";
                            sheet.Cells[index, 14].Value = "individualFraudScore.Blacklist_Type_Name.ToString()";
                            sheet.Cells[index, 15].Value = "individualFraudScore.Blacklist_Type_Discription.ToString()";
                            index++;
                        }
                        buffer = package.GetAsByteArray();
                        
                        var content = BitConverter.ToString(buffer);
                        HttpRuntime.Cache[fileId] = content;
                    }
                }
            }
        }
        
        private void DownloadFile(HttpRequest request, HttpResponse response)
        {
            response.Clear();
            response.AddHeader("content-disposition", $"attachment; filename={DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx");
            response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            var fileId = request["fileId"];
            var content = HttpRuntime.Cache[fileId] as string;
            if (!string.IsNullOrEmpty(content))
            {
                content = content.Replace("-", "");
                var buffer = Enumerable.Range(0, content.Length)
                    .Where(p => p % 2 == 0)
                    .Select(p => Convert.ToByte(content.Substring(p, 2), 16))
                    .ToArray();
                response.OutputStream.Write(buffer, 0, buffer.Length);
            }

            HttpRuntime.Cache.Remove(fileId);
            HttpRuntime.Cache.Remove(fileId + PROGRESS);
        }

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C#异步TCP通讯类库FlyTcpFramework发布时间:2022-07-18
下一篇:
vc++深入详解中errorc2440的解决方案发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap