当前位置: 首页>>代码示例>>C#>>正文


C# IRow.CreateCell方法代码示例

本文整理汇总了C#中IRow.CreateCell方法的典型用法代码示例。如果您正苦于以下问题:C# IRow.CreateCell方法的具体用法?C# IRow.CreateCell怎么用?C# IRow.CreateCell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IRow的用法示例。


在下文中一共展示了IRow.CreateCell方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: buildWorkbook

        private void buildWorkbook(IWorkbook wb)
        {
            ISheet sh = wb.CreateSheet();
            IRow row1 = sh.CreateRow(0);
            IRow row2 = sh.CreateRow(1);
            row3 = sh.CreateRow(2);

            row1.CreateCell(0, CellType.Numeric);
            row1.CreateCell(1, CellType.Numeric);

            row2.CreateCell(0, CellType.Numeric);
            row2.CreateCell(1, CellType.Numeric);

            row3.CreateCell(0);
            row3.CreateCell(1);

            CellReference a1 = new CellReference("A1");
            CellReference a2 = new CellReference("A2");
            CellReference b1 = new CellReference("B1");
            CellReference b2 = new CellReference("B2");

            sh.GetRow(a1.Row).GetCell(a1.Col).SetCellValue(35);
            sh.GetRow(a2.Row).GetCell(a2.Col).SetCellValue(0);
            sh.GetRow(b1.Row).GetCell(b1.Col).CellFormula = (/*setter*/"A1/A2");
            sh.GetRow(b2.Row).GetCell(b2.Col).CellFormula = (/*setter*/"NA()");

            Evaluator = wb.GetCreationHelper().CreateFormulaEvaluator();
        }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:28,代码来源:TestLogicalFunction.cs

示例2: CreateCell

        internal static ICell CreateCell(IWorkbook workbook, IRow row, int column, decimal? content, bool isCentered)
        {
            ICellStyle style = workbook.CreateCellStyle();
            ICell cell = row.CreateCell(column);
            if (content == null)
            {
                cell.SetCellValue("");
            }
            else
            {
                cell.SetCellValue(Convert.ToDouble(content.Value));
            }
            if (isCentered)
            {
                style.Alignment = HorizontalAlignment.Center;

            }
            style.BorderBottom = BorderStyle.Thin;
            style.BorderTop = BorderStyle.Thin;
            style.BorderLeft = BorderStyle.Thin;
            style.BorderRight = BorderStyle.Thin;

            cell.CellStyle = style;
            return cell;
        }
开发者ID:chamilka,项目名称:drreport,代码行数:25,代码来源:CellManager.cs

示例3: InsertCell

 private static int InsertCell(IRow row, int cellIndex, string value, ICellStyle cellStyle)
 {
     var cell = row.CreateCell(cellIndex);
     cell.SetCellValue(value);
     cell.CellStyle = cellStyle;
     cellIndex++;
     return cellIndex;
 }
开发者ID:zhh007,项目名称:CKGen,代码行数:8,代码来源:ExcelHelper.cs

示例4: CreateCells

 public void CreateCells(int cellsCount, ref IRow row, IList<string> cellsValues = null)
 {
     //var isEmptyCells = cellsValues == null || !cellsValues.Any() || cellsValues.Count != cellsCount;
     //if (isEmptyCells)
     //    for (var j = 0; j < cellsCount; j++)
     //        row.CreateCell(j).SetCellValue(string.Empty);
     //else
         for (var j = 0; j < cellsCount; j++)
             row.CreateCell(j).SetCellValue("cell " + j);
 }
开发者ID:adamsabri,项目名称:Security,代码行数:10,代码来源:BaseWriter.cs

示例5: WriteCell

        protected ICell WriteCell(IRow row, int column, Action<ICell> setValue, ICellStyle style = null)
        {
            var cell = row.CreateCell(column);
            setValue(cell);
            if (style != null)
            {
                cell.CellStyle = style;
            }

            return cell;
        }
开发者ID:breslavsky,项目名称:queue,代码行数:11,代码来源:BaseReport.cs

示例6: SetCellValue

		public void SetCellValue(IRow row, int index, CellType cellType, dynamic value)
		{
			if (value == null) value = string.Empty;
			if (value is string)
			{
				value = Convert.ChangeType(value, TypeCode.String);
			}
			else
			{
				value = Convert.ChangeType(value, TypeCode.Double);
			}

			ICell cell = row.CreateCell(index);
			cell.SetCellType(cellType);
			cell.SetCellValue(value);
		}
开发者ID:green-s,项目名称:CSGO-Demos-Manager,代码行数:16,代码来源:AbstractSheet.cs

示例7: GetOrCreateCell

 /// <summary>
 /// 获取单元格,如果不存在则创建
 /// </summary>
 private ICell GetOrCreateCell( IRow row, int columnIndex ) {
     return row.GetCell( columnIndex ) ?? row.CreateCell( columnIndex );
 }
开发者ID:BeiMeng,项目名称:GitApplication,代码行数:6,代码来源:NpoiExcelBase.cs

示例8: WriteTitle

 /// <summary>
 /// 写入数据到Row
 /// </summary>
 /// <param name="row"></param>
 /// <param name="columns"></param>
 public void WriteTitle(IRow row, DataColumnCollection columns)
 {
     for (int j = 0; j < columns.Count; j++)
     {
         var cell = row.CreateCell(j);
         cell.SetCellValue(columns[j].ColumnName);
         cell.CellStyle = titleStyle;
     }
 }
开发者ID:bosima,项目名称:FireflySoft.Excel,代码行数:14,代码来源:NPOIOperator.cs

示例9: CreateRow

        /// <summary>
        /// 创建一行数据
        /// </summary>
        /// <param name="row">Row 对象</param>
        /// <param name="rowDatas">填入 Row 的只读数据集合</param>
        /// <param name="userStringFormat">是否是否使用 string 数据格式,默认 false</param>
        private void CreateRow(IRow row, object[] rowDatas, bool userStringFormat = false)
        {
            for (var i = 0; i < rowDatas.Length; i++)
            {
                var cell = row.CreateCell(i);
                var data = rowDatas[i];

                var dataType = data == null || userStringFormat ? typeof(string) : data.GetType();
                WriteToCell(cell, dataType, data);
            }
        }
开发者ID:yangganggood,项目名称:EMP,代码行数:17,代码来源:ExcelWriter.cs

示例10: CreateCellForRow

 /// <summary>
 /// 根据datarow 创建 cells. 
 /// </summary>
 /// <param name="excelRow"></param>
 /// <param name="columns"></param>
 /// <param name="row">如果为null 则该行所有cell的值为空</param>
 /// <param name="isHead">如果是true 则创建表头.</param>
 private void CreateCellForRow(IRow excelRow, DataColumnCollection columns, DataRow row,bool isHead)
 {
     for (int i=0;i<columns.Count;i++)
     {
         var cell = excelRow.CreateCell(i);
         if (isHead)
         {
             cell.SetCellValue(columns[i].ColumnName);
         }
         else
         {
             string cellValue = string.Empty;
             if (row != null) { cellValue = row[i].ToString(); }
             cell.SetCellValue(cellValue);
         }
     }
 }
开发者ID:phiree,项目名称:NTSBase,代码行数:24,代码来源:TransferInDatatable.cs

示例11: SetRow

 /// <summary>
 /// 设置行
 /// </summary>
 /// <param name="row"></param>
 /// <param name="obj"></param>
 private static void SetRow(IRow row, object obj)
 {
     //获取属性
     var columns = obj.GetType().GetProperties();
     //一个属性一个格
     for (int i = 0; i < obj.GetType().GetProperties().Length; i++)
     {
         //创建格
         ICell cell = row.CreateCell(i);
         //设置单元格的内容
         SetCell(cell, columns[i], obj);
     }
 }
开发者ID:v5bep7,项目名称:Utility,代码行数:18,代码来源:ExcelHelper.cs

示例12: CreateRow

 /// <summary>
 /// 创建 Row
 /// </summary>
 /// <param name="row">Row 对象</param>
 /// <param name="datas">填入 Row 的只读数据集合</param>
 /// <param name="isFormat">是否数据有格式化,默认 true</param>
 private void CreateRow(IRow row, IReadOnlyList<object> datas, bool isFormat = true)
 {
     for (var i = 0; i < this._columnNames.Length; i++)
     {
         var cell = row.CreateCell(i);
         var dataType = isFormat ? this._columnTypes[i] : typeof (string);
         this.WriteToCell(cell, dataType, datas[i]);
     }
 }
开发者ID:yangganggood,项目名称:ReportMS,代码行数:15,代码来源:ExcelRecord.cs

示例13: CreateCell

 /// <summary>NPOI新增儲存格資料</summary>
 /// <param name="Word">顯示文字</param>
 /// <param name="ContentRow">NPOI IROW</param>
 /// <param name="CellIndex">儲存格列數</param>
 /// <param name="cellStyleBoder">ICellStyle樣式</param>
 private static void CreateCell(string Word, IRow ContentRow, int CellIndex, ICellStyle cellStyleBoder)
 {
     ICell _cell = ContentRow.CreateCell(CellIndex);
     _cell.SetCellValue(Word);
     _cell.CellStyle = cellStyleBoder;
 }
开发者ID:haoas,项目名称:2014.IT.Ironman7,代码行数:11,代码来源:OrderController.cs

示例14: CreateCellForRow

        /// <summary>
        /// 根据datarow 创建 cells. 
        /// </summary>
        /// <param name="excelRow"></param>
        /// <param name="columns"></param>
        /// <param name="row">如果为null 则该行所有cell的值为空</param>
        /// <param name="isHead">如果是true 则创建表头.</param>
        private void CreateCellForRow(IRow excelRow, DataColumnCollection columns, DataRow row, bool isHead)
        {
            for (int i = 0; i < columns.Count; i++)
            {
                var cell = excelRow.CreateCell(i);
                if (isHead)
                {
                    cell.SetCellValue(columns[i].ColumnName);
                }
                else
                {
                    string cellValue = string.Empty;
                    if (row != null) { cellValue = row[i].ToString(); }

                    //该地址是图片
                    if (NeedInsertImage&& Regex.IsMatch(cellValue, @"\.jpg|\.png|\.tiff|\.tif", RegexOptions.IgnoreCase))
                    {
                        string filePath = System.Web.HttpContext.Current.Server.MapPath("/ProductImages/original/" + cellValue);
                        if (File.Exists(filePath))
                        {

                            try
                            {
                                System.Drawing.Image image = System.Drawing.Image.FromFile(filePath);

                                System.Drawing.Bitmap targetImage = ThumbnailMaker.DrawThumbnail(image, ThumbnailType.GeometricScalingByWidth, 150, 0);
                                excelRow.Sheet.SetColumnWidth(i, MSExcelUtil.pixel2WidthUnits(targetImage.Width - 2));
                                excelRow.HeightInPoints = (float)((targetImage.Height - 2) * 0.75);
                                using (MemoryStream ms = new MemoryStream())
                                {
                                    targetImage.Save(ms, image.RawFormat);

                                    InsertImageToCell(ms, i, excelRow.RowNum);
                                }
                                targetImage.Dispose();
                                image.Dispose();
                            }
                            catch (Exception ex)
                            {
                                NLogger.Logger.Debug(filePath+ex.Message);
                            }

                        }
                    }
                    else
                    {
                        cell.SetCellValue(cellValue);
                    }
                }
            }
        }
开发者ID:phiree,项目名称:NTSBase2,代码行数:58,代码来源:TransferInDatatable.cs

示例15: topBottomBorder

 internal static void topBottomBorder(IWorkbook workbook, ICell cell, IRow row, int numCells)
 {
     ICellStyle cellStyle = workbook.CreateCellStyle();
     cellStyle.BorderBottom = BorderStyle.Thin;
     cellStyle.BorderTop = BorderStyle.Thin;
     cellStyle.BorderLeft = BorderStyle.Thin;
     cellStyle.BorderRight = BorderStyle.Thin;
     for (int i = 1; i <= numCells; i++)
     {
         ICell newCell = row.CreateCell(cell.ColumnIndex + i);
         newCell.CellStyle = cellStyle;
     }
 }
开发者ID:chamilka,项目名称:drreport,代码行数:13,代码来源:CellManager.cs


注:本文中的IRow.CreateCell方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。