Ejemplo n.º 1
0
        private void CustomTableHeader(object sender, TableWritingEventArgs args)
        {
            IExportable expObj = sender as IExportable;

            IRow  titleRow = args.Sheet.CreateRow(expObj.NextRowNum());
            ICell cell     = titleRow.CreateCell(0);

            args.Sheet.AddMergedRegion(new CellRangeAddress(titleRow.RowNum, titleRow.RowNum, 0, args.Export.Body.MaxColumnIndex));

            ICellStyle style = args.Sheet.Workbook.CreateCellStyle();

            style.Alignment         = HorizontalAlignment.Center;
            style.VerticalAlignment = VerticalAlignment.Center;
            IFont font = args.Sheet.Workbook.CreateFont();

            font.Color      = HSSFColor.Red.Index;
            font.FontName   = "宋体";
            font.FontHeight = 20 * 20;
            font.Boldweight = 10;
            font.IsItalic   = true;

            style.SetFont(font);
            cell.CellStyle = style;
            cell.SetCellValue("成绩导出");
        }
Ejemplo n.º 2
0
        private void CustomTableFooter(object sender, TableWritingEventArgs args)
        {
            IExportable expObj = sender as IExportable;

            IRow  endRow = args.Sheet.CreateRow(expObj.NextRowNum());
            ICell cell   = endRow.CreateCell(0);

            args.Sheet.AddMergedRegion(new CellRangeAddress(endRow.RowNum, endRow.RowNum, 0, args.Export.Body.MaxColumnIndex));

            ICellStyle style = args.Sheet.Workbook.CreateCellStyle();

            style.Alignment           = HorizontalAlignment.Right;
            style.VerticalAlignment   = VerticalAlignment.Center;
            style.FillForegroundColor = HSSFColor.Green.Index;
            style.FillPattern         = FillPattern.AltBars;
            style.FillBackgroundColor = HSSFColor.Green.Index;

            cell.SetCellValue(DateTime.Today, expObj.ExcelDateFormat);
        }