How to Insert an Excel File Name or Path in a Header
Question details
The user needs to display the workbook's file name or complete file path in the header of an Excel spreadsheet without manually typing it or using spreadsheet functions like CELL.

- Product
- Excel / WPS Spreadsheet
- Device & OS
- not provided
- Scenario
- Preparing a spreadsheet for printing or professional distribution where identifying the file's location or name on the physical page is required.
- Observed behavior
- The goal is to automatically display the correct file name or path in the document header so it updates dynamically.
Ensure that your workbook has been saved to your local device or cloud storage at least once; otherwise, the file name or path header element will not display correctly.
Insert File Name or Path via Header & Footer Elements
Use the built-in Header & Footer tab to automatically insert the file name or complete file path code into your Excel document.
Excel provides built-in header and footer elements that dynamically pull the file's metadata. This method is much easier than using complex formulas and ensures the file path updates automatically if you move the file.
Navigate to the 'Insert' tab on the top ribbon and click on 'Header & Footer'. This will change your worksheet view to Page Layout mode and activate the Header & Footer tools.
Click inside the left, center, or right section of the header area where you want the file name or path to appear.
On the newly appeared 'Header & Footer' tab, locate the 'Header & Footer Elements' group. Click on 'File Name' to insert the &[File] code, or click 'File Path' to insert the &[Path]&[File] code.
Click anywhere outside the header area in your worksheet. The code will disappear, and you will see the actual file name or path displayed.

Easily Add Headers and Footers with WPS Spreadsheet
WPS Office offers an intuitive interface for managing spreadsheet headers and footers. You can quickly insert file paths, file names, page numbers, and dates into your printed documents with just a few clicks.
- 1. Open WPS Spreadsheet: Launch WPS Office and open your existing spreadsheet or create a new one.
- 2. Go to the Insert Tab: Click on 'Insert' in the top menu ribbon, then select 'Header and Footer'.
- 3. Add File Information: In the Header and Footer design tab, click 'File Name' or 'File Path' to automatically insert the corresponding details into the chosen section.
- 4. Save and Print: Save your document to ensure the path is accurate, and view the final result in Print Preview mode.

Frequently Asked Questions
Why is my file path showing up as blank in the header?
If the file path or name appears blank or just shows the code (like &[Path]), it usually means the workbook has not been saved yet. Save the document to your computer or cloud drive, and the header will automatically update to show the correct path.
Can I format the text of the file name in the header?
Yes. Once you insert the file name code, you can highlight the text and use the standard font formatting options (like bold, italic, or changing the font size) found on the Home tab.
How do I remove the file name or path from the header?
To remove it, simply click into the header section containing the file name or path, highlight the text or code (e.g., &[File]), and press the Delete or Backspace key on your keyboard.
Is it possible to show both the sheet name and the file name?
Absolutely. You can click on 'File Name' and then click on 'Sheet Name' in the Header & Footer Elements group. This will insert both codes (e.g., &[File] &[Tab]), displaying both pieces of information together.




