hyperlink2.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 » hyperlink2.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: hyperlink2.py,v 1.3 2004/01/31 18:56:07 fufff Exp $"""

###############################################################################
#
# Example of how to use the WriteExcel module to write internal and internal
# hyperlinks.
#
# If you wish to run this program and follow the hyperlinks you should create
# the following directory structure:
#
# C:\ -- Temp --+-- Europe
#               |
#               \-- Asia
#
#
# See also hyperlink1.pl for web URL examples.
#
# reverse('(c)'), February 2002, John McNamara, jmcnamara@cpan.org
#


import pyXLWriter as xl

# Create three workbooks:
#   C:\Temp\Europe\Ireland.xls
#   C:\Temp\Europe\Italy.xls
#   C:\Temp\Asia\China.xls
#
ireland   = xl.Writer(r'C:\Temp\Europe\Ireland.xls')
ire_links = ireland.add_worksheet('Links')
ire_sales = ireland.add_worksheet('Sales')
ire_data  = ireland.add_worksheet('Product Data')

italy     = xl.Writer(r'C:\Temp\Europe\Italy.xls')
ita_links = italy.add_worksheet('Links')
ita_sales = italy.add_worksheet('Sales')
ita_data  = italy.add_worksheet('Product Data')

china     = xl.Writer(r'C:\Temp\Asia\China.xls')
cha_links = china.add_worksheet('Links')
cha_sales = china.add_worksheet('Sales')
cha_data  = china.add_worksheet('Product Data')

# Add a format
format = ireland.add_format(color='green', bold=1)
ire_links.set_column('A:B', 25)


###############################################################################
#
# Examples of internal links
#
ire_links.write('A1', 'Internal links', format)

# Internal link
ire_links.write('A2', 'internal:Sales!A2')

# Internal link to a range
ire_links.write('A3', 'internal:Sales!A3:D3')

# Internal link with an alternative string
ire_links.write_url('A4', 'internal:Sales!A4', 'Link')

# Internal link with a format
ire_links.write('A5', 'internal:Sales!A5', format)

# Internal link with an alternative string and format
ire_links.write_url('A6', 'internal:Sales!A6', 'Link', format)

# Internal link (spaces in worksheet name)
ire_links.write('A7', "internal:'Product Data'!A7")

###############################################################################
#
# Examples of external links
#
ire_links.write('B1', 'External links', format)

# External link to a local file
ire_links.write('B2', 'external:Italy.xls')

# External link to a local file with worksheet
ire_links.write('B3', 'external:Italy.xls#Sales!B3')

# External link to a local file with worksheet and alternative string
ire_links.write_url('B4', 'external:Italy.xls#Sales!B4', 'Link')

# External link to a local file with worksheet and format
ire_links.write('B5', 'external:Italy.xls#Sales!B5', format)

# External link to a remote file, absolute path
ire_links.write('B6', 'external:c:/Temp/Asia/China.xls')

# External link to a remote file, relative path
ire_links.write('B7', 'external:../Asia/China.xls')

# External link to a remote file with worksheet
ire_links.write('B8', 'external:c:/Temp/Asia/China.xls#Sales!B8')

# External link to a remote file with worksheet (with spaces in the name)
ire_links.write('B9', "external:c:/Temp/Asia/China.xls#'Product Data'!B9")

###############################################################################
#
# Some utility links to return to the main sheet
#
ire_sales.write_url('A2', 'internal:Links!A2', 'Back')
ire_sales.write_url('A3', 'internal:Links!A3', 'Back')
ire_sales.write_url('A4', 'internal:Links!A4', 'Back')
ire_sales.write_url('A5', 'internal:Links!A5', 'Back')
ire_sales.write_url('A6', 'internal:Links!A6', 'Back')
ire_data.write_url('A7', 'internal:Links!A7', 'Back')

ita_links.write_url('A1', 'external:Ireland.xls#Links!B2', 'Back')
ita_sales.write_url('B3', 'external:Ireland.xls#Links!B3', 'Back')
ita_sales.write_url('B4', 'external:Ireland.xls#Links!B4', 'Back')
ita_sales.write_url('B5', 'external:Ireland.xls#Links!B5', 'Back')
cha_links.write_url('A1', 'external:../Europe/Ireland.xls#Links!B6', 'Back')
cha_sales.write_url('B8', 'external:../Europe/Ireland.xls#Links!B8', 'Back')
cha_data.write_url('B9', 'external:../Europe/Ireland.xls#Links!B9', 'Back')

ireland.close()
italy.close()
china.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.