日期:2014-05-17 浏览次数:20463 次
private void btnSave_Click(object sender, EventArgs e)
{
//创建Application对象
Excel.Application xApp = new Excel.Application();
xApp.Visible = true;
//得到WorkBook对象
Excel.Workbook xBook = xApp.Workbooks._Open(@""+file.FileName+"",
Missing.Value, Missing.Value, Missing.Value, Missing.Value
, Missing.Value, Missing.Value, Missing.Value, Missing.Value
, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
//指定要操作的Sheet
Excel.Worksheet xSheet = (Excel.Worksheet)xBook.Sheets[1];
//写入数据
for (int i = 4; i < ; i++)
{
Excel.Range rng3 = xSheet.get_Range("G"+i+"", Missing.Value);
rng3.Value2 = "Hello";
}
}