首页 文章

如何在C#中完全删除excel单元格的内容和属性?

提问于
浏览
1

有没有简单的方法,给定从Excel工作表(使用C#)获取的一系列单元格,删除其所有内容?

所有内容我的意思是:背景变为白色,文本=空,删除公式以及之前插入该单元格/单元格区域的任何文本格式?

提前致谢

1 回答

  • 2

    这解决了我的问题,基本上,手动设置属性回到他们的“默认”值

    cell.Formula = "";
                cell.Value2 = (string) String.Empty;
                cell.Font.Bold = false;
                cell.Font.Name = "Tahoma";
                cell.Font.Size = 10;
                cell.BorderAround();
                cell.HorizontalAlignment = XlHAlign.xlHAlignCenter;
                cell.Interior.Color = System.Drawing.ColorTranslator.ToOle(Color.FromArgb(255,255,255));
                cell.ShrinkToFit = false;
    

    不管怎么说,多谢拉 :)

相关问题