Tutorial by Examples

//set the total value of cells in range A1 - A25 into A27 worksheet.Cells["A27"].Formula = "=SUM(A1:A25)"; //set the number of cells with content in range C1 - C25 into C27 worksheet.Cells["C27"].Formula = "=COUNT(C1:C25)"; //fill column K with the s...
//set the total value of all cells in Sheet 2 into G27 worksheet.Cells["G27"].Formula = "=SUM('" + worksheet2.Name + "'!" + worksheet2.Dimension.Start.Address + ":" + worksheet2.Dimension.End.Address + ")"; //set the number of cells with conten...
If you use formulas, Excel will ask you to save the file every time, even if there were no changes made. To prevent this behaviour you can set the calculation mode to manual. excelPackage.Workbook.CalcMode = ExcelCalcMode.Manual; //fill the sheet with data and set the formulas excelPackage....
//create a new ExcelPackage using (ExcelPackage excelPackage = new ExcelPackage()) { //create 2 WorkSheets ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets.Add("Sheet 1"); ExcelWorksheet worksheet2 = excelPackage.Workbook.Worksheets.Add("Sheet 2"); ...

Page 1 of 1