Android的碧玉报告 [英] Android Jasper Reporting
问题描述
能否碧玉报表集成到一个Android应用程序?我试图生成PDF,CSV,文本,并从JRXML文件XLS报告。不过,我没有看到包net.sf.jasperreports.engine是在Android SDK的支持。任何人都可以证实,这是可能的?
Can Jasper Reporting be integrated into an Android application? I'm trying to generate PDF, CSV, Text, and XLS reports from jrxml files. However, I don't see that the package net.sf.jasperreports.engine is supported in the Android SDK. Can anyone confirm that this is possible?
推荐答案
我试了一下,太。但我并不全成...
I tried it, too. But I was NOT successfull...
假如得到的JasperReports源(实际它是4.7.0主干)
Had get the source of JasperReports (actual it's trunk of 4.7.0)
那时,在源 - code一些变化:
Then there were some changes in Source-Code:
-
集创建解析器valadation为假
(net.sf.jasperreports.engine.xml.BaseSaxParserFactory):
set created Parser valadation to false (net.sf.jasperreports.engine.xml.BaseSaxParserFactory):
public SAXParser createParser() {
try {
SAXParserFactory parserFactory = createSAXParserFactory();
parserFactory.setValidating(false); // add this line
更新:没有必要 - 使用属性net.sf.jasperreports.compiler.xml.validation =假,而不是
UPDATE: no need for - use property net.sf.jasperreports.compiler.xml.validation=false instead
模式(net.sf.jasperreports.engine.xml.BaseSaxParserFactory)的禁用配置:
评法的完全体:
保护无效configureParser(SAXParser的解析器)抛出的SAXException
disable configuration of schema (net.sf.jasperreports.engine.xml.BaseSaxParserFactory): comment complete body of method: protected void configureParser(SAXParser parser) throws SAXException
创建项目AndroidRepackage,创建一个包my.beans,放在java.beans.PropertyDescriptor中(rt.jar中的解压缩源)那里的资源文件,并解决了大量的编译器的问题(太很多这里列出)
Create the Project "AndroidRepackage", create a package for my.beans, put in there the sourcefile of java.beans.PropertyDescriptor (unzip source of rt.jar) and solve a lots of compiler-problems (too much to list in here)
获取公地的BeanUtils-1.8.3,解压org.apache.commons.beanutils.BeanUtils.java和org.apache.commons.beanutils.MethodUtils.java来源在你的AndroidRepackage - 项目和解决了大量的编译器问题(太多这里列出)
Get The Source for commons-beanutils-1.8.3, unzip org.apache.commons.beanutils.BeanUtils.java and org.apache.commons.beanutils.MethodUtils.java in your "AndroidRepackage"-Project and solve a lots of compiler-problems (too much to list in here)
更改为的BeanUtils java.beans中所有引用到my.beans
change all references to java.beans in beanutils into my.beans
=>问题是:BeanUtils的使用sun.reflet *这是原产于每个平台。
来源$ C $ C可以发现,而是沿着当地人自然它必须是C.
在这一点上,我决定去寻找另一种方式......
=> PROBLEM is: beanutils are using sun.reflet.* which is native for every platform. Source code can be found, but along natives nature it has to be C. At this point I decided to look for another way... ...
第二个尝试:
事实上,上面只希望加载从XML报表时会导致本地code描述的方法,我想就在API创建我的JasperDesing
结果=>问题是:JasperReports的创建* .java文件并调用调用Runtime.getRuntime()EXEC(javac的)...
2nd try:
In fact that the approach described above hopefully only leads to native code when loading the report from an XML, I tried to create my JasperDesing right over the API
=> PROBLEM is: JasperReports creates *.java files and calls Runtime.getRuntime().exec("javac")...
这些问题现在:有没有编译器直接在设备上使用和如何在不生根的设备执行这样的
- >问如何实现Java编译器和DEX转换器转换成Android应用
The questions are now: "Is there any compiler to use directly on the device" AND "how to execute such without rooting the device -> asked in How to implement a Java compiler and DEX converter into an Android app?
O.K:JasperReports的支持从JDT编译器,它只是要在类路径中。因此,将它添加到它引出了下一个问题项目的libs文件夹:java.lang.Object中不能被解析
O.K.: JasperReports supports the compiler from JDT, it just has to be in the classpath. So adding it to the libs folder of the project it leads to the next problem: java.lang.Object could not be resolved!
但是,这真的是相当一个问题:财产jasper.reports.compile.class.path由JasperReports的规定将被JDT编译器被忽略 - 因此如何从Android框架加载类?
随着特殊类加载器我din't成功了,每天经过试验,试图哭我决定延长JRJdtCompiler和覆盖的方法compileUnits。在那里我会在上面链接测试使用批处理编译org.eclipse.jdt.internal.compiler.batch.Main等。当我完成的工作我会后做的就是它运行的是什么...
But that's really quite a problem: The property "jasper.reports.compile.class.path" provided by JasperReports will be ignored by the JDT compiler - so how to load the classes from android framework? With an special classloader I din't succeeded, after a day testing, trying and crying I decided to extend the JRJdtCompiler and override the method compileUnits. there I will use the batch compiler org.eclipse.jdt.internal.compiler.batch.Main like in the test linked above. When I've finished the work I will post what to do to get it running...
问题:
JasperReports的进口java.awt.GraphicsEnvironment其中进口sun.java2d - >这是原产code =>同样的问题,像上面的XML解析...
PROBLEM: JasperReports imports java.awt.GraphicsEnvironment which imports sun.java2d -> which is native code => same problem like parsing from xml above...
结论:
它是否会在Android上工作,还有很多工作要做,一些本地库港口。对于我来说,这不适合,我会回落到使用iText的创建PDF文件。
conclusion: If it will work on android there is a lot of work to be done and some native libs to port. For me that's not suitable and i will fall back to use iText to create the PDFs.
或许在某个时候谷歌将supoort AWT的包,但我不相信它。
Perhaps in sometime Google will supoort the awt package, but i don't believe it.
反正我已经做了所有的工作是非生产性的,但很有趣,因为这是我的第一个Android项目,我学到了很多东西,我可以希望使用其他时间:)
Anyway: all work I've done was unproductive but very interesting because this is my first android project and I learned much which I can hopefully use another time :)
这篇关于Android的碧玉报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!