PHP:使用 OpenTBS 进行电子表格摘要?

发布于 2025-01-01 18:07:22 字数 273 浏览 2 评论 0原文

我使用 PHP 库 TinyButStrong 和插件 OpenTBS 将现有 Excel(或 OpenOffice Calc)电子表格与数据库中的数据合并。

这工作正常,但我不知道如何定义列的摘要。

例如,我将单元格 A1 定义为与数据合并的单元格。合并后,为 A2、A3 等插入行。

问题是我事先不知道要插入多少行,因此不能选择将 10 行留空并将 A11 定义为摘要字段,因为它也可能是 100 行数据,并且我希望摘要直接位于最后一行数据的下方。

有什么想法吗?

I'm using the PHP library TinyButStrong with the plugin OpenTBS to merge existing Excel (or OpenOffice Calc) spreadsheets with data from a database.

This works fine, but I can't figure out how to define summaries for a column.

For example , I define cell A1 as the cell that merges with the data. After the merge, rows are inserted for A2, A3, etc.

The problem is that I don't know beforehand how many rows are going to be inserted, so it's not an option to leave 10 rows empty, and define A11 as the summary field, because it could also be 100 rows of data, and I want the summary directly below the last row of data.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鯉魚旗 2025-01-08 18:07:22

合并工作表时,OpenTBS 无法跟踪单元格,因为在合并过程中任何单元格都可以移动、删除和复制。

尽管如此,我可以提出两种解决方案。

简单的解决方案:

决定将总计放在要求和的区域上方。并使用一个公式来覆盖它永远不可能覆盖的区域。

ODS 文件示例(OpenOffice 电子表格):

对于 Excel,将“odsNum”替换为“xlsxNum”,将“table:table-row”替换为“row”。

A1: = SUM(A2:A20000)
A2: [a.amount;block=table:table-row;ope=odsNum]

这样,无论块“a”如何,ODS 公式都保持正确延伸至.

详细解决方案:

使用引用其上方单元格的公式。

ODS 文件示例(OpenOffice 电子表格):

对于 Excel,将“odsNum”替换为“xlsxNum”,将“table:table-row”替换为“row”。

A1: [a.amount;block=table:table-row;ope=odsNum]
A2: =SUM( A1 : INDIRECT(ADDRESS(ROW()-1;COLUMN())) )

相同,但具有固定列:

A1: [a.amount;block=table:table-row;ope=odsNum]
A2: =SUM( A1 : INDIRECT("A" & (LIGNE()-1))) )

OpenTBS is not able to follow a cell when a sheet is merged because any cell can be moved, deleted and duplicated at any time during the merging.

Nevertheless, I can suggest two solutions.

Easy solution:

Decide to place the total above the zone to sum. And use a formula that covers the zone over it can never be.

Example with an ODS file (OpenOffice Spreadsheet):

For Excel, replace "odsNum" with "xlsxNum", and "table:table-row" with "row".

A1: = SUM(A2:A20000)
A2: [a.amount;block=table:table-row;ope=odsNum]

This way the ODS formula stays correct what ever the block "a" can be extended to.

Elaborated solution:

Use a formula that references to the cell just above itself.

Example with an ODS file (OpenOffice Spreadsheet):

For Excel, replace "odsNum" with "xlsxNum", and "table:table-row" with "row".

A1: [a.amount;block=table:table-row;ope=odsNum]
A2: =SUM( A1 : INDIRECT(ADDRESS(ROW()-1;COLUMN())) )

The same but with a fixed column:

A1: [a.amount;block=table:table-row;ope=odsNum]
A2: =SUM( A1 : INDIRECT("A" & (LIGNE()-1))) )
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文