How to get the Excel header on each print page to be the first row of the table
I need the first row in an Excel spreadsheet to print as the header on all pages.
Solution 1:
Go to file->Page Setup and choose the sheet tab. There is an option 'rows to repeat at top'.
Solution 2:
Here is a step by step description of how to add header rows.
- Start by selecting the page layout tab and then open the Page Layout dialog box.
- On the Sheet tab of the Page Setup dialog box, click on the rows to repeat at top.
- Clicking on the row you want to appear at the top of each page will populate the Page Setup – Rows to repeat at top dialog box. When done return to the Page Setup dialog box by hitting the enter key.
- Select the OK button to complete the setup.
- Now whenever you print preview or print your worksheet, the row you selected will be repeated at the top of each page.
Solution 3:
also programatically (at least in c#) it's to the effect of:
[excel sheet].PageSetup.PrintTitleRows = "$[firstrow]$[lastrow]";
I would expect other languages to handle it similarly though, being that it's a com interface.
Solution 4:
The problem is the missing colon(:) between rows to repeat at top. You can even try this by viewing it as you set it manually within Excel(any version)
Excel.Application xlApp ;
Excel.Workbook xlWorkBook ;
Excel.Worksheet xlWorkSheet ;
object misValue = System.Reflection.Missing.Value;
xlApp = new Excel.Application(); //Start Excel and get Application object.
xlApp.Visible = true;
xlWorkBook = (Excel.Workbook)(xlApp.Workbooks.Add(misValue));
xlWorkSheet = (Excel.Worksheet)xlWorkBook.ActiveSheet;
xlWorkSheet.PageSetup.PrintTitleRows = "$1:$1"; // Rows to repeat at top of Excel Page Setup
xlWorkSheet.PageSetup.PrintTitleColumns = "$A:$B"; // Columns to repeat at left of Excel Page Setup