Good morning, I would like to edit some cells from already existing excell file. I tried use EPPlus and normal OpenXml classes. However I failed. In both situation program w
You can use the Interop dll's from Microsoft to edit office documents http://msdn.microsoft.com/en-us/library/15s06t57.aspx. Add the "Microsoft.Office.Interop.Excel.dll" to your solution. With this code i've changed 2 cell values.
static void Main(string[] args)
{
Application excel = new Application();
Workbook workbook = excel.Workbooks.Open(@"C:\Users\Martijn\Documents\Test.xlsx", ReadOnly: false, Editable:true);
Worksheet worksheet = workbook.Worksheets.Item[1] as Worksheet;
if (worksheet == null)
return;
Range row1 = worksheet.Rows.Cells[1, 1];
Range row2 = worksheet.Rows.Cells[2, 1];
row1.Value = "Test100";
row2.Value = "Test200";
excel.Application.ActiveWorkbook.Save();
excel.Application.Quit();
excel.Quit();
}
I've started with Test1 and Test2 wich after the program running changed into the proper values.
