How do I set the first cell of the first row to span all columns?

May 13, 2010 at 9:21 PM
I have a spreadsheet called Balance Sheet. I want the first row of the worksheet to say "Balance Sheet" and have it centered on the screen/page. How do I do this?
May 14, 2010 at 1:10 AM
Edited May 14, 2010 at 4:54 AM
I am not sure how to get the number of columns on the page, but if you know the number of columns you can do this:

ExcelRange range = worksheet.Cells[1, 1, 1, 10]; //starting row, starting column, ending row, ending column
range.Merge = true;
range.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
range.Value = "Balance Sheet";

This may not be what you're looking for but maybe it will help a little.
May 14, 2010 at 2:01 PM
Since I already know the number of columns this is exactly what I need! Thank you!
Dec 18, 2011 at 7:20 AM

merci cdc5205