【问题标题】:Copy/Paste cells & value with property使用属性复制/粘贴单元格和值
【发布时间】:2018-12-07 16:13:42
【问题描述】:

我想复制/粘贴工作表中的范围,包括单元格中的值/属性(删除线)到另一个新工作簿。
我无法在新工作表上设置此属性。使用 Microsoft.Office.Interop.Excel; 我无法像图片中那样复制此属性。我该怎么做。 1 个单元格中的 3 行具有不同的属性

public void WriteCellWithFont(int i, int j , _Excel.Range cell)
{
    i++;
    j++;
    ws.Cells[i, j].Value2 = cell.Value2;
    ws.Cells[i,j].Font.Strikethrough = true;
}

【问题讨论】:

    标签: c# excel


    【解决方案1】:

    尝试使用 PasteSpecial。它就像我们在粘贴时用来保持格式的正常方式一样。

    // copy
    Range cells1 = (Range)worksheet1.Cells[2, 3];
    cells1.Copy();
    
    // Paste
    Range cells2= (Range)worksheet2.Cells[2, 3];
    cells2.PasteSpecial(XlPasteType.xlPasteFormats);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-11
      • 2022-01-22
      • 2023-02-14
      • 2014-12-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多