Hello all,
please, let me apologize in advance. English is not my first language
(not even my second one), so excuse any errors with which I'm about to
embarass myself in front of the general public. Second, I'm relatively
new to python, so sorry if this seems like a stupid question.
I'm trying to find a way to write data to excel cells (or to be more
specific to an .xls file), let's say for the sake of argument, data
readen from a file (although it will be calculated in the process).
I've been searching, but couldn't find any examples which allows that.
Do anyone knows of any ? All help is appreciated on this matter.
Tutorials? Anything ...
Best regards
Marin 20 3581
I'm trying to find a way to write data to excel cells (or to be more
specific to an .xls file), let's say for the sake of argument, data
readen from a file (although it will be calculated in the process).
I've been searching, but couldn't find any examples which allows that.
The answer will depend on your base os.. if you are on windows there
will be some options using the COM interfaces I bet.. but I don't know
anything about them.
If you are on a unix based os, your choices are limited. If you can,
I would just write to a csv file and open it with Excel. If you have
to interface with an exsisting excel file, you can try http://pypi.python.org/pypi/xlrd , but it may not support writing xls
files, still.
On Sat, Aug 30, 2008 at 4:41 PM, Marin Brkic <mbrkic@invalid _mail.adresswro te:
Hello all,
>
I'm trying to find a way to write data to excel cells (or to be more
specific to an .xls file), let's say for the sake of argument, data
readen from a file (although it will be calculated in the process).
I've been searching, but couldn't find any examples which allows that.
Is it suitable for you to use a python program talking with a running
instance of openoffice? in that case, pyuno could help you.
--
Marco Bizzarri http://notenotturne.blogspot.com/ http://iliveinpisa.blogspot.com/
Marin Brkic wrote:
Hello all,
please, let me apologize in advance. English is not my first language
(not even my second one), so excuse any errors with which I'm about to
embarass myself in front of the general public. Second, I'm relatively
new to python, so sorry if this seems like a stupid question.
I'm trying to find a way to write data to excel cells (or to be more
specific to an .xls file), let's say for the sake of argument, data
readen from a file (although it will be calculated in the process).
I've been searching, but couldn't find any examples which allows that.
Do anyone knows of any ? All help is appreciated on this matter.
Tutorials? Anything ...
Best regards
Marin
Not specific to python, but if you have a recent version of excel, you
could write to the Excel xml format (if not, you could consider
the (or one of the) gnumeric xml formats.
The Excel format is verbose, but you can copy and paste most of it.
The critical bit you need your software to write looks
something like this:
<Worksheet ss:Name="Sheet1 ">
<Table ss:ExpandedColu mnCount="2" ss:ExpandedRowC ount="5"
x:FullColumns=" 1"
x:FullRows="1">
<Row>
<Cell><Data ss:Type="String ">number</Data></Cell>
<Cell><Data ss:Type="String ">square</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="Number ">1</Data></Cell>
<Cell><Data ss:Type="Number ">1</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="Number ">2</Data></Cell>
<Cell><Data ss:Type="Number ">4</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="Number ">3</Data></Cell>
<Cell><Data ss:Type="Number ">9</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="Number ">4</Data></Cell>
<Cell><Data ss:Type="Number ">16</Data></Cell>
</Row>
</Table>
<WorksheetOptio ns xmlns="urn:sche mas-microsoft-com:office:exce l">
<Selected/>
<Panes>
<Pane>
<Number>3</Number>
<ActiveRow>5</ActiveRow>
<ActiveCol>1</ActiveCol>
</Pane>
</Panes>
<ProtectObjects >False</ProtectObjects>
<ProtectScenari os>False</ProtectScenario s>
</WorksheetOption s>
</Worksheet>
On Aug 31, 12:41 am, Marin Brkic <mbrkic@invalid _mail.adresswro te:
>
I'm trying to find a way to write data to excel cells (or to be more
specific to an .xls file), let's say for the sake of argument, data
readen from a file (although it will be calculated in the process).
I've been searching, but couldn't find any examples which allows that.
Do anyone knows of any ? All help is appreciated on this matter.
Tutorials? Anything ...
It helps in situations like this to mention details of your
environment
(1) what version of what operating system (Linux, OS X, Windows, etc)
(2) what version of Python
as the available solutions are often dependent on the answers.
For Python version 2.[345] on any platform, you can use xlwt, which is
as simple as this for writing a 1-worksheet Excel 97-to-2003 XLS file
(without any formatting):
def write_xls(file_ name, sheet_name, data):
import xlwt
book = xlwt.Workbook()
sheet = book.add_sheet( sheet_name)
rowx = 0
for row in data:
rowx += 1
for colx, value in enumerate(row):
sheet.write(row x, colx, value)
book.save(file_ name)
# data can be any of the following Python types: int, long, float,
decimal.Decimal , datetime.date, datetime.dateti me, bool, str, and
unicode.
xlwt is available from https://secure.simplistix.co.uk/svn/xlwt/trunk
I suggest that you join the python-excel group (http://
groups.google.c om.au/group/python-excel?hl=en) or at least read some
of the questions and responses.
HTH,
John
On Aug 31, 12:57 am, "Eric Wertman" <ewert...@gmail .comwrote:
If you have
to interface with an exsisting excel file, you can try http://pypi.python.org/pypi/xlrd, but it may not support writing xls
files, still.
That remark appears to be an inverted cousin of the old joke question
"Have you stopped beating your wife?" :-)
xlrd is still doing what it was designed to do: read (not "interface
with") Excel xls files. There is a currently active project to add
support for reading the xlsx (x=XML) files produced by Excel 2007.
This may be followed by Excel 2007 xlsb (b=binary) files and
OpenOffice ods files. Writing is not on the agenda.
Cheers,
John
Yes sorry, that's a really poorly formed sentence all the way
around... not a dig on xlrd, but a warning to the OP that they may not
find what they are looking for there.
On Aug 31, 12:57 am, "Eric Wertman" <ewert...@gmail .comwrote:
>If you have to interface with an exsisting excel file, you can try http://pypi.python.org/pypi/xlrd, but it may not support writing xls files, still.
That remark appears to be an inverted cousin of the old joke question
"Have you stopped beating your wife?" :-)
On Sat, 30 Aug 2008 17:18:19 -0700 (PDT), John Machin
<sj******@lexic on.netwrote:
Hello John (and everyone else), thanks for answering.
>It helps in situations like this to mention details of your environment (1) what version of what operating system (Linux, OS X, Windows, etc) (2) what version of Python as the available solutions are often dependent on the answers.
Yes, of course. I sometimes forget the most essential of things.
- winxp, sp2
- python 2.5.2
> For Python version 2.[345] on any platform, you can use xlwt, which is as simple as this for writing a 1-worksheet Excel 97-to-2003 XLS file (without any formatting):
Actually, that might work. What I was needing (aiming for) was a way
to write to excel 2003 files. Formatting is not necessary, since what
I'm trying to write is some tabular data; results from fortran-python
simulation (I can explain, but the details seem irrelevant for this
case).
I'm trying to avoid the text file - import to excel - mechanism, since
there is quite a lot of files written.
> def write_xls(file_ name, sheet_name, data):
import xlwt
book = xlwt.Workbook()
sheet = book.add_sheet( sheet_name)
rowx = 0
for row in data:
rowx += 1
for colx, value in enumerate(row):
sheet.write(row x, colx, value)
book.save(file_ name) # data can be any of the following Python types: int, long, float, decimal.Decima l, datetime.date, datetime.dateti me, bool, str, and unicode.
xlwt is available from https://secure.simplistix.co.uk/svn/xlwt/trunk
I suggest that you join the python-excel group (http:// groups.google. com.au/group/python-excel?hl=en) or at least read some of the questions and responses.
Please, one more question. As you have noticed, I posted my message to
comp.lang.pytho n, using a newsreader. Is there a way to access google
groups through a similiar interface program as a newsreader. Never
used them before, and getting a lot of messages to my email every day
does not sound very appealing to me.
Best regards
Marin
> HTH,
John
On Sat, 30 Aug 2008 19:37:16 +0200, "Marco Bizzarri"
<ma************ @gmail.comwrote :
> Is it suitable for you to use a python program talking with a running instance of openoffice? in that case, pyuno could help you.
Hello Marco, thanks for answering,
no, sorry. As much as I like OOffice, several other people will be
using the program I'm working on, and I can't cound on them having the
OOffice installed.
MS, as much as I hate to admit it, is the industry standard (or, at
least that's the one we're stuck with at the present time ;-)
Best regards
Marin
On Sun, 31 Aug 2008 03:36:39 +0200, Marin Brkic
<mbrkic@invalid _mail.adresswro te:
>On Sat, 30 Aug 2008 19:37:16 +0200, "Marco Bizzarri" <ma*********** *@gmail.comwrot e:
>> Is it suitable for you to use a python program talking with a running instance of openoffice? in that case, pyuno could help you.
Hello Marco, thanks for answering,
no, sorry. As much as I like OOffice, several other people will be using the program I'm working on, and I can't cound on them having the
*count* This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Deepa |
last post by:
I am writing a console app in c# wherein am converting a dataset into a CSV
file. It works fine. But I have some values in the dataset which have a comma
within(eg. A,B,C). When I view the CSV file in Excel, the multiple values
which are separated by the 'comma' in the dataset are being displayed in the
next column , which I dont want that way. I want to retain any commas which
are present in my dataset.
How do I handle such a scenario?
...
|
by: Mr. Smith |
last post by:
Hello all,
My code can successfully open, write to, format and save several
worksheets in a workbook then save it by a given name, close and quit excel.
My problem is that if I try and do it again, Excel hangs. OR if I open
Excel again (say from a desktop icon) before I close Access, Excel
hangs. (this has happened for both 97 & 2000 for me)
I of course thought that I mustn't be unloading a variable properly.
|
by: bob |
last post by:
My program copys things from a word document and puts
them into an excel spreadsheet. The problem I have
though is these annoying symbols that appear in place of
spaces in the text after Ive put them into the excel file.
here is an example. this is what it looks like in the
word document....
I went to the store.
|
by: RJN |
last post by:
Hi
I've a template excel file which has all the calculations defined. There
are certain input values to be entered which gives a lot of output to
the user. I don't want to expose the excel sheet to the user as
calculations become visible. I'm writing a web interface which takes the
input values from user, updates the excel sheet and returns the
recalculated output from the excel file. I'm using ADO.Net to update and
read the excel file.
|
by: RahimAsif |
last post by:
I am designing a data acquisition program that peridically collects
data from a panel and writes to a file. The way I am doing it right
now, every time I have data from the panel, I open the file, write my
data, and then close the file. The generated file itself is a text file
that is formatted either comma separated or tab separeted.
My problem is that the file my app generates can and probably will be
opened by the user in MS Excel....
| |
by: shintu |
last post by:
Hallo,
I am trying to write french accented characters é è ê in Excel worksheet using my perl script , But I am stuck here as I couldnt find a way of writing it !:
My code:
use strict;
use warnings;
|
by: thanawala27 |
last post by:
Hi,
I had problems writing in an existing Excel File.
There is an excel file with a worksheet. I would like to open this existing Excel file and add another worksheet and write data into it. But I dont know how to open an existing excel file.
can anyone give me some hint or help?
|
by: jpero09 |
last post by:
Having some trouble writing out accented characters to an ms-excel
type output from my asp.net page (c#).
I've tried a few different charsets but every time the è on my page is
getting rendered as è
Any ideas?
...
Response.Clear();
Response.Buffer= true;
|
by: =?Utf-8?B?ZmhpbGxpcG8=?= |
last post by:
We have a code snippet that downloads data to Excel. it is writing row by
row. This causes a performance issue. Any ideas on how to speed this up will
be appreciated.
Please find below an excerpt of the code:
#region Method:WriteToExcel
/// <summary>
/// <para>Description : Method is used to Write the records into
excel</para>
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |