简体   繁体   English

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

[英]PHP: spreadsheet summary with OpenTBS?

I'm using the PHP library TinyButStrong with the plugin OpenTBS to merge existing Excel (or OpenOffice Calc) spreadsheets with data from a database. 我将PHP库TinyButStrong与插件OpenTBS结合使用,以将现有的Excel(或OpenOffice Calc)电子表格与数据库中的数据合并。

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. 例如,我将单元格A1定义为与数据合并的单元格。 After the merge, rows are inserted for A2, A3, etc. 合并后,将插入A2,A3等行。

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

Any ideas? 有任何想法吗?

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. 合并工作表时,OpenTBS无法跟随单元格,因为在合并过程中任何时间都可以移动,删除和复制任何单元格。

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): ODS文件示例(OpenOffice电子表格):
For Excel, replace "odsNum" with "xlsxNum", and "table:table-row" with "row". 对于Excel,将“ odsNum”替换为“ xlsxNum”,将“ table:table-row”替换为“ 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. 这样,ODS公式始终保持正确,无论块“ a”可以扩展到什么。

Elaborated solution: 详细的解决方案:

Use a formula that references to the cell just above itself. 使用一个引用单元格上方的公式。

Example with an ODS file (OpenOffice Spreadsheet): ODS文件示例(OpenOffice电子表格):
For Excel, replace "odsNum" with "xlsxNum", and "table:table-row" with "row". 对于Excel,将“ odsNum”替换为“ xlsxNum”,将“ table:table-row”替换为“ 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))) )

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

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