Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in Python only
Search
Advanced Search
Forums
Product Launch
Updates
Today's Posts
Member List
Calendar
Home
Forum
Topic
Python
Copying values from one spreadsheet to another
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
alagalah
New Member
Join Date:
Feb 2009
Posts:
3
#1
Copying values from one spreadsheet to another
Feb 21 '09, 11:41 PM
Does anyone have an example of reading an Excel spreadsheet and iteratively copying the VALUES from each of the cells in each of the sheets over to a new spreadsheet?
TIA
MojaveKid
New Member
Join Date:
Sep 2007
Posts:
9
#2
Mar 2 '09, 08:00 AM
python and excel...uhum
first thing to do:
install the win32 extension for python (just search sourceforge for this)
now assume we have an excel file (file.xls) with 2 sheets : "sheet 1", "sheet 2"
############### ############### #######
import win32com.client
xlApp = win32com.client .Dispatch('Exce l.Application')
xlBook = xlApp.Workbooks .Open("file.xls ")
sheet1 = xlBook.Workshee ts["sheet 1"]
sheet2 = xlBook.Workshee ts["sheet 2"]
# assume we are going to copy the first 200 rows of column 1
rows = 200
col = 1
index = 1
while index <= rows:
sheet2.Cells(in dex,col).Value = sheet1.Cells(in dex,col).Value
xlBook.Save(Sav eChanges=0) #save the file
del xlApp #kill the excel application
############### ############### #######
...hope this helps
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment