Windows Develop Bookmark and Share   
 index > Windows Forms General > create excel using templates
 

create excel using templates


I am trying to create an excel file from a template file ( using the template to create
excel headers and footers to appear on each page).

the SAVEAS runs and creates the new file without the header and footer info.
How can I take the template with this info and carry it into the new excel file.

I am using Microsoft PIA excel library: - the biggest problem I have is getting  the headers 
and footers (ie: on footer -page number to appear on all pages), etc

bev


  oXL = CreateObject("Excel.Application")
        oWB = oXL.Workbooks.Open("c:\uaf_letters\openuaftemplate.XLT", 0, True, 5, "", "", True, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", True, False, 0, True)
        'Get the data from the dataset (or database) and put it on the template
        oWB = oXL.Workbooks.Add

        oSheet = oWB.ActiveSheet
        For Each dr In dt.Rows
            oSheet.Cells(rowcounter, 1) = dr.Item("territory_id")
            rowcounter = rowcounter + 1
        Next


        'Save the spreadsheet as a report
        oXL.ActiveWorkbook.SaveAs("c:\uaf_letters\openuaf", Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, Type.Missing, Type.Missing, _
Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, _
Type.Missing, Type.Missing, Type.Missing, Type.Missing)


MigrationUser 1  Tuesday, May 17, 2005 10:18 AM
You can set the headers and footers with ActiveSheet.PageSetup. For example, to display the page number on the center footer, write:
oWB.ActiveSheet.PageSetup.CenterFooter = "Page &P"  <i>or</i>  = "Page &P of &N"
MigrationUser 1  Tuesday, May 17, 2005 12:16 PM

You can use google to search for other answers

Custom Search

More Threads

• Logging into MDI Application
• Change Text of TreeNode like in Visual Studio .NET
• help needed urgent
• Cannot save image after load in C# 2008
• mciSendString API
• How to have no image for some nodes in a TreeView with an ImageList?
• Selecting a value in a datagrid using datagridbuttoncolumn
• Localization
• Rendering a form into an image
• Embedded VB 3.0 and the iPaq H1940