Copy format from one row to another using c#

前端 未结 3 1702
抹茶落季
抹茶落季 2020-12-20 23:56

This question is quite similar to the one asked here. But the answer given suggests copying the format along with the data. I have a excel sheet (.xlsx) that I generate usin

3条回答
  •  抹茶落季
    2020-12-21 00:35

    You can use PasteSpecial with xlPasteFormats.

    Excel.Range R1 = (Excel.Range)oSheet.Cells[11, 11];
    R1.Copy(Type.Missing);
    
    Excel.Range R2 = (Excel.Range)oSheet.Cells[15, 15];
    R2.PasteSpecial(Excel.XlPasteType.xlPasteFormats,
        Excel.XlPasteSpecialOperation.xlPasteSpecialOperationNone, false, false);
    

提交回复
热议问题