写给ms excel [英] Writing to ms excel

查看:97
本文介绍了写给ms excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


拜托,让我提前道歉。英语不是我的第一语言

(甚至不是我的第二语言),所以请原谅我即将发生的任何错误

在公众面前尴尬。第二,我对python来说是相对新的b $ b很抱歉,如果这看起来像是一个愚蠢的问题,那就很抱歉。


我想找个方法将数据写入excel单元格(或者更多是特定于.xls文件的
),让我们说为了论证,数据

来自a文件(虽然它将在此过程中计算)。

我一直在搜索,但找不到任何允许的例子。


有人知道吗?所有的帮助都在此事上表示赞赏。

教程?什么...

祝你好运

马林

解决方案

我正在努力找到一种方法将数据写入excel单元格(或更多


特定于.xls文件),让我们说为了论证,数据

从文件中获取(虽然它将在此过程中计算)。

我一直在搜索,但找不到任何允许这样做的例子。



答案将取决于您的基础操作系统..如果您在Windows上那里

将是一些使用COM接口的选项我打赌..但我不知道

关于他们的任何事情。


如果你使用基于unix的操作系统,你的选择是有限的。如果可以,

我会写一个csv文件并用Excel打开它。如果你有一个与现有的excel文件接口的
,你可以尝试
http://pypi.python.org/pypi/xlrd ,但它可能不支持写xls

文件,仍然。


2008年8月30日星期六下午4:41,Marin Brkic< mbrkic@invalid_mail.adresswrote:


大家好,


>

我正试图找到一种方法将数据写入excel单元格(或者更多

特定于.xls文件),让我们说为了参数,数据

从文件中重新登记(虽然它将在此过程中计算) 。

我一直在寻找,但是找不到任何允许这样做的例子。



你是否适合使用python程序与openoffice的运行

实例交谈?在这种情况下,pyuno可以帮助你。

-

Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/


Marin Brkic写道:


大家好,


拜托,让我提前道歉。英语不是我的第一语言

(甚至不是我的第二语言),所以请原谅我即将发生的任何错误

在公众面前尴尬。第二,我对python来说是相对新的b $ b很抱歉,如果这看起来像是一个愚蠢的问题,那就很抱歉。


我想找个方法将数据写入excel单元格(或者更多是特定于.xls文件的
),让我们说为了论证,数据

来自a文件(虽然它将在此过程中计算)。

我一直在搜索,但找不到任何允许的例子。


有人知道吗?所有的帮助都在此事上表示赞赏。

教程?什么...


祝你好运

Marin



不是特定于python,但是如果你有一个excel的最新版本,你可以写入Excel xml格式(如果没有,你可以考虑

)(或其中一个)gnumeric xml格式。

Excel格式很详细,但您可以复制并粘贴大部分内容。

您需要软件编写的关键位看

类似这样的事情:

< Worksheet ss:Name =" Sheet1">

< Table ss:ExpandedColumnCount =" 2" ss:ExpandedRowCount =" 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 =" N. umber"> 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>

< /行>

<行>

< Cell><数据ss:Type =" Number"> 3< / Data>< ; / Cell>

< Cell>< Data ss:Type =" Number"> 9< / Data>< / Cell>

< /行>

<行>

< Cell><数据ss:Type =" Number"> 4< / Data>< / Cell>

< Cell>< Data ss:Type =" Number"> 16< / Data>< / Cell>

< / Row>

< /表>

< WorksheetOptions xmlns =" urn:schemas-microsoft-com:office:excel">

< Selected />

&l t; Panes>

< Pane>

< Number> 3< / Number>

< ActiveRow> 5< / ActiveRow>

< ActiveCol> 1< / ActiveCol>

< / Pane>

< / Panes>

< ProtectObjects> False< / ProtectObjects>

< ProtectScenarios> False< / ProtectScenarios>

< / WorksheetOptions>

< /工作表>


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

解决方案

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.adresswrote:

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:ExpandedColumnCount="2" ss:ExpandedRowCount="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>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<Selected/>
<Panes>
<Pane>
<Number>3</Number>
<ActiveRow>5</ActiveRow>
<ActiveCol>1</ActiveCol>
</Pane>
</Panes>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>


这篇关于写给ms excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆