Well, if you could manually insert two rows at second row (A2 cell location) in MS Excel, you will notice that the formula would become “=SUM(B4:B4)”, which is not what you want I think. I think for your need you have to insert one extra blank row b/w your formula cell row and starting row and change your formula to “=SUM(B2:B3)”. Now process your code but you have to add one line of code i.e., designer.Workbook.Worksheets.Cells.DeleteBlankRows(); to your code for your needs.
See the updated sample code and try it with the updated template file (attached). You may just refer to it and adjust your other segments of your program or project accordingly for your needs.
static void Main(string args)
WorkbookDesigner designer = new WorkbookDesigner();
designer.Workbook = new Workbook(“Template1.xlsx”);
designer.Workbook.Worksheets.Cells.ImportDataTable(GetData(), false, “A2”);
private static DataTable GetData()
DataTable table = new DataTable();
table.Columns.Add(new DataColumn(“Code”, typeof(string)));
table.Columns.Add(new DataColumn(“Cost”, typeof(decimal)));
var r = table.NewRow();
r[“Code”] = “A”;
r[“Cost”] = 100;
r = table.NewRow();
r[“Code”] = “B”;
r[“Cost”] = 200;