Epplus add one value over a range

How can I add one text value of a range of cells? Currently, I have the following code snippet:

ExcelRange oRngheader1 = oSheet.Cells["A2:B2"];
oSheet.Cells["A2:B2"].Value= "Division Budgets";

Which places the value 'Division Budgets' in both cell A2 and Cell B2; however, I wish this value to span both A2 to B2.

1 answer

  • answered 2018-03-13 20:19 John Tesmer

    ExcelRange oRngheader1 = oSheet.Cells["A2:B2"];
    oSheet.Cells["A2"].Value= "Division Budgets";
    oRngheader1.Merge = true;

    It's important to put the value in the top-left-most cell to ensure that it's not lost when you merge.