Пример #1
0
        public ActionResult export(string name)
        {
            var user = OperatorProvider.Provider.Current();
            //取出数据源
            int       total       = 0;
            DataTable exportTable = workmeetingbll.getExport(name);
            //设置导出格式
            ExcelConfig excelconfig = new ExcelConfig();

            //excelconfig.Title = "违章信息";
            //excelconfig.TitleFont = "微软雅黑";
            //excelconfig.TitlePoint = 25;
            excelconfig.HeadHeight      = 50;
            excelconfig.HeadPoint       = 12;
            excelconfig.HeadFont        = "宋体";
            excelconfig.FileName        = "危险预知训练导出.xls";
            excelconfig.IsAllSizeColumn = true;
            //每一列的设置,没有设置的列信息,系统将按datatable中的列名导出
            List <ColumnEntity> listColumnEntity = new List <ColumnEntity>();

            excelconfig.ColumnEntity = listColumnEntity;
            ColumnEntity columnentity = new ColumnEntity();

            excelconfig.ColumnEntity.Add(new ColumnEntity()
            {
                Column = "jobcontent", ExcelColumn = "作业内容", Width = 12, Alignment = "fill"
            });
            excelconfig.ColumnEntity.Add(new ColumnEntity()
            {
                Column = "workquarters", ExcelColumn = "作业岗位", Width = 15
            });
            excelconfig.ColumnEntity.Add(new ColumnEntity()
            {
                Column = "usetime", ExcelColumn = "使用次数", Width = 15
            });
            excelconfig.ColumnEntity.Add(new ColumnEntity()
            {
                Column = "redactiondate", ExcelColumn = "修订时间", Width = 15
            });
            excelconfig.ColumnEntity.Add(new ColumnEntity()
            {
                Column = "redactionperson", ExcelColumn = "修订人", Width = 18
            });
            //调用导出方法
            ExcelHelper.ExcelDownload(exportTable, excelconfig);
            return(Success("导出成功。"));
        }