PyOpenXMLCalc

peckto

A python library to create OpenXML spreadsheets, so that Microsoft Excel, or every other program that supports this format (e.g. LibreOffice, Openoffice) can open a file created with this library.

Implemented features:

Requirements:

Example

create a new sheet

from PyOpenXMLCalc import *

workbook = Calc('Company','userName')
workbook.newSheet('Test')
workbook.selectSheet('Test')

import a list

l = list()
l.append(['A','B','C','D','E'])
for i in range(10):
    l.append(['A','OK' if i%2 else 'NOK','C','D','E'])
workbook.import_list('A1',l)

create a formated table

ref = workbook.formatTable('A1','Table1',tableStyle='TableStyleMedium16')

define some colors

rgb_read = "FFFF0000"
rgb_green = "FF00B050"
rgb_orange = {'theme':'9'}
rgb_grey = {'theme':"1",'tint':"0.499984740745262"}
dxfId = workbook.getStyle(rgb_green)

conditional formating

workbook.add_conForm_beginWith(Sqref('A2:A%s'%ref.end.rowID),dxfId,4,'A')
format_ = 'B2="OK"'
workbook.add_conForm_expression(Sqref('B2:B%s'%ref.end.rowID),dxfId,format_,4)
workbook.add_frozen_row(1)

save to file

workbook.selectCell('B2')
workbook.save('Sample.xlsx')
excel screenshot
excel screenshot

For further examples please have a look at sample.py and sample-2.py