Skip to main content

Process .docx, .xlsx, .pptx, .pdf files for office automation

Project description

office module 0.2.0 documentation

Author: JoStudio, Date: 2022/9/1

office Module

Process .docx, .xlsx, .pptx, .pdf files for office automation

office.excel submodule

Excel : process the data in .xlsx file

Example:

import office



# open file datafile.xlsx, return workbook object

workbook = office.open_file("datafile.xlsx")



# list worksheets

sheet_names = workbook.sheetnames

print(sheet_names)



# get a sheet

sheet = workbook['Sales']

print(sheet.name)



# get a cell

cell = sheet['B2']

print(cell.value)



# write a cell

cell.value = 'New City'



# save

workbook.save("newfile.xlsx")



# close

workbook.close()

office.ppt submodule

PPT : auto creation of the .pptx file

Example:

import office



# create file output.pptx using template1.pptx

ppt = office.open_file("output.pptx", template="template1.pptx")



# create ppt content by fill the data from Excel file datafile.xlsx, and save.

ppt.fill('datafile.xlsx').save()



# save pptx to pdf with watermark (works on Windows with Microsoft PowerPoint)

ppt.save('final.pdf', watermark="CONFIDENTIAL")



# save pptx slides into a long image, with watermark (works on Windows with Microsoft PowerPoint)

ppt.save('long.jpg', watermark="CONFIDENTIAL")



# play ppt (works on Windows with Microsoft PowerPoint)

ppt.play()

office.word submodule

Word : auto creation of the .docx file

Example:

import office



# create file output.docx using template1.docx

doc = office.open_file("output.docx", template="template1.docx")



# create document content by fill the data from Excel file datafile.xlsx, and save.

doc.fill('datafile.xlsx').save()



# save to pdf with watermark (works on Windows with Microsoft PowerPoint)

doc.save('final.pdf', watermark="CONFIDENTIAL")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jojo-office-0.2.2.tar.gz (102.6 kB view details)

Uploaded Source

File details

Details for the file jojo-office-0.2.2.tar.gz.

File metadata

  • Download URL: jojo-office-0.2.2.tar.gz
  • Upload date:
  • Size: 102.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.0

File hashes

Hashes for jojo-office-0.2.2.tar.gz
Algorithm Hash digest
SHA256 e35a32efb1c6cd14294ca8ce7cd95082bc6eadfbe6f3fc825cd474fdd14644b0
MD5 7367c08e19c32462f93927e31b12aa3a
BLAKE2b-256 936bb3ed387fad783f460d164b80a54c115457e78d9fcac490b511e7cad6d088

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page