/// <summary>
/// 插入数据
/// </summary>
/// <param name="rowIndex">行号</param>
/// <param name="columnIndex">列号</param>
/// <param name="content">内容</param>
/// <param name="comment">批注</param>
public static void InsertCell(int rowIndex, int columnIndex, string content, string comment)
{
Microsoft.Office.Interop.Excel.ApplicationClass excel = wbb.Application as Microsoft.Office.Interop.Excel.ApplicationClass;
Microsoft.Office.Interop.Excel.Workbook wb = excel.Workbooks[1];
int a = wb.Application.ActiveCell.Row;
Microsoft.Office.Interop.Excel.Worksheet ws = wb.Worksheets[1] as Microsoft.Office.Interop.Excel.Worksheet;
range = ws.Cells;
Microsoft.Office.Interop.Excel.Range oCell = range[rowIndex, columnIndex] as Microsoft.Office.Interop.Excel.Range;
oCell.Value2 = content;
}
本文介绍了一种使用 C# 在 Excel 中指定位置插入数据的方法。通过 Microsoft Office Interop Excel 组件,可以实现设置单元格内容及批注的功能。该方法接受行号、列号、内容和批注作为参数。
496

被折叠的 条评论
为什么被折叠?



