Create excel from template

Excel for Microsoft 365 Excel 2021 Excel 2019 Excel 2016 Excel 2013 Excel 2010 Excel 2007 More…Less

If you often use the same layout or data in a workbook, save it as a template so you can use the template to create more workbooks instead of starting from scratch.

You can use one of your own templates to create a new workbook, or you can use one of the many predefined templates that you can download from Microsoft Office Online.

Save a workbook as a template

  1. If you’re saving a workbook to a template for the first time, start by setting the default personal templates location:

    1. Click File > Options.

    2. Click Save, and then under Save workbooks, enter the path to the personal templates location in the Default personal templates location box.

      This path is typically: C:Users[UserName]DocumentsCustom Office Templates.

      Options you can set for saving workbooks

    3. Click OK.

      Once this option is set, all custom templates you save to the My Templates folder automatically appear under Personal on the New page (File > New).

  2. Open the workbook you want to use as a template.

  3. Click File > Export.

  4. Under Export, click Change File Type.

  5. In the Workbook File Types box, double-click Template.

  6. In the File name box, type the name you want to use for the template.

  7. Click Save, and then close the template.

Create a workbook based on the template

With the template you created above, you can create a new workbook. This section tells you how to do that.

Note: Alternately, you can browse for various online templates in Excel and use them instead. For more information, see Download free, pre-built templates.

  1. Click File > New.

  2. Click Personal.

    Personal templates location

  3. Double-click the template you just created.

    Excel creates a new workbook that is based on your template.

Save a workbook as a template

  1. Open the workbook that you want to use as a template.

  2. Click File, and then click Save As.

  3. In the File name box, type the name that you want to use for the template.

  4. In the Save as type box, click Excel Template, or click Excel Macro-Enabled Template if the workbook contains macros that you want to make available in the template.

  5. Click Save.

    The template is automatically placed in the Templates folder to ensure that it will be available when you want to use it to create a new workbook.

Tip: You can copy any Excel workbook into the Templates folder, then you can use the workbook as a template without saving it in the template file format (.xltx or .xltm). In Windows Vista, the Templates folder is usually C:Users<your name>AppDataRoamingMicrosoftTemplates. In Microsoft Windows XP, the Templates folder is usually C:Documents and Settings<your name>Application DataMicrosoftTemplates.

Use a template to create a new workbook

  1. Click File and then click New.

  2. Under Available Templates, do one of the following:

    • To base the workbook on a recently used template, click Recent Templates, and then double-click the template that you want to use.

    • To base the workbook on an installed template, click Sample templates and then double-click the template that you want to use.

    • To base the workbook on a template that you created, click My templates, and then on the Personal Templates tab, double-click the template that you want to use.

    • To base the workbook on another workbook, click New from Existing, and then double-click the workbook that you want to use.

Tip: When you are connected to the Internet, you can also access templates that are available from Office.com. Under Office.Com Templates, click a template category, and then under that category, double-click the template that you want to download. If the template that you want to download has been supplied by a member of the Microsoft Office.com Community, you must click I accept to accept the License Agreement for Community Templates Terms of Use before you can download that template.

Save a workbook as a template

  1. Open the workbook that you want to use as a template.

  2. Click the Microsoft Office Button Office button image, and then click Save As.

  3. In the File name box, type the name that you want to use for the template.

  4. In the Save as type box, click Excel Template, or click Excel Macro-Enabled Template if the workbook contains macros that you want to make available in the template.

  5. Click Save.

    The template is automatically placed in the Templates folder to ensure that it will be available when you want to use it to create a new workbook.

Tip: You can copy any Excel workbook into the Templates folder, then you can use the workbook as a template without saving it in the template file format (.xltx or .xltm). In Windows Vista, the Templates folder is usually C:Users<your name>AppDataRoamingMicrosoftTemplates. In Microsoft Windows XP, the Templates folder is usually C:Documents and Settings<your name>Application DataMicrosoftTemplates.

Use a template to create a new workbook

  1. Click the Microsoft Office Button Office button image, and then click New.

  2. Under Templates, do one of the following:

    • To base the workbook on a recently used template, click Blank and recent, and then under Recently Used Templates, double-click the template that you want to use.

    • To base the workbook on an installed template, click Installed Templates, and then under Installed Templates, double-click the template that you want to use.

    • To base the workbook on a template that you created, click My templates, and then on the My Templates tab, double-click the template that you want to use.

    • To base the workbook on another workbook, click New from Existing, and then double-click the workbook that you want to use.

Tip: When you are connected to the Internet, you can also access templates that are available from Office Online. Under Microsoft Office Online, click a template category, and then under that category, double-click the template that you want to download. If the template that you want to download has been supplied by a member of the Microsoft Office Online Community, you must click I accept to accept the License Agreement for Community Templates Terms of Use before you can download that template.

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Existing Templates | Create a Template

Instead of creating an Excel workbook from scratch, you can create a workbook based on a template. There are many free templates available, waiting to be used.

Existing Templates

To create a workbook based on an existing template, execute the following steps.

1. On the File tab, click New.

2. Use the search box to search for online templates or click a template from one of the Office templates.

Office Templates

3. Click Create to download the template.

Create a Template

Excel creates the workbook Home inventory1.xlsx based on this template.

Create a Template

If you create your own template, you can safely store it in the Templates folder. As a result, you can create new workbooks based on this template without worrying that you overwrite the original file.

To create a template, execute the following steps.

1. Create a workbook.

2. On the File tab, click Save As.

3. Click Browse.

Click Browse

4. Enter a file name.

5. Select Excel Template (*.xltx) from the drop-down list.

Save As Template

Excel automatically activates the Templates folder. Notice the location of the Templates folder on your computer. It’s usually located here:

C:Users<username>DocumentsCustom Office Templates

6. Click Save.

Templates Folder

To create a workbook based on this template, execute the following steps.

7. On the File tab, click New.

8. Click Personal.

9. Click WeddingBudget.

Click WeddingBudget

Excel creates the workbook WeddingBudget1.xlsx based on this template.

Note: to edit a template, on the File tab, click Open and then click Browse, to open the template. Edit the file and save the file to its original location.

Wednesday, December 3, 2008
Peltier Technical Services, Inc., Copyright © 2023, All rights reserved.
 

Excel templates are a useful way to reuse structure, content, and formatting among many different projects. You can save your own workbooks as custom templates, or use templates from other sources. You can use a template in two ways. You can create a new file based on the template, and you can insert sheets from a template into an existing workbook.

Creating Excel Templates

Creating a template is straightforward. When you have a workbook (one or more sheets) configured the way you want it, simply use Save As, and under Save As Type, select Template (*.xlt). If you are using Excel 2007, you have two template options: Excel Template (*.xltx) and Excel Macro-Enabled Template (*.xltm). If your template contains any VBA that you want to use when the template is used later in a workbook, be sure to select the macro-enabled option.

By default, Excel saves the template in the Template directory, which in Windows XP and Office 2003 is:

C:Documents and SettingsusernameApplication DataMicrosoftTemplates
 

This directory contains Excel templates, as well as Word and PowerPoint templates.

Creating a New Workbook from an Excel Template

There are at least three ways to create a new file based on a template. In all of these techniques, the result is a new file that opens in Excel. This file is exactly like the template, except instead of having the template’s file name (“MyTemplate.xlt”), it is unsaved but has a default name based on the template’s name (“MyTemplate1”). All sheets and code from the original template are at your disposal in the new workbook.

1. You can double click on an Excel template in Windows Explorer, and the new file will open in Excel.

2. You can create a new file in Excel using File menu > New (or in Excel 2007, Office menu > New), using the option to create a new workbook based on an existing workbook. A File Open dialog opens in the Templates directory (see above) where your templates are saved. You can browse anywhere to find your template. You can use a regular workbook as well as an official template ass the basis for your new file.

3. You can create a new file from a template, and Excel 2003 gives you the option to search for a template, use a template from Office Online or from your computer, or select from a list of recently used templates. If you choose the Office Online option, the Template Categories page from Office Online opens in your default browser. If you choose the Templates on this Computer option, a Templates dialog appears with tabs for different directories, opened at first to the Templates directory. Subdirectories of Templates appear on the other tabs. You are limited to the directories available on the tabs.

Inserting New Sheets from an Excel Template

You can insert sheets from a template into the active workbook by right clicking on a sheet tab and choosing Insert. The same Templates dialog as in option 3 above will appear so you can select a template. All sheets from the selected template are inserted in front of the active sheet. Any code contained in the code modules associated with these sheets is copied with the sheets, but workbook or project level code is not transferred into the parent workbook.

Sample Uses for Excel Templates

There are many ways that templates make your spreadsheet life easier. Rather than reconstructing the data range and charts in a workbook, you can save the original workbook as a template, use the template to create a new workbook, and enter new data into the new workbook.

If you create regular reports or analyses, you can create an array of templates, one for each section your analysis or report may contain. As you populate your report, you can add the sheets you need from the available templates, and ignore the sheets you don’t need.

You could use a template to insert boilerplate (copyright notices, contact information, cover pages, etc.) into workbooks.

Often, people use a template to carry out an analysis quickly and easily. Finding an existing template is easier and more reliable than trying to construct a page full of formulas by hand. There are many templates available on the internet.

Sources of Excel Templates

Microsoft hosts a large number of templates on their Office Online Templates pages. A number of other sites have templates available for download.

The Vertex42.com web site hosts a number of nicely made Excel Templates. For example, the Amortization Chart template has a simple data entry area where you can input amount of a loan, the interest rate, and the number of periods over which the loan will be repaid. A table below the input region is populated with data, and a pair of charts show the status of the loan over time.

loan amortization chart       loan payment chart

This example shows how a relatively simple template can be an elegant way to carry out an analysis with a minimum of difficulty.

I am creating a excel sheet from tempalte excel sheet.

I have a code

try
{
    FileInfo newFile = new FileInfo(@"D:ExcelFromTemplate.xlsx");
    FileInfo template = new FileInfo(@"D:template.xlsx");

    using (ExcelPackage xlPackage = new ExcelPackage(newFile, template))
    {
        
        ExcelWorksheet worksheet = xlPackage.Workbook.Worksheets["Sheet1"];
        
        ExcelCell cell = worksheet.Cell(5,1);
        cell.Value = "15";
        
        //worksheet.Cell(5, 1).Value = "Soap";

        //xlPackage.Save();
        Response.Write("Excel file created successfully");
    }

}
catch (Exception ex)
{
    Response.WriteFile(ex.InnerException.ToString());
}  

this code creates the new excel file same as the template excel file but could not add the cell value. Why?

I had tried it with 2 ways as in above code for cell(5,1). But the excel sheet creates without writting cell value. How we can add it.

Ruben Bartelink's user avatar

asked Oct 27, 2009 at 5:18

Girish's user avatar

3

You need to save the file to persist the changes made. Using save()

  try
        {
            FileInfo newFile = new FileInfo(@"D:ExcelFromTemplate.xlsx");
            FileInfo template = new FileInfo(@"C:Example.xlsx");

            using (ExcelPackage xlPackage = new ExcelPackage(newFile , template))
            {

               //Added This part
               foreach (ExcelWorksheet aworksheet in xlPackage.Workbook.Worksheets)
                {
                    aworksheet.Cell(1, 1).Value = aworksheet.Cell(1, 1).Value;
                }

                ExcelWorksheet worksheet = xlPackage.Workbook.Worksheets["My Data"];

                ExcelCell cell = worksheet.Cell(5, 1);
                cell.Value = "15";

                //worksheet.Cell(5, 1).Value = "Soap";

                xlPackage.Save( );
                //Response.Write("Excel file created successfully");
            }

        }
        catch (Exception ex)
        {
            //Response.WriteFile(ex.InnerException.ToString());
        }

Got the issue. The problem is inherent to ExcelPackage.
For the same you have to open each sheet and do some changes for it to get saved.

Search the forum for more explanation.

JohnFx's user avatar

JohnFx

34.5k18 gold badges104 silver badges162 bronze badges

answered Oct 27, 2009 at 6:21

Sachin Chavan's user avatar

Sachin ChavanSachin Chavan

5,5485 gold badges49 silver badges75 bronze badges

2

Понравилась статья? Поделить с друзьями:
  • Create excel from php
  • Create excel files with python
  • Create excel file xml
  • Create excel file with python
  • Create excel file from python