Пример #1
0
        public string ExportExcel()
        {
            MissCanTimePara b = new MissCanTimePara()
            {
                StartDate = DateTime.Now.AddDays(-31),

                EndDate      = DateTime.Now,
                EmployeeCode = 0
            };
            MissingScanTimeCollection collection = ReportManager.GetExMonthlyReport(b);
            DataTable dt       = collection.ToDataTable <MissingScanTime>();
            string    fileName = "RBVHEmployee_" + SystemConfig.CurrentDate.ToString("MM-dd-yyyy");

            string[] RemoveColumn = { "CompanyID", "TargetDisplayID", "ReturnDisplay", "TotalRecord", "CreatedUser", "CreatedDate" };
            for (int i = 0; i < RemoveColumn.Length; i++)
            {
                if (dt.Columns.Contains(RemoveColumn[i]))
                {
                    dt.Columns.Remove(RemoveColumn[i]);
                }
            }
            DataSet ds = new DataSet();

            ds.Tables.Add(dt);
            //set Column Date Format
            int[]     DateColumn = { 8, 9, 10, 11 };
            string[]  sheetName  = { "Daily_TMS" };
            ExcelPara mypara     = new ExcelPara()
            {
                ds          = ds,
                sheetName   = sheetName,
                fileName    = fileName,
                DateColumns = DateColumn,
                DateFormat  = "h:mm:ss"
            };

            FileInputHelper.ExportMultiSheetExcelExtend(mypara);
            FileInputHelper.ExportExcel(dt, fileName, "RBVHEmployee List", false);
            return(fileName);
        }