简体   繁体   中英

ExcelPackage not Saving programmatically using C#

I'm trying to edit an existing excel file with .xlsx extension using C#,but it is not saving the new value.My code is as follows.Can anybody help me?

 string path = @"D:\Demo\test.xlsx"    ;  
    FileInfo file = new FileInfo(Path.GetFileName(path));
          using (ExcelPackage xlPackage = new ExcelPackage(file))
           {
                 ExcelWorkbook workBook = xlPackage.Workbook;
                 ExcelWorksheet ws = workBook.Worksheets[1];
                 ws.Cells[8, 6].Value = 25;
                 xlPackage.Save();
           }

Put the @ symbol before your path string to prevent automatic stripping or manually escape your \\ characters

string path = @"D:\test\test.xslx";

Or

string path = "D:\\test\\test.xslx";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM