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

May 13, 2010 at 8: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 12:10 AM
Edited May 14, 2010 at 3: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 1:01 PM
Since I already know the number of columns this is exactly what I need! Thank you!
Dec 18, 2011 at 6:20 AM

merci cdc5205