File: WriteSharedFormula.py

package info (click to toggle)
libqt5qxlsx 1.4.4-1.1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 15,304 kB
  • sloc: cpp: 17,870; ansic: 4,644; python: 15; makefile: 4
file content (26 lines) | stat: -rw-r--r-- 658 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python

# WriteSharedFormula.py

# Installation: pip install XlsXcessive
# https://pypi.org/project/XlsXcessive/

import io

from xlsxcessive import xlsx
from xlsxcessive.worksheet import Cell

def main():
	workbook = xlsx.Workbook()
	sheet1 = workbook.new_sheet('Sheet 1')
	sheet1.cell('B1', value=7)
	sheet1.cell('C1', value=8)
	sheet1.cell('D1', value=9)
	formula = sheet1.formula('B1 + C1', shared=True)
	sheet1.cell('D2', formula) # master
	sheet1.cell('E2', formula) # shared, references the master formula	
	xlsx.save(workbook, 'test.xlsx') # save local file

if __name__ == "__main__":
    # execute only if run as a script
    main()