• Cell


    string path = System.IO.Path.Combine(HttpRuntime.AppDomainAppPath, @"Template代表建议留言模板.xls");
                Workbook book = new Workbook(path);
                //book.Replace("Title", "测试活动233");
                
                WorkbookDesigner wd = new WorkbookDesigner(book);
                wd.SetDataSource("HDTitle", data.List[0].activity_name);//替换值
                System.Data.DataTable dt = (new ZW.DAL.T_Activity_Scene()).GetPageTable(search);
                dt.TableName = "tablename";
                dt.Columns.Add("RowIndex", typeof(int));
                dt.Columns.Add("name", typeof(string));
                dt.Columns.Add("remark", typeof(string));
                dt.Columns.Add("addtime", typeof(string));
                dt.Columns.Add("HDTitle", typeof(string));
                var row = dt.NewRow();
                row["RowIndex"] = 1;
                row["name"] = "张三";
                row["remark"] = "我的建议是233";
                row["addtime"] = "2017-03-14";
                row["HDTitle"] = "我的活动23333";
                dt.Rows.Add(row);
                row = dt.NewRow();
                row["RowIndex"] = 2;
                row["name"] = "李四";
                row["remark"] = "我的建议是244";
                row["addtime"] = "2017-03-14";
                row["HDTitle"] = "我的活动43333";
                dt.Rows.Add(row);
                wd.SetDataSource(dt);
                wd.Process();
                System.IO.MemoryStream ms = wd.Workbook.SaveToStream();
                byte[] bt = ms.ToArray();
                //客户端保存的文件名  
                //以字符流的形式下载文件    
                string file = LzCommon.ToolsUtil.CreateTimeStamp() + "测试活动建议.xls";
                System.Web.HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
                System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + file);
                System.Web.HttpContext.Current.Response.OutputStream.Write(bt, 0, bt.Length);
  • 相关阅读:
    JavaScript高级程序设计之元素大小
    软件测试面试必备的一些基础理论概念
    golang跨平台编译
    gin shoudBind
    requests
    excelize
    gin获取全部参数
    golang随机数及pipe
    不安全代码只会在使用 /unsafe 编译的情况下出现
    MongoDB 比较运算符 $eq$gt
  • 原文地址:https://www.cnblogs.com/gxivwshjj/p/6549287.html
Copyright © 2020-2023  润新知