像 PHP 的 Crystal Reports 之类的东西?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/747103/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 23:45:09  来源:igfitidea点击:

Something like Crystal Reports for PHP?

phpreportinvoice

提问by Mez

I'm looking for something that works in PHP and is similar to crystal reports. I basically need to have a layout setup that means I can output invoices just by inserting the data, and then send it to a printer.

我正在寻找可以在 PHP 中使用并且类似于水晶报告的东西。我基本上需要一个布局设置,这意味着我可以通过插入数据输出发票,然后将其发送到打印机。

The closest I've found so far is PDFB, but It's a bit of a pain as it needs to have precise positioning.

到目前为止,我发现的最接近的是 PDFB,但它需要精确定位,因此有点痛苦。

I'd like to have something that could generate an invoice based on a template (preferably XML based) and then output it to a form easy for us to print (PostScript would be nice!)

我想要一些可以基于模板(最好是基于 XML 的)生成发票的东西,然后将其输出到易于我们打印的表单中(PostScript 会很好!)

It needs to have support for barcodes too (though these can be generated as a GD image)

它也需要支持条形码(尽管这些可以生成为 GD 图像)

Another requirement is that this must be FLOSS

另一个要求是这个必须是FLOSS

采纳答案by vartec

Use XML + XSL:FO with Apache FOPvia PHP-JavaBridge.

通过PHP-JavaBridge将 XML + XSL:FO 与Apache FOP一起使用

Here is how: http://wiki.apache.org/xmlgraphics-fop/HowTo/PHPJavaBridge

方法如下:http: //wiki.apache.org/xmlgraphics-fop/HowTo/PHPJavaBridge

PostScript would be nice!

PostScript 会很好!

Many PostScript printers understand PDF too.

许多 PostScript 打印机也能理解 PDF。

回答by Ivan Vu?ica

I've used Spreadsheet_Excel_Writerin PHP, and it's good enough. Not WYSIWYG, but it does generate XSL files, and I'm happy with it. Afterwards, you can use OpenOffice macroto convert the document to PDF. It works from command line, ergo, it works from PHP scripts too.

Spreadsheet_Excel_Writer在PHP中使用过,它已经足够好了。不是所见即所得,但它确实生成了 XSL 文件,我对此很满意。之后,您可以使用 OpenOffice 宏将文档转换为 PDF。它可以从命令行运行,ergo,它也可以从 PHP 脚本运行。

Or here's an even better way.

或者这里有一个更好的方法。

Use OpenOffice to convert a Smarty template. Smarty is a cool templating engine for PHP, I recommend it for this purpose. Then generate pure HTML using PHP with Smarty. Finally, just convert the generated HTML into PDF using aforementioned method.

使用 OpenOffice 转换 Smarty 模板。Smarty 是一个很酷的 PHP 模板引擎,为此我推荐它。然后使用 PHP 和 Smarty 生成纯 HTML。最后,只需使用上述方法将生成的 HTML 转换为 PDF。

Reporting Revolutionized (tm).

报告革命化 (tm)。

EDIT Jun6 2009Modded down? Ah, nevermind.

编辑 2009 年 6 月 6 日修改下来?啊没关系。

Anyways, this method works on a headless server without running X11. I've taken the script from the mentioned link(except I put it in preexisting collection "Standard" instead of "DannysLibrary") and then I've ran this command from Windows machine using PuTTY, and X was shut down on remote machine, and DISPLAY variable was not set, and ... well, in any case, there's no way OOo could find X11 to connect to.

无论如何,这种方法在没有运行 X11 的无外设服务器上工作。我已经从提到的链接中获取了脚本(除了我把它放在预先存在的集合“标准”而不是“DannysLibrary”中),然后我使用 PuTTY 从 Windows 机器运行了这个命令,并且 X 在远程机器上被关闭,并且没有设置 DISPLAY 变量,而且……好吧,无论如何,OOo 无法找到要连接的 X11。

$ openoffice.org -invisible -headless "macro:///Standard.Conversion.ConvertWordToPDF(`pwd`/logaritamska.doc)"

This works and I'm sure this would work great for anyone who'd need conversion from another format into PDF, including production of printable reports from HTML. By editing the macro you could, perhaps, even get OOo to read directly from stdin or from your temporary service URL, and output into predefined file. The script on the linkis quite simple once you have the elementary code to expand.

这很有效,我相信这对于需要从另一种格式转换为 PDF 的任何人都非常有用,包括从 HTML 生成可打印的报告。通过编辑宏,您甚至可以让 OOo 直接从标准输入或临时服务 URL 读取,并输出到预定义文件中。一旦您有了要扩展的基本代码,链接上的脚本就非常简单。

Summary:

概括:

  • generate reports as XLS or HTML
  • convert them
  • even though it's OOo, it works on headless machines
  • 生成 XLS 或 HTML 格式的报告
  • 转换它们
  • 即使它是 OOo,它也适用于无头机器

EDIT Jun 9 2009I've tried to implement an online converter this way. You should make PHP run under the same user under which you created macros. This user apparently cannot be www-data. I've tried to use suphp, but for some reason it didn't change the user properly (posix_getuid()kept returning 33 which is www-data). I'll edit this once I fix this.

编辑 2009 年 6 月 9 日我尝试以这种方式实现在线转换器。您应该让 PHP 在您创建宏的同一用户下运行。这个用户显然不能是 www-data。我尝试使用 suphp,但由于某种原因它没有正确更改用户(posix_getuid()一直返回 33,即 www-data)。一旦我解决了这个问题,我会编辑这个。

EDIT Jun 26 2009Guess it took me a while to report back. Yes, this works with suphp. I'm however not in position to show it live, since the only server I have runs a relatively critical web app which didn't have professional security auditing. This means one of the things we depend on to protect the backend is that the user under which frontend runs is a very very unprivileged user (such as www-data). Don't ask :-)

编辑 2009 年 6 月 26 日猜猜我花了一段时间才回来报告。是的,这适用于 suphp。然而,我无法现场展示它,因为我唯一的服务器运行的是一个没有专业安全审计的相对关键的 Web 应用程序。这意味着我们依赖于保护后端的一件事是前端运行的用户是一个非常非常没有特权的用户(例如 www-data)。不要问:-)

Hope this helps someone: yes, converting into PDF with OO.o is quite realistic. There's even some remote calling support in OO.o but I didn't study that just for purposes of writing this.

希望这对某人有所帮助:是的,使用 OO.o 转换为 PDF 是非常现实的。OO.o 中甚至还有一些远程调用支持,但我并不是为了写这篇文章而研究它的。

回答by elviejo79

I have used the eclpse in php: "BIRT Project"

我在 php 中使用了 eclpse:“BIRT 项目”

http://www.eclipse.org/birt/phoenix/

http://www.eclipse.org/birt/phoenix/

You design your report in Eclipse. Then upload it to your server (it must be running tomcat) I know. Then you can call that report from your php application you can send the parameters to the report through the query string:

您在 Eclipse 中设计您的报告。然后将其上传到您的服务器(它必须运行tomcat)我知道。然后您可以从您的 php 应用程序调用该报告,您可以通过查询字符串将参数发送到报告:

/myreport.birt?param=var&param2=var2

/myreport.birt?param=var¶m2=var2

We have a 4 year application working like this so far. Around a 100 reports and it works really well.

到目前为止,我们有一个像这样工作的 4 年应用程序。大约有 100 份报告,而且效果非常好。

Of course it is open source.

当然,它是开源的。

Good luck

祝你好运

回答by Martijn Laarman

If you have server access you might also like to go for XSL Formatting Objectsthrough Apache FOP. XSL-FO is XML based and supports alot of output formatsincluding PostScript and PDF

如果您有服务器访问权限,您可能还想通过Apache FOP进行XSL 格式化对象。XSL-FO 基于 XML,支持多种输出格式,包括 PostScript 和 PDF

回答by Ansgar

If you manage to call a Java application in your php-environment (which in general should be possible) JasperReportsmaybe the thing you are looking for:

如果您设法在您的 php 环境中调用 Java 应用程序(通常应该是可能的),JasperReports可能是您正在寻找的东西:

回答by Moamen Mostafa

Reportico

报告

In my opinion is one of the best, detailed and feature rich PHP Report Designer.

在我看来,它是最好的、详细的、功能丰富的 PHP 报表设计器之一。

回答by juanmf

The right tool for this need is XSL-FO, as it's perfect for printable media. XSL-FO is also a W3C Recommendation, with XSLT. I've made a php tool that use XSL-FO as intermediate language for reporting, this XLS-FO is the result of merging (processing) the report XSLT template with your XML data.

满足此需求的正确工具是 XSL-FO,因为它非常适合可打印媒体。XSL-FO 也是 W3C 推荐标准,带有 XSLT。我制作了一个使用 XSL-FO 作为报告中间语言的 php 工具,这个 XLS-FO 是将报告 XSLT 模板与您的 XML 数据合并(处理)的结果。

You create the template automagically using MS Word, and exporting as shown in the user manual. Then you feed the reporting Engine with the template, and at run time with the data XML.

您可以使用 MS Word 自动创建模板,并按照用户手册中的说明进行导出。然后将模板提供给报告引擎,并在运行时提供数据 XML。

Also at runtime, the resulting XSL-FO report is rendered to:

同样在运行时,生成的 XSL-FO 报告呈现为:

a) the same XSL-FO (if you want to debug or just want a XSL-FO)

a) 相同的 XSL-FO(如果你想调试或者只是想要一个 XSL-FO)

b) A perfect PDF, (ApacheFOP renders the XSL-FO)

b) 完美的 PDF,(ApacheFOP 呈现 XSL-FO)

c) HTML with a XSLFO2HTML transformation.

c) 带有 XSLFO2HTML 转换的 HTML。

Here you have the project, its a symfony 1.4 plugin: https://github.com/juanmf/sfPlugins/tree/master/reportPlugin

这里有项目,它是一个 symfony 1.4 插件:https: //github.com/juanmf/sfPlugins/tree/master/reportPlugin

I plan to decouple it from sf. Don't hesitate to ask anything. Here is the HowTo: https://github.com/juanmf/sfPlugins/blob/master/reportPlugin/doc/HowToReport.pdf?raw=true

我打算将它与科幻脱钩。不要犹豫,问任何事情。这是操作方法:https: //github.com/juanmf/sfPlugins/blob/master/reportPlugin/doc/HowToReport.pdf?raw =true

This post might also give you some help: https://stackoverflow.com/questions/5519024/report-engine-solution-for-lamp-application/13042656

这篇文章也可能会给你一些帮助:https: //stackoverflow.com/questions/5519024/report-engine-solution-for-lamp-application/13042656

Regards!

问候!

回答by Kyle Simek

I ran into the same problem about a year ago. After searching all over for an existing solution I didn't find one, so I wrote a slimmed-down crystal reports using Zend Framework's PDF generation library. I had to heavily adapt their library to support grouped objects, repeating sections and templates. It worked, but it was really clunky, and if I had to do it again, I would find a way to bridge php to crystal reports, either through a web service like Gushiken said, or by calling a command-line app. CPAN has a Perl interface to C.R.: Win32::OLE::CrystalRuntime::Application .

大约一年前,我遇到了同样的问题。在四处寻找现有的解决方案后,我没有找到,所以我使用 Zend Framework 的 PDF 生成库编写了一个精简的水晶报告。我不得不大量调整他们的库以支持分组对象、重复部分和模板。它有效,但它真的很笨拙,如果我必须再次这样做,我会找到一种方法将 php 桥接到 Crystal 报告,或者通过 Gushiken 所说的 Web 服务,或者通过调用命令行应用程序。CPAN 有一个到 CR 的 Perl 接口:Win32::OLE::CrystalRuntime::Application

If a PHP solution has been released in the past year, I doubt it is mature enough to compare to C.R. Don't waste your time pulling your hair out -- go with what works. Time is expensive. Software ain't.

如果 PHP 解决方案已在过去一年中发布,我怀疑它是否足够成熟以与 CR 进行比较。不要浪费您的时间——选择有效的方法。时间是昂贵的。软件不是。

回答by SvenFinke

hm.. i had the same problem at my current project and i ended up using crystal reports and calling the report with an asp.net web service written in c#. the web service is nothing to complex and you can still use all the features of crystal reports. i dont think that you will find any report engine that is completely based on php that can be compared to crystal reports... i havent been able to find one yet...

嗯..我在我当前的项目中遇到了同样的问题,我最终使用了水晶报告并使用用 c# 编写的 asp.net web 服务调用了报告。Web 服务并不复杂,您仍然可以使用 Crystal Reports 的所有功能。我不认为你会发现任何完全基于 php 的报告引擎可以与水晶报告相比......我还没有找到......

回答by Ratheesh R

Try Tufat

试试图法

I just happen to see that ..may be it will help you. However there is a free version is available for you to test.

我只是碰巧看到..也许它会帮助你。但是,有一个免费版本可供您测试。

You will like it .. Please share your copy.

你会喜欢它.. 请分享你的副本。