我对Crystal Report有疑问。我有一个现有的报告,其数据来自存储过程。数据可能如下所示:
Division|Group Level 1|Group Level 2 |Group Level 3|Value --------+-------------+-------------------+-------------+-------- IT |Assets |Current Asset |Cash |100 CORP |Assets |Current Asset |Cash |200 IT |Assets |Current Asset |Receivables |300 CORP |Assets |Current Asset |Receivables |400 IT |Assets |Fixed Asset |Land |500 CORP |Assets |Fixed Asset |Land |600 IT |Liabilities |Current Liabilities|Wages |100 CORP |Liabilities |Current Liabilities|Wages |200 IT |Liabilities |Current Liabilities|Taxes |100 CORP |Liabilities |Current Liabilities|Taxes |100 IT |Liabilities |Long-Term |Bonds |300 CORP |Liabilities |Long-Term |Bonds |400
实际数据可能有更多分区(不只是两个)。在新报告中,我希望报告如下所示:
| IT | CORP Current Asset Cash | 100 | 200 Receivables | 300 | 400 Total Current Asset | 400 | 600 Fixed Asset Land | 500 | 600 Total Fixed Asset | 500 | 600 Total Assets | 900 | 1200 Current Liabilities Wages | 100 | 200 Taxes | 100 | 100 Total Current Liabilities | 200 | 300 Long-Term Bonds | 300 | 400 Total Long-Term | 300 | 400 Total Liabilities | 500 | 700
因此,根据分部的数量,报告将扩展到右侧。假设一个页面最多可以容纳10个分区。然后,如果有15个分区,则第一页将显示分区1到10,第二页将显示11到15.第一页和第二页上显示的项目将是相同的,仅适用于不同的分区。分部的数量是灵活的。而且项目也很多(可能有很多流动资产,负债等)。
现在,我尝试在存储过程中进行一些格式化,因此返回的数据将类似于:
Page No | Group Level 1 | Group Level 2 | Group Level 3 | Div 1 | Value 1 | Div 2 | Value 2 --------+---------------+---------------+---------------+-------+---------+-------+-------- 1 | Assets | Current Asset | Cash | IT | 100 | CORP | 200 1 | Assets | Current Asset | Receivables | IT | 300 | CORP | 400
等等。 对于11到15分区,我将页面编号设置为2.然后在Crystal Report中,我将分组:页面编号,组级别1,组级别2和组级别3。 因此,Crystal报表将根据页码显示页面上的所有内容。
问题是:
- 如果有很多项目,那么它也可能不适合一页。例如,假设一个页面最多可以容纳30行,那么如果我有40行,则10行将显示在第二页中。
但我希望第二页仍然显示分区11-15的前30项,第三页将显示分区1-10的最后10行,第四页将显示分区11-15的最后10行。
- Crystal Report中的运行总计将在组的每次更改时重置。假设我有40个资产。然后在第三页和第四页的40个资产之后,它应该显示资产的总数。如何计算运行总计以使其正确显示? (考虑到我不能直接总结,因为第三页和第四页应该显示不同部门的总和)。
是否有针对此问题的解决方案或更好的数据格式化方法?
感谢。
答案 0 :(得分:0)
你的确切问题是什么?
实施以下流程
编写公式并添加以下代码
如果Divison =“IT” 那么价值 否则o wirte另一个公式,并添加下面的代码
IF Divison =“Corp” 然后价值 其他0
详细放置两个论坛并将摘要添加到所有部分。还要详细说明
对于所有组页脚,请写入必需的文本
这将解决您的问题。
答案 1 :(得分:0)
我建议使用交叉表。
设定:
Division
Group Level 1
,Group Level 2
,Group Level 3
Value
您必须尝试行分组字段才能获得正确的间距。对列的大小调整也一样。
答案 2 :(得分:0)
总的来说,这就是我最终解决问题的方法:
1. Define how many divisions (NumColumn) to be displayed in a single page.
2. Create a table to store the mapping of the division. The table has column that stores PageOffset and ColumnNo. PageOffset stores the number of page to be added when displaying a particular division. For example, if there are 15 divisions, and a page can only accommodate 10 divisions, then the first 10 divisions will have `PageOffset = 0` and the last 5 divisions will have `PageOffset = 1`. The ColumnNo is the position of a division in the report column. So first division will have value of 1, second division will have value of 2 and so on. 11th division will have the value of 1, etc.
3. Create a result table. For each column in the report, we have 2 database field, value and total.
4. Loop for each record, sorted by the group.
Select the position of the division from the table in step 2. If `ColumnNo = 1` insert a row in the result table. E.g. for division 1 and 11 it will create rows in result table.
After that update the row data, based on the position of the division. So for division 1-10 will update the row created by division 1, division 11-15 will update row created by division 11.
5. Count the number of items in each group and store it into a table.
6. Define how many rows (RowsInPage) to be displayed in a single page.
7. Set PageAdd = 0 and RowsLeft = RowsInPage
8. Loop for each group
Retrieve the number of rows needed for this group
Add the page number of each row with PageAdd
Decrement RowsLeft
If RowsLeft = 0
Increment PageAdd
Set RowsLeft = RowsInPage
End If
9. Loop for each group
Loop from 1 to NumColumn
Update the total field for each division. This total field value will be put in the report as the running group total for that particular division.