Esempio n. 1
0
 /// <summary>
 ///     格式化
 /// </summary>
 /// <param name="sheetAdapter">Sheet适配器</param>
 public override void Format(SheetAdapter sheetAdapter)
 {
     if (FormatterList.IsNullOrEmpty())
     {
         throw new ExcelReportFormatException("TableFormatter is empty");
     }
     if (DataSource.IsNullOrEmpty())
     {
         sheetAdapter.RemoveRow(TagParameter.RowIndex); //删除模板行
     }
     else
     {
         for (int i = 0; i < DataSource.Count; i++)
         {
             if (i < DataSource.Count - 1) //非最后一行数据时,复制模板
             {
                 sheetAdapter.CopyRow(TagParameter.RowIndex, () =>
                 {
                     foreach (var formatter in FormatterList) //格式化行
                     {
                         formatter.Format(sheetAdapter, DataSource[i]);
                     }
                 });
             }
             else
             {
                 foreach (var formatter in FormatterList) //格式化行
                 {
                     formatter.Format(sheetAdapter, DataSource[i]);
                 }
             }
         }
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 格式化
 /// </summary>
 /// <param name="workbook">工作薄</param>
 public void Format(IWorkbook workbook)
 {
     ISheet sheet = workbook.GetSheet(SheetName);
     if (!sheet.IsNull() && !FormatterList.IsNullOrEmpty())
     {
         var sheetAdapter = new SheetAdapter(sheet);
         foreach (ElementFormatter formatter in FormatterList)
         {
             formatter.Format(sheetAdapter);
         }
     }
 }
Esempio n. 3
0
        /// <summary>
        /// 格式化
        /// </summary>
        /// <param name="workbook">工作薄</param>
        public void Format(IWorkbook workbook)
        {
            ISheet sheet = workbook.GetSheet(SheetName);

            if (!sheet.IsNull() && !FormatterList.IsNullOrEmpty())
            {
                var sheetAdapter = new SheetAdapter(sheet);
                foreach (ElementFormatter formatter in FormatterList)
                {
                    formatter.Format(sheetAdapter);
                }
            }
        }
Esempio n. 4
0
 /// <summary>
 ///     格式化
 /// </summary>
 /// <param name="sheetAdapter">Sheet适配器</param>
 public override void Format(SheetAdapter sheetAdapter)
 {
     IRow row = sheetAdapter.GetRow(Parameter.RowIndex);
     if (null == row)
     {
         throw new ExcelReportFormatException("row is null");
     }
     ICell cell = row.GetCell(Parameter.ColumnIndex);
     if (null == cell)
     {
         throw new ExcelReportFormatException("cell is null");
     }
     cell.SetValue(Value);
 }
Esempio n. 5
0
        /// <summary>
        ///     格式化
        /// </summary>
        /// <param name="sheetAdapter">Sheet适配器</param>
        public override void Format(SheetAdapter sheetAdapter)
        {
            IRow row = sheetAdapter.GetRow(Parameter.RowIndex);
            if (null == row)
            {
                throw new ExcelReportException("row is null");
            }
            ICell cell = row.GetCell(Parameter.ColumnIndex);
            if (null == cell)
            {
                throw new ExcelReportException("cell is null");
            }

            cell.SetValue(cell.StringCellValue.Replace(string.Format("$[{0}]", Parameter.Name), Value.CastTo<string>()));
        }
Esempio n. 6
0
        /// <summary>
        ///     格式化
        /// </summary>
        /// <param name="sheetAdapter">Sheet适配器</param>
        public override void Format(SheetAdapter sheetAdapter)
        {
            IRow row = sheetAdapter.GetRow(Parameter.RowIndex);

            if (null == row)
            {
                throw new ExcelReportFormatException("row is null");
            }
            ICell cell = row.GetCell(Parameter.ColumnIndex);

            if (null == cell)
            {
                throw new ExcelReportFormatException("cell is null");
            }
            cell.SetValue(Value);
        }
Esempio n. 7
0
        /// <summary>
        ///     格式化
        /// </summary>
        /// <param name="sheetAdapter">Sheet适配器</param>
        public override void Format(SheetAdapter sheetAdapter)
        {
            IRow row = sheetAdapter.GetRow(Parameter.RowIndex);

            if (null == row)
            {
                throw new ExcelReportException("row is null");
            }
            ICell cell = row.GetCell(Parameter.ColumnIndex);

            if (null == cell)
            {
                throw new ExcelReportException("cell is null");
            }

            cell.SetValue(cell.StringCellValue.Replace(string.Format("$[{0}]", Parameter.Name), Value.CastTo <string>()));
        }