Python Forum

Full Version: Excel Help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am REALLY new to python. I have used it to open some web pages and used eventghost to take it from there. I have an Excel workbook that has sheets in it named for months of the year. I need to write script that will extract this month and last months sheet and email it to several people automatically. I am fine with changing the sheet names manually if need be, or even finding a way to email the file without python if need be, but can I save a file with only the sheets I need? (example: now it is August, can I save sheets July and August to a file on my laptop?)
This package (only read excel, no write) is probably the easiest to use
if you only have to do simple extractions: https://pypi.python.org/pypi/excel/1.0.0

As far as email is concerned, the builtin package: https://docs.python.org/3/library/email.html
will not handle SMTP or NNTP but is fine for MIME.
OK you are talking to a complete novice here so forgive my ignorance. but your examples seem to be reading specific rows and columns and not sheet names. plus I don't see a save command. like I said I am really new to this. so could you spell it out to me, or maybe even validate my question. lol
I didn't provide any examples only references to packages that you might use.
These packages typically have methods to do sheet extraction.
You will need to read the documentation
(Aug-03-2017, 01:30 AM)Gbry71 Wrote: [ -> ]I am REALLY new to python. I have used it to open some web pages and used eventghost to take it from there. I have an Excel workbook that has sheets in it named for months of the year. I need to write script that will extract this month and last months sheet and email it to several people automatically. I am fine with changing the sheet names manually if need be, or even finding a way to email the file without python if need be, but can I save a file with only the sheets I need? (example: now it is August, can I save sheets July and August to a file on my laptop?)

I use the xlxswriter module for all my excel work in python http://xlsxwriter.readthedocs.io/

Admittedly I have only used it to create spreadsheets with my data. It is easy to use and the documentation is well done. Like you I'm new to python only been using for 4 weeks.

For emailing your newly created spreadsheet I use the module smtplib https://docs.python.org/3/library/smtplib.html
The xlxswriter  module is fine for 'writing' hence the name, but cannot read excel.