我在我的程序中使用Interop.Excel。我需要改变细胞的价值。你能说更快的方法吗?
ChangeValue1()
{
object c1, c2;
c1 = (Range)excelworksheet.Cells[1, 1];
c2 = (Range)excelworksheet.Cells[2,2];
Range cell1 = (Range)excelworksheet.get_Range(c1, c2);
cell1.Copy(Type.Missing);
c1 = (Range)excelworksheet.Cells[3, 1];
c2 = (Range)excelworksheet.Cells[4,2];
Range cell2 = (Range)excelworksheet.get_Range(c1, c2);
cell2.PasteSpecial(XlPasteType.xlPasteValuesAndNumberFormats, XlPasteSpecialOperation.xlPasteSpecialOperationNone,true, false);
}
或
ChangeValue2()
{
object c1, c2;
c1 = (Range)excelworksheet.Cells[1, 1];
c2 = (Range)excelworksheet.Cells[2,2];
Range cell1 = (Range)excelworksheet.get_Range(c1, c2);
c1 = (Range)excelworksheet.Cells[3, 1];
c2 = (Range)excelworksheet.Cells[4,2];
Range cell2 = (Range)excelworksheet.get_Range(c1, c2);
cell2.Value2=cell1.Value2;
}