本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}