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


C# Row.InsertBefore方法代码示例

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


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

示例1: CreateCell

        // Add a cell with the specified address to a row.
        private static DocumentFormat.OpenXml.Spreadsheet.Cell CreateCell(Row row, String address)
        {
            DocumentFormat.OpenXml.Spreadsheet.Cell cellResult;
            DocumentFormat.OpenXml.Spreadsheet.Cell refCell = null;

            // Cells must be in sequential order according to CellReference. 
            // Determine where to insert the new cell.
            foreach (DocumentFormat.OpenXml.Spreadsheet.Cell cell in row.Elements<DocumentFormat.OpenXml.Spreadsheet.Cell>())
            {
                // if (string.Compare(cell.CellReference.Value, address, true) > 0)
                if (CompareCellName(cell.CellReference.Value, address) > 0)
                {
                    refCell = cell;
                    break;
                }
            }

            cellResult = new DocumentFormat.OpenXml.Spreadsheet.Cell();
            cellResult.CellReference = address;

            row.InsertBefore(cellResult, refCell);
            return cellResult;
        }
开发者ID:paopaofeng,项目名称:dp2,代码行数:24,代码来源:ExcelUtil.cs

示例2: CreateCell

        // Add a cell with the specified address to a row.
        protected Cell CreateCell(Row row, String address)
        {
            Cell cellResult;
            Cell refCell = null;

            // Cells must be in sequential order according to CellReference.
            // Determine where to insert the new cell.
            foreach (Cell cell in row.Elements<Cell>())
            {
                if (string.Compare(cell.CellReference.Value, address, true) > 0)
                {
                    refCell = cell;
                    break;
                }
            }

            cellResult = new Cell();
            cellResult.CellReference = address;

            row.InsertBefore(cellResult, refCell);
            return cellResult;
        }
开发者ID:War0n,项目名称:Leaping-Cliff,代码行数:23,代码来源:IExcelDataTransfer.cs

示例3: AppendCell

        // 追加一个 Cell
        public static DocumentFormat.OpenXml.Spreadsheet.Cell AppendCell(
            // Worksheet ws,
            Row row,
            string addressName)
        {
            // SheetData sheetData = ws.GetFirstChild<SheetData>();
            DocumentFormat.OpenXml.Spreadsheet.Cell cell = null;

            cell = new DocumentFormat.OpenXml.Spreadsheet.Cell();
            cell.CellReference = addressName;

            row.InsertBefore(cell, null);

            return cell;
        }
开发者ID:paopaofeng,项目名称:dp2,代码行数:16,代码来源:ExcelUtil.cs

示例4: createCell

 //
 //  Add a new cell at the specified address
 //
 private Cell createCell(Row row, string addr)
 {
     Cell cellResult;
     Cell refCell = null;
     //
     //  Parse the selected row until found the wanted one
     //  or return a new cell
     //
     foreach (Cell cell in row.Elements<Cell>())
     {
         if (string.Compare(cell.CellReference.Value, addr, true) > 0)
         {
             refCell = cell;
             break;
         }
     }
     //
     //  Create a new Cell and insert it
     //
     cellResult = new Cell();
     cellResult.CellReference = addr;
     row.InsertBefore(cellResult, refCell);
     return cellResult;
 }
开发者ID:Rossano,项目名称:Dome_Control,代码行数:27,代码来源:LogLib.cs

示例5: CreateCell

        /// <summary>
        /// Вставка ячейки по адресу
        /// </summary>
        /// <param name="row"></param>
        /// <param name="address"></param>
        /// <returns></returns>
        private Cell CreateCell(Row row, String address)
        {
            var refCell = row.Elements<Cell>().FirstOrDefault(cell => String.Compare(cell.CellReference.Value, address, StringComparison.OrdinalIgnoreCase) > 0);

            Cell cellResult = new Cell { CellReference = address };

            row.InsertBefore(cellResult, refCell);
            return cellResult;
        }
开发者ID:gerasyana,项目名称:Academy,代码行数:15,代码来源:ExcellWorker.cs

示例6: GetCell

        private static Cell GetCell(Row row, string columnName)
        {
            string cellReference = columnName + row.RowIndex;
            int columnIndex = ExcelUtilities.ColumnNameToOrdinal(columnName);

            var cell = row.Elements<Cell>().Where(c => c.CellReference.Value == cellReference).FirstOrDefault();
            if (cell == null)
            {
                Cell refCell = null;
                foreach (Cell otherCell in row.Elements<Cell>())
                {
                    int otherColumnIndex = ExcelUtilities.ColumnNameToOrdinal(ExcelUtilities.GetColumnName(otherCell.CellReference.Value));
                    if (otherColumnIndex > columnIndex)
                    {
                        refCell = otherCell;
                        break;
                    }
                }
                cell = new Cell() { CellReference = cellReference };
                row.InsertBefore(cell, refCell);
                if (refCell == null)
                {
                    if (row.Spans == null)
                        row.Spans = new ListValue<StringValue>();
                    row.Spans.InnerText = string.Format("1:{0}", columnIndex);
                }
                //connection.DeferredSubmit();
            }
            return cell;
        }
开发者ID:andresmoschini,项目名称:Moschini.Excel,代码行数:30,代码来源:OpenXmlExcelRandomWriter.cs


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