473,387 Members | 1,465 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,387 software developers and data experts.

PYTHON + EXCEL

I write my code :
#inizializzazioni varie che tralascio
#mi connetto al mio db mysql e recupero i dati che volgio inserire
nel file excel
conn = MySQLdb.connect(host = "XXX", port = XXX, user = "XXX",
passwd = "XXX", db= "XXX")
cursor = conn.cursor()
cursor.execute("SELECT * FROM XXX")
allFields = cursor.description
allRecords = cursor.fetchall()
cursor.close()
conn.close()
#inizializzo gli strumenti per lavorare in python con excel
xlApp = Dispatch("Excel.Application")
#xlApp.Visible = 1
xlApp.Workbooks.Add()
#specifico che file utilizzare
xlbook = xlApp.Workbooks.Open('C:/view.xls')
i = 1
j = 1
#popolo il mio file excel
for field in allFields :
xlApp.ActiveSheet.Cells(i, j).Value = field[0]
j = j + 1
for records in allRecords :
i = i + 1
j = 1
for item in records :
xlApp.ActiveSheet.Cells(i, j).Value = item
j = j + 1
#salvo le modifiche effettuate
xlbook.SaveAs('C:/view.xls')
#scrivo le istruzioni che mi permettereanno di aprirlo in una
pagina html
size = os.path.getsize('C:/view.xls')
of = open("C:/view.xls","rb")
content = of.read()
of.close()
print"Content-Type:application7vnd.ms-excel"
print"content-disposition:inline;filename=view.xls"
print"Content-length:%d \r\n"%size
print content



I want open an excel document in an apache page.
I want write in excel document the information of a database mySQL and
after open the excel documen in a broswer page
Where is the problem?
Sorry for my english but I'm not speak english very well, I write in
this group because I think that in this forum there are very very good
programmer

Nov 14 '06 #1
0 1242

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet...
12
by: rhmd | last post by:
Just found Python and I love it. What an elegant language! I would like to use it for various applications, but the mathematical calculations are way too slow (a million sines 8 seconds in Python...
0
by: justin worrall | last post by:
Hi,   I have a very simple python win32 example (gleaned from the O'Reilly book on Win32 programming for Python), of an Excel client with a COM server. Essentially I have three VB buttons -...
2
by: Kevin T. Ryan | last post by:
Hi Group - I have written a "semi-program" in MS Excel related to running a football pool. I've updated it over the past two years or so, to the point where it is getting pretty advanced. ...
3
by: Xiao-Qin Xia | last post by:
I don't like VBA, and want to use python to work with Excel. Does anybody recommend some good documents to begin with? Many thanks, Xiao-Qin
10
by: sam | last post by:
Hi group, I m wondering which Excel module is good to be used by Python? Thanks Sam
5
by: mbbx6spp | last post by:
Hi All, I already searched this newsgroup and google groups to see if I could find a Python equivalent to Perl's Template::Extract, but didn't find anything leading to a Python module that had...
6
by: ÒÊÃÉɽÈË | last post by:
i want to compare the content in excel,but i don't know whick module to use! can you help me?
4
by: michael.pearmain | last post by:
Hi Experts, Looking for a very quick bit on of advice on how to make some python code run. I'm a newbie to both VBA and Python, so i apologise if this is very easy but i'm about to tear my hair...
6
by: AleydisGP | last post by:
I have a .plt file (which is a tab delimited ASCII file) and I want to format it to get a .dbf with data in rows and columns, detele some rows/columns and substitute decimal '.' with ','. All this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...

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.