简体   繁体   English

Excel::Writer::XLSX (Perl) 表格内省

[英]Excel::Writer::XLSX (Perl) sheet introspecion

For some time I've wondered if/when this module could get some introspection abilities, beyond just hacking on the object.有一段时间我想知道这个模块是否/何时可以获得一些内省能力,而不仅仅是对对象进行黑客攻击。

For example:例如:

Once a sheet has been written, how can I know query the sheet object to know things like how many rows and columns it has?写好工作表后,我怎么知道查询工作表对象以了解它有多少行和列?

What I want to do is write a number of sheets, then go back to each and write more rows to them.我想要做的是写一些工作表,然后回到每个工作表并向他们写更多行。 I could keep track of last row/column on my own, but before I do that I'm wondering if I can get that data from the already-written objects, before the final workbook->close.我可以自己跟踪最后一行/列,但在此之前,我想知道是否可以在最终工作簿->关闭之前从已经编写的对象中获取该数据。

I think I could count the number of keys in a sheet object's _table hash, but that may be too close to the metal to be "official."我想我可以计算工作表对象的 _table 哈希中的键数,但这可能太接近金属而不能成为“官方”。 I remember John saying not to do that somewhere in the CPAN docs.我记得 John 在 CPAN 文档的某个地方说过不要这样做。

I could keep track of last row/column on my own, but before I do that I'm wondering if I can get that data from the already-written objects, before the final workbook->close.我可以自己跟踪最后一行/列,但在此之前,我想知道是否可以在最终工作簿->关闭之前从已经编写的对象中获取该数据。

No. That isn't possible.不,那是不可能的。 Excel::Writer::XLSX doesn't provide any tools for introspecting the data once it crosses the APIs.一旦数据通过 API,Excel::Writer::XLSX 不提供任何用于自省数据的工具。 This is a deliberate design decision.这是一个深思熟虑的设计决定。 You should treat an Excel::Writer::XLSX object as a black box and not some sort of database.您应该将 Excel::Writer::XLSX 对象视为黑盒而不是某种数据库。

The best way to do what you want is to track the range data in your program.做你想做的最好的方法是在你的程序中跟踪范围数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM