使用 pyExcelerator/xlrd 的枢轴 [英] pivots using pyExcelerator/xlrd

查看:36
本文介绍了使用 pyExcelerator/xlrd 的枢轴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用pyExcelerator/xlrd等python库创建带有数据透视表的工作表(在excel工作簿中)?我需要生成一个每日报告,其中有一个数据透视表来汇总其他工作表上的数据.一种选择是使用我复制并填充数据的空白模板.在这种情况下,有没有办法从代码中刷新数据透视表?还有其他建议吗?

How can I go about creating a worksheet (within an excel workbook) with a pivot table using python libs like pyExcelerator / xlrd? I need to generate a daily report that has a pivot table to summarize data on other sheets. One option would be to have a blank template that I copy and populate with the data. In this case, is there a way to refresh the pivot from code? Any other suggestions?

推荐答案

请澄清(通过编辑您的问题)sheet"是spreadsheet"的缩写并表示整个 XLS 文件,还是工作表",工作簿"的一个组成部分.

Please clarify (by editing your question) whether "sheet" is an abbreviation of "spreadsheet" and means a whole XLS file, or whether it's an abbreviation of "worksheet", a component of a "workbook".

如果您所说的数据透视表"指的是 Excel 机制,那您就不走运了,因为它只能由 Excel 创建.但是,如果您的意思是使用 Python 和适当的库创建自己的交叉表",则可以使用 xlrd、xlwt 和 xlutils 三个组合来实现.

If by "pivot table" you mean the Excel mechanism, you are out of luck, because that can be created only by Excel. However if you mean a "cross-tab" that you create your self using Python and an appropriate library, you can do this using the trio of xlrd, xlwt and xlutils.

xlrd 你似乎知道.

xlrd you appear to know about.

xlwt 是 pyExcelerator 的一个分支,修复了错误并进行了一些增强.pyExcelerator 似乎没有维护.

xlwt is a fork of pyExcelerator with bugs fixed and several enhancements. pyExcelerator appears not to be maintained.

xlutils 是一个实用程序模块包.xlutils.copy 可用于从 xlrd Book 对象创建 xlwt Workbook 对象,以便您可以对 xlwt Workbook 进行更改并将其保存到文件中.

xlutils is a package of utility modules. xlutils.copy can be used to make an xlwt Workbook object from an xlrd Book object, so that you can make changes to the xlwt Workbook and save it to a file.

这是您的一站式商店,了解有关这三个软件包的更多信息,以及教程,以及指向可用于获取帮助的 google-group/mailing-list 的链接.

Here is your one-stop-shop for more info on the three packages, together with a tutorial, and links to a google-group/mailing-list which you can use to get help.

这篇关于使用 pyExcelerator/xlrd 的枢轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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