headers.py :  » XML » pyXLWriter » pyXLWriter-0.4a3 » examples » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » XML » pyXLWriter 
pyXLWriter » pyXLWriter 0.4a3 » examples » headers.py
#!/usr/bin/env python
# This example script was ported from Perl Spreadsheet::WriteExcel module.
# The author of the Spreadsheet::WriteExcel module is John McNamara
# <jmcnamara@cpan.org>

__revision__ = """$Id: headers.py,v 1.1 2004/01/31 18:57:53 fufff Exp $"""

######################################################################
#
# This program shows several examples of how to set up headers and
# footers with Spreadsheet::WriteExcel.
#
# The control characters used in the header/footer strings are:
#
#   Control             Category            Description
#   =======             ========            ===========
#   &L                  Justification       Left
#   &C                                      Center
#   &R                                      Right
#
#   &P                  Information         Page number
#   &N                                      Total number of pages
#   &D                                      Date
#   &T                                      Time
#   &F                                      File name
#   &A                                      Worksheet name
#
#   &fontsize           Font                Font size
#   &"font,style"                           Font name and style
#   &U                                      Single underline
#   &E                                      Double underline
#   &S                                      Strikethrough
#   &X                                      Superscript
#   &Y                                      Subscript
#
#   &&                  Miscellaneous       Literal ampersand &
#
#
# reverse('(c)'), March 2002, John McNamara, jmcnamara@cpan.org
#

import pyXLWriter as xl

workbook = xl.Writer("headers.xls")
preview = "Select Print Preview to see the header and footer"

######################################################################
#
# A simple example to start
#
worksheet1 = workbook.add_worksheet('Simple')

header1 = '&CHere is some centred text.'

footer1 = '&LHere is some left aligned text.'

worksheet1.set_header(header1)
worksheet1.set_footer(footer1)

worksheet1.set_column('A:A', 50)
worksheet1.write('A1', preview)

######################################################################
#
# This is an example of some of the header/footer variables.
#
worksheet2 = workbook.add_worksheet('Variables')

header2 = '&LPage &P of &N' + \
          '&CFilename: &F'  + \
          '&RSheetname: &A'

footer2 = '&LCurrent date: &D' + \
              '&RCurrent time: &T'

worksheet2.set_header(header2)
worksheet2.set_footer(footer2)

worksheet2.set_column('A:A', 50)
worksheet2.write('A1', preview)
worksheet2.write('A21', "Next sheet")
worksheet2.set_h_pagebreaks(20)

######################################################################
#
# This example shows how to use more than one font
#
worksheet3 = workbook.add_worksheet('Mixed fonts')

header3 = '&C' + \
          '&"Courier New,Bold"Hello ' + \
          '&"Arial,Italic"World'

footer3 = '&C' + \
          '&"Symbol"e' + \
          '&"Arial" = mc&X2'

worksheet3.set_header(header3)
worksheet3.set_footer(footer3)

worksheet3.set_column('A:A', 50)
worksheet3.write('A1', preview)

######################################################################
#
# Example of line wrapping
#
worksheet4 = workbook.add_worksheet('Word wrap')

header4 = "&CHeading 1\nHeading 2\nHeading 3"

worksheet4.set_header(header4)

worksheet4.set_column('A:A', 50)
worksheet4.write('A1', preview)

######################################################################
#
# Example of inserting a literal ampersand &
#
worksheet5 = workbook.add_worksheet('Ampersand')

header5 = "&CCuriouser && Curiouser - Attorneys at Law"

worksheet5.set_header(header5)

worksheet5.set_column('A:A', 50)
worksheet5.write('A1', preview)

workbook.close()
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.