• 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);
  • 相关阅读:
    Android 逐帧动画isRunning 一直返回true的问题
    android动画学习
    android信号强度
    在代码中创建Drawable资源
    通过ComponentName获取相应的Widget
    EditText和输入法相关的问题
    Android 沉浸式状态栏
    安防设置功能出现的错误
    自定义seekbar
    android 新控件 AppBarLayout 使用
  • 原文地址:https://www.cnblogs.com/gxivwshjj/p/6549287.html
Copyright © 2020-2023  润新知