473,406 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Copying values from one spreadsheet to another

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
Feb 21 '09 #1
1 6855
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('Excel.Application')
xlBook = xlApp.Workbooks.Open("file.xls")

sheet1 = xlBook.Worksheets["sheet 1"]
sheet2 = xlBook.Worksheets["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(index,col).Value = sheet1.Cells(index,col).Value

xlBook.Save(SaveChanges=0) #save the file
del xlApp #kill the excel application

#####################################

...hope this helps
Mar 2 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Andy | last post by:
Hi! Is possible to do xml validation of one xml block based on values from another xml block? For example, I have an input xml file containing account types. <Root> <AccountTypes>...
5
by: Nathan Sokalski | last post by:
I am writing an ASP.NET application in which I need to copy DataRows from one DataTable to another. When I use code such as the following: temprows = nodes.Select("state='PA'")...
6
by: psbasha | last post by:
Hi, I am assigning the list/dict values to another list/dict variable as shown below. List : List1 = List2 = List1
0
by: menyki | last post by:
Below is a little code i wrote to display values on another form called recordForm. The code is writen on a form called regForm.pls can somebody help tell me what to do cos is not running. ...
1
by: zoeb | last post by:
Currently I have a table, and would like the calculate a field in the table by referencing values from another 3 tables. i.e. tblData Index1, Index2, Index3, Value 1 2 3 2...
5
by: mruedy | last post by:
I would like to know if it is possible to write an XML Schema restriction that binds to values of another element. For example I have XML <people> <family name="Smith"> ...
0
by: LSGKelly | last post by:
I have a spreadsheet that has an employee name and a date range, beginning date, ending date. Within that spreadsheet, I have the columns Monday - Friday. I need to pull data into the Monday -...
7
by: Andy Sears | last post by:
I am trying to SUM values in a column where values in another column are the same. Here is what I need, but I know the 5th line won't work: UPDATE manufacturing_detail SET item_lead_time_1 = ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.