惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
P
Privacy International News Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Troy Hunt's Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Attack and Defense Labs
Attack and Defense Labs
S
Secure Thoughts
V2EX - 技术
V2EX - 技术
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
O
OpenAI News
Cloudbric
Cloudbric
Google Online Security Blog
Google Online Security Blog
Schneier on Security
Schneier on Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Help Net Security
Help Net Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
L
Lohrmann on Cybersecurity
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Spread Privacy
Spread Privacy
NISL@THU
NISL@THU
N
News and Events Feed by Topic
T
Tenable Blog
S
Security @ Cisco Blogs
N
News and Events Feed by Topic
The Hacker News
The Hacker News
C
CXSECURITY Database RSS Feed - CXSecurity.com
宝玉的分享
宝玉的分享
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
V
Visual Studio Blog
P
Proofpoint News Feed
Webroot Blog
Webroot Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 三生石上(FineUI控件)
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Jina AI
Jina AI
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
Hugging Face - Blog
Hugging Face - Blog
腾讯CDC
L
LangChain Blog
The Register - Security
The Register - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东

博客园 - baileyer

VisualSVN破解安装到VS2026 使用 SQL 中的递归查询(Recursive CTE)来实现1-50数字 git 忽略本地文件提交(VS) Abp vue项目找不到模块“./app.vue” MSSqlserver分割文件备份恢复 github的镜像下载加快clone下载速度 widows部署.NET Core 3.1项目到IIS问题 .net core/mvc获取特性 oracle instr 替代like查询 quartz3.0.7和topshelf4.2.1实现任务调度 VS2017同时生成.net core和.net framework两份代码 .net core Failed to load API definition 错误 vs 2017 调试中断问题 .net Core 2.2实现京东宙斯API采用OAuth授权方式调用 WinForm 校验只能输入数字英文字母退格键 NPOI导出excel C#通过反射获取相应的字段和值 activemq.bat 在window7 x64下启动(安装)报错解决方案 <asp:RadioButton> 选项判断
C# 自定义导出模板(NPOI)
baileyer · 2022-04-07 · via 博客园 - baileyer
private async Task<Stream> ExportOrderDtlTemp(string tempName = "订货订单明细导入模板")
        {
            IWorkbook workbook = new XSSFWorkbook(); //.xlsx
            ISheet sheet = workbook.CreateSheet("sheet1");
            #region 创建表头
            #region 尺码组
            //第一行
            IRow row = sheet.CreateRow(0);
            row.CreateCell(0).SetCellValue("");
            row.CreateCell(1).SetCellValue("");
            row.CreateCell(2).SetCellValue("");
            row.CreateCell(3).SetCellValue("尺码组名称A");
            row.CreateCell(4).SetCellValue("36");
            row.CreateCell(5).SetCellValue("37");
            row.CreateCell(6).SetCellValue("38");
            row.CreateCell(7).SetCellValue("39");
            row.CreateCell(8).SetCellValue("40");
            //第二行
            IRow row2 = sheet.CreateRow(1);
            row2.CreateCell(0).SetCellValue("");
            row2.CreateCell(1).SetCellValue("");
            row2.CreateCell(2).SetCellValue("");
            row2.CreateCell(3).SetCellValue("尺码组名称B");
            row2.CreateCell(4).SetCellValue("S");
            row2.CreateCell(5).SetCellValue("M");
            row2.CreateCell(6).SetCellValue("L");
            row2.CreateCell(7).SetCellValue("XL");
            row2.CreateCell(8).SetCellValue("XXL");
            #endregion

            #region 第三行
            IRow rowTitle = sheet.CreateRow(2);
            rowTitle.CreateCell(0).SetCellValue("商品编码");
            rowTitle.CreateCell(1).SetCellValue("商品名称");
            rowTitle.CreateCell(2).SetCellValue("颜色");
            rowTitle.CreateCell(3).SetCellValue("店铺");
            rowTitle.CreateCell(4).SetCellValue("尺码1");
            rowTitle.CreateCell(5).SetCellValue("尺码2");
            rowTitle.CreateCell(6).SetCellValue("尺码3");
            rowTitle.CreateCell(7).SetCellValue("尺码4");
            rowTitle.CreateCell(8).SetCellValue("尺码5");
            #endregion 
            #endregion
            //字体颜色
            IFont font = workbook.CreateFont();
            font.Color = IndexedColors.Red.Index;
            ICellStyle style = workbook.CreateCellStyle();
            style.SetFont(font);
            rowTitle.GetCell(0).CellStyle = style;
            rowTitle.GetCell(2).CellStyle = style;
            rowTitle.GetCell(3).CellStyle = style;
            //转为字节数组  
            MemoryStream memoryStream = new MemoryStream();
            workbook.Write(memoryStream);
            var buf = memoryStream.ToArray();
            memoryStream = (MemoryStream)null;
            //返回待下载文件
            Stream stream = new MemoryStream(buf);
            stream.Flush();
            stream.Position = 0L;
            stream.Seek(0L, SeekOrigin.Begin);
            string str = ".xlsx";
            string fileName = (string.IsNullOrEmpty(tempName) ? DateTime.Now.ToString("yyyyMMddHHmmssffff") : tempName) + str;
            this._httpContextAccessor.HttpContext.Response.ContentType = "application/vnd.ms-excel";
            this._httpContextAccessor.HttpContext.Response.ContentLength = new long?(stream.Length);
            ContentDispositionHeaderValue dispositionHeaderValue = new ContentDispositionHeaderValue((StringSegment)"attachment");
            dispositionHeaderValue.SetHttpFileName((StringSegment)fileName);
            this._httpContextAccessor.HttpContext.Response.Headers["Content-Disposition"] = (StringValues)((object)dispositionHeaderValue).ToString();
            this._httpContextAccessor.HttpContext.Response.Headers["Accept-Ranges"] = (StringValues)"bytes";
            Stream stream1 = (Stream)stream;
            stream = (NpoiMemoryStream)null;
            return stream1;
        }

posted @ 2022-04-07 17:35  baileyer  阅读(375)  评论()    收藏  举报