本文整理汇总了C#中Microsoft.Office.Interop.Excel.Range.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# Range.Insert方法的具体用法?C# Range.Insert怎么用?C# Range.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Office.Interop.Excel.Range
的用法示例。
在下文中一共展示了Range.Insert方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertRows
/// <summary>
/// 插行(在指定WorkSheet指定行上面插入指定数量行)
/// </summary>
/// <param name="sheetIndex"></param>
/// <param name="rowIndex"></param>
/// <param name="count"></param>
public void InsertRows(int sheetIndex, int rowIndex, int count)
{
if (sheetIndex > this.WorkSheetCount)
{
this.KillExcelProcess();
throw new Exception("索引超出范围,WorkSheet索引不能大于WorkSheet数量!");
}
try
{
workSheet = (Excel.Worksheet)workBook.Worksheets[sheetIndex];
range = (Excel.Range)workSheet.Rows[rowIndex, this.missing];
for (int i = 0; i < count; i++)
{
range.Insert(Excel.XlDirection.xlDown);
}
}
catch (Exception e)
{
this.KillExcelProcess();
throw e;
}
}
示例2: InsertRows
/// <summary>
/// 插行(在指定行上面插入指定数量行)
/// </summary>
/// <param name="rowIndex"></param>
/// <param name="count"></param>
public void InsertRows(int rowIndex, int count)
{
try
{
range = (Excel.Range)workSheet.Rows[rowIndex, this.missing];
for (int i = 0; i < count; i++)
{
range.Insert(Excel.XlDirection.xlDown, missing);
}
}
catch (Exception e)
{
this.KillExcelProcess(false);
throw e;
}
}
示例3: AddRow
/// <summary>
/// Метод добавляет пустую строку.
/// </summary>
/// <param name="rowNum">Номер строки</param>
public void AddRow(int rowNum)
{
_range = (Excel.Range)_xlWorkSheet.Rows[rowNum, _misValue];
_range.Select();
_range.Insert(Excel.XlInsertShiftDirection.xlShiftDown, _misValue);
}
示例4: InsertColumns
/// <summary>
/// 插列(在指定列右边插入指定数量列)
/// </summary>
/// <param name="columnIndex"></param>
/// <param name="count"></param>
public void InsertColumns(int columnIndex, int count)
{
try
{
range = (Excel.Range)(workSheet.Columns[columnIndex, this.missing]); //注意:这里和VS的智能提示不一样,第一个参数是columnindex
for (int i = 0; i < count; i++)
{
range.Insert(Excel.XlDirection.xlDown, missing);
}
}
catch (Exception e)
{
this.KillExcelProcess(false);
throw e;
}
}