当前位置: 代码迷 >> .NET Framework >> 使用EPPlus怎么在代码中替换Excel里面的公式,并且保存。
  详细解决方案

使用EPPlus怎么在代码中替换Excel里面的公式,并且保存。

热度:58   发布时间:2016-05-01 23:58:02.0
使用EPPlus如何在代码中替换Excel里面的公式,并且保存。。

                        string str = worksheet.Cells["E22"].Formula;
                        str = str.Replace("AAA()", "1");
                        str = str.Replace("BBB()", "2");
                        str = str.Replace("ccc()", "3");
                        //str.Substring(
                        worksheet.Cells["E22"].Formula = str;
                        //ep.Workbook.Properties.SetCustomPropertyValue
                        ep.Save();
                        //ep.SaveAs(new FileInfo(fileName));
                        //worksheet.Cells["E22"].Formula = "1";
                        //worksheet.Cells["E22"].Formula.Insert(1, str);
                        Console.WriteLine(worksheet.Cells["E22"].Formula);


用这段代码我可以把公式替换了,但是我不知道怎么保存了~ 请会玩EPPlus的指导下,我是刚用这个,对于EPPlus以前也根本不了解~ 但是客户要求用这个做,没办法~~愁啊..

------解决方案--------------------
没怎么用过,仔细瞅瞅源代码吧,里面应该有介绍
  相关解决方案