/// <summary>
 /// 扩展标题头样式
 /// </summary>
 /// <param name="workbook"></param>
 /// <param name="propertyName"></param>
 /// <returns></returns>
 protected virtual ICellStyle SetHeaderStyle(HSSFWorkbook workbook, PropertyInfo propertyInfo)
 {
     if (propertyInfo.Name.Contains("DataContent"))
     {
         return(ExcelStyle.HeaderLeftStyle(workbook)); //设置居左
     }
     return(ExcelStyle.HeaderStyle(workbook));         //设置Header剧中
 }
        /// <summary>
        /// 设定某一列的样式
        /// </summary>
        /// <param name="workbook"></param>
        /// <param name="propertyName"></param>
        /// <param name="cdrRowStyle">如果设置了行样式,列的样式设置会被覆盖,仅返回行样式</param>
        /// <returns></returns>
        private ICellStyle SetCdrCellStyle(HSSFWorkbook workbook, PropertyInfo propertyInfo, T dbModel, ICellStyle cdrRowStyle)
        {
            if (cdrRowStyle != null)
            {
                return(cdrRowStyle);
            }

            return(ExcelStyle.CenterStyle(workbook));
        }
        private ISheet CreateSheet(HSSFWorkbook workbook, int sheetCount, int sheetIdx, string title, out int occupancyRows)
        {
            ExcelStyle.InitSheetStyle();
            occupancyRows = 0;
            ISheet sheet    = workbook.CreateSheet("Sheet" + sheetIdx);
            string strTitle = title + (sheetCount == 1 ? "" : " (" + sheetIdx + ")");

            sheet         = ExcelStyle.SetSheeetParams(sheet);
            occupancyRows = CreateSheetTitle(workbook, sheet, strTitle, occupancyRows);
            occupancyRows = CreateSheetHeads(workbook, sheet, occupancyRows);
            return(sheet);
        }
        private int CreateSheetTitle(HSSFWorkbook workbook, ISheet sheet, string title, int titleOccupancyRows)
        {
            IRow row = sheet.CreateRow(titleOccupancyRows);

            row.HeightInPoints = 25;
            ICell cell = row.CreateCell(0);

            cell.CellStyle = ExcelStyle.GetStyleTitle(workbook);
            cell.SetCellValue(title);
            sheet.AddMergedRegion(new CellRangeAddress(0, 0, 0, ExportCellHeadList.Count - 1));

            titleOccupancyRows++;
            return(titleOccupancyRows);
        }
 public ExportExcelService()
 {
     this.ExcelStyle = new ExcelStyle();
     typeMapper      = new TypeMapper <ExcelInfo>();
 }