是否可以使用PhpExcel库生成或克隆数据透视表? [英] Is It Possible To Generate Or Clone Pivot Tables Using PhpExcel Library?

查看:670
本文介绍了是否可以使用PhpExcel库生成或克隆数据透视表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近使用 phpExcel 库在cakephp中以excel格式生成报告。除了数据透视表外,每一件事情都很好。

Recently i have used phpExcel library to generate reports in excel format in cakephp. Every thing is working fine except pivot Tables.

我使用一个master excel表(其中包含数据透视表)来克隆/生成其他excel表。在新生成的工作表中其他信息看起来很好,但是不生成数据透视表(仅显示标题上的名称。没有过滤器选项)。这里是我使用的代码。

I am using a master excel sheet (Which contain pivot table) to clone/generate other excel sheet. In newly generated sheet other information is looking fine but pivot table is not being generated (only names on header are being display. There is no filter options). Here is the code i am using.

        $filename = WWW_ROOT."files/master_report_template/compliance_workflow_master_template.xlsx";
        $reportFileName = WWW_ROOT."files/documents/reports/compliance_workflow_template.xlsx";
        $this->PhpExcel->loadWorksheet($filename); 
        $this->PhpExcel->getActiveSheet()->setCellValue('B1',$this->request->data['fromDate']);
        $this->PhpExcel->getActiveSheet()->setCellValue('B2',$this->request->data['toDate']);
        $this->PhpExcel->getActiveSheet()->setCellValue('B3',date('D-M-y'));
        $row=6;
        foreach($repostData as $rows)
        {
            $col = 0;
            foreach($rows as $key =>$value)
            {   
                $this->PhpExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow($col, $row, $value);
                $col++;
            }
            $row++;
        }
        $this->PhpExcel->save($reportFileName);
        $this->PhpExcel->output(); 

我认为生成的excel表将是Master excel表的克隆,但两者都不相同到透视表)。有没有好的教程或文档来生成数据透视表?

I thought that generated excel sheet would be the clone of Master excel sheet but both are not same (due to pivot tables). Is there any good tutorial or documentations to generate pivot table ?

推荐答案

虽然这是一个老问题,答案:我几个月前有同样的问题,最后决定我需要做自己的实现(所以这是自广告..)

Albeit this is an old issue, I'd like to give an answer: I had the same issue some months ago and finally decided that I need to do my own implementation (so this is self-advertisement..)

这个解决方案远远不完美 - 因为我可能是唯一使用它的人 - 但它正在做你所描述的:将原始数据写入一张主文件,允许您创建报告:

This solution is far from perfect - since I'm maybe the only person using it - but it is doing exactly what you describe: Writing raw data into one sheet of a "master file" allowing you to create reports:

https://github.com/svrnm/exceldatatables

这篇关于是否可以使用PhpExcel库生成或克隆数据透视表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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