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

###############################################################################
#
# Example of formatting using the Spreadsheet::WriteExcel module
#
# This is a simple example of how to use functions that reference cells in
# other worksheets within the same workbook.
#
# reverse('(c)'), March 2001, John McNamara, jmcnamara@cpan.org
#

import pyXLWriter as xl

# Create a new workbook and add a worksheet
workbook = xl.Writer("stats_ext.xls")
worksheet1 = workbook.add_worksheet('Test results')
worksheet2 = workbook.add_worksheet('Data')

# Set the column width for columns 1
worksheet1.set_column('A:A', 20)


# Create a format for the headings
heading = workbook.add_format()
heading.set_bold()

# Create a numerical format
numformat = workbook.add_format()
numformat.set_num_format('0.00')

# Write some statistical functions
worksheet1.write('A1', 'Count', heading)
worksheet1.write('B1', '=COUNT(Data!B2:B9)')

worksheet1.write('A2', 'Sum', heading)
worksheet1.write('B2', '=SUM(Data!B2:B9)')

worksheet1.write('A3', 'Average', heading)
worksheet1.write('B3', '=AVERAGE(Data!B2:B9)')

worksheet1.write('A4', 'Min', heading)
worksheet1.write('B4', '=MIN(Data!B2:B9)')

worksheet1.write('A5', 'Max', heading)
worksheet1.write('B5', '=MAX(Data!B2:B9)')

worksheet1.write('A6', 'Standard Deviation', heading)
worksheet1.write('B6', '=STDEV(Data!B2:B9)')

worksheet1.write('A7', 'Kurtosis', heading)
worksheet1.write('B7', '=KURT(Data!B2:B9)')

# Write the sample data
worksheet2.write('A1', 'Sample', heading)
worksheet2.write('A2', 1)
worksheet2.write('A3', 2)
worksheet2.write('A4', 3)
worksheet2.write('A5', 4)
worksheet2.write('A6', 5)
worksheet2.write('A7', 6)
worksheet2.write('A8', 7)
worksheet2.write('A9', 8)

worksheet2.write('B1', 'Length', heading)
worksheet2.write('B2', 25.4, numformat)
worksheet2.write('B3', 25.4, numformat)
worksheet2.write('B4', 24.8, numformat)
worksheet2.write('B5', 25.0, numformat)
worksheet2.write('B6', 25.3, numformat)
worksheet2.write('B7', 24.9, numformat)
worksheet2.write('B8', 25.2, numformat)
worksheet2.write('B9', 24.8, numformat)

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.