0

I already have the path of the Excel file, but whenever I call save method, the program writes new content to UTC.xlsx file.

string pathString = "C:\Users\ADMIN-PC\Documents\SUMMER 2018\PRN192\CreateFile\SubFolder\UTC.xlsx"; ef.Save(pathString);

ndmeiri
  • 4,979
  • 12
  • 37
  • 45
Teresa
  • 1
  • the `ef.save(pathString)` will override old data. – giaosudauto Jul 24 '18 at 03:53
  • Possible duplicate of [Gembox Spreadsheet add column without remove the other ones](https://stackoverflow.com/questions/35430096/gembox-spreadsheet-add-column-without-remove-the-other-ones) – giaosudauto Jul 24 '18 at 03:56
  • Thanks, but can you tell me the specific method?#giaosudauto – Teresa Jul 24 '18 at 05:11
  • You need to load the existing Excel file and then write your new content into it and then save. So something like: var ef = ExcelFile.Load(pathString); /* Write new content ... */ ef. Save(pathString); – Mario Z Jul 28 '18 at 06:13

1 Answers1

0
var path = @"C:\Users\ADMIN-PC\Documents\SUMMER 2018\PRN192\CreateFile\SubFolder\UTC.xlsx";

// Load the workbook:
var workbook = ExcelFile.Load(path);

// Manipulate the workbook … 
// … and save it over the original
workbook.Save(path);
Josh Gallagher
  • 5,211
  • 2
  • 33
  • 60