blank page in codeigniter when working with jasper - codeigniter-3

I have am trying to generate jasper report using CI.
The report when called from the controller keeps on
showing blank page with only the query I have used in jasper ireport design page . Which is 'select * from books'.
The function called to call the report is :getReport()
public function getReport(){
$xml = simplexml_load_file(APPPATH .'report/report1.jrxml');
$jasperXmlObj = new PHPJasperXML();
$jasperXmlObj ->debugsql=true;
$jasperXmlObj ->arrayParameter=array("parameter1"=>1);
$jasperXmlObj ->xml_dismantle($xml); $jasperXmlObj->transferDBtoArray('localhost','root','','db_emergency');
$jasperXmlObj ->outpage("I");
}
I expect a report in pdf format .

Related

combine multiple reports in crystal reports in c#

I have designed a crystalReport(myReport.rpt) that is connected to data base without any problem. What I want is to create a report including multiple of this report...!
For example creating a 3-pages report that each page is built by myReport.rpt but with different values...
In fact I want to create some objects from my report class and then combine all of them to be one report and I print that or make pdf from that...
Example:
myReport rpt1= new myReport(); //(some changes in rpt1's fields):
(TextObject)rpt1.ReportDefinition.ReportObjects["time"]).Text=getTime();
((TextObject)rpt1.ReportDefinition.ReportObjects["date"]).Text =getDate();
// or any other changes in fileds
myReport rpt2= new myReport(); //(some changes in rpt2's fields):
(TextObject)rpt2.ReportDefinition.ReportObjects["time"]).Text = getTime();
((TextObject)rpt2.ReportDefinition.ReportObjects["date"]).Text = getDate();
// or any other changes in fileds...
myReport rpt3= new myReport(); //(some changes in rpt3's fields):
(TextObject)rpt3.ReportDefinition.ReportObjects["time"]).Text = getTime();
((TextObject)rpt3.ReportDefinition.ReportObjects["date"]).Text = getDate();
// or any other changes in fileds...
and I want something like this:
CrystalDecisions.CrystalReports.Engine.ReportDocument totalReport=new CrystalDecisions.CrystalReports.Engine.ReportDocument();
totalReport=merge(rpt1,rpt2,rpt3);
totalReport.PrintToPrinter(1, ture, 1, 1);
Thank you for your helping...
I'm using:
VS 2012 & Crystal Reports 13

how to export a jasper report with bar chart to a html file

This question is in reference of generated jasper report is not showing bar chart
I m exporting a report built in jasper reports with bar chart (template report5.jrxml) to a html file.
Code:
public showReport() throws JRException{
...
InputStream reportStream = this.getClass().getResourceAsStream("/report5.jrxml");
JRDataSource dataSource = new JRBeanCollectionDataSource(reportData);
HashMap params = new HashMap();
params.put("Title", "Report");
JasperDesign jd = JRXmlLoader.load(reportStream);
JasperReport jr = JasperCompileManager.compileReport(jd);
JasperPrint jp = JasperFillManager.fillReport(jr, params, dataSource);
JRHtmlExporter exporter = new JRHtmlExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
//EXPORTING REPORT TO A FILE "myreport.html"
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, "E:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps/mywebapp/WEB-INF/jsps/reports/reportsOutput/myreport.html");
exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, false);
exporter.setParameter(JRHtmlExporterParameter.IMAGES_DIR_NAME , "E:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps/mywebapp/WEB-INF/jsps/reports/reportsOutput/myreport.html_files"); exporter.setParameter(JRHtmlExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, true);
exporter.exportReport();
}
The generated report in output html file (myreport.html) shows text but does not show any chart.Though there is folder (myreport.html_files) generated by jasper reports API next to the output file which contains chart images.
Why generated html is not showing any chart images?

SAP Crystal Report Visual Studio 2010

How can the parameter prompt in SAP Crystal Report be disabled? I'm using Visual Studio 2010.
My Code is:
{
NPB.Report.CrLetter objCrLetter = new NPB.Report.CrLetter();
NPB.Report.frmViewer objView = new NPB.Report.frmViewer();
private void btnGenerateLetters_Click(object sender, EventArgs e)
{
objCrLetter.ParameterFields["LetterDate"].DefaultValues.AddValue(dtpLetterDate.Value.ToShortTimeString());
objCrLetter.ParameterFields["Salutation"].DefaultValues.AddValue(cboboxSalutation.Text);
objCrLetter.ParameterFields["Address"].DefaultValues.AddValue("2");
objCrLetter.ParameterFields["City"].DefaultValues.AddValue("3");
objCrLetter.ParameterFields["State"].DefaultValues.AddValue("4");
objCrLetter.ParameterFields["ZipCode"].DefaultValues.AddValue("5");
objView.crViewer.ReportSource = objCrLetter;
objView.Show();
}
}
I would probably change your code so that for each Parameter in the Crystal Report would clear the current & default values then pass in the correct value.
So you need to do something like this for each parameter:
ParameterDiscreteValue paramDV = new ParameterDiscreteValue();
paramDV.Value = "Parameter Value";
objCrLetter.ParameterFields["#ParameterName"].CurrentValues.Clear();
objCrLetter.ParameterFields["#ParameterName"].DefaultValues.Clear();
objCrLetter.ParameterFields["#ParameterName"].CurrentValues.Add(paramDV);
This should prevent the Parameter Prompt from appearing.
This answers are almost perfect, but, You should pay attention to the when setting de data source.
This setting should happens before you set the parameters.

Crystal Report on C#

Well I have a Cyrstal report which has 4 sub reports on and it is linked through an ItemID column and a Culture, so it has a parameter value "?Pm-ItemID" and "?Pm-Culture" now i'm using DataSet to load the data to the Crystal Report's datasource, when I run the report its giving me an error which was an asking parameter field was not suplied, so i think my question would be what am I going to pass to those ParameterFields?
here's an idea.
ReportDocument myreport = new ReportDocument();
myreport.Load("C:\MyReport.rpt");
DataSet ds = GenerateReportData();
myreport.SetDataSource(ds);
//Loop through each to Load the DataSet
for (int i = 0; i < myreport.Subreports.Count; i++)
{
ReportDocument subreport = myreport.SubReports[i];
DataSet subds = GenerateReportData(subreport.name)
subreport.SetDataSource(subds);
}
//I can see that there's a parameterfields in myreport.ParameterFields
//As I look through inside it there are 8 ParameterFields repeating Pm-ItemID and Pm-Culture
foreach (ParameterField pf in myreport.ParameterFields)
{
myreport.SetParameterValue(pf.Name, Value???);
}
Well, I see what's wrong.
ReportDocument subreport = myreport.SubReports[i];
DataSet subds = GenerateReportData(subreport.name)
subreport.SetDataSource(subds);
should not be done this way, it should be
DataSet subds = GenerateReportData(subreport.name)
myreport.SubReports[i].SetDataSource(subds);
I don't know about Crystal, but in SSRS it works like this:
1) create a subreport and create some parameters
2) create the main report, put there the subreport and in the properties you can specify what to bind to the subreport's parameters
Conclusion: I don't think this is supposed to be set in code, rather report designer.

how do you set the default export name in the crystal report viewer

On an ASP.NET page, when a user is viewing a report from the Crystal Report Viewer(CRV) they have the ability to export the report (eg to PDF). The default filename for the export is the ID of the CRV.
I would like to set the default name to be something that is based on the parameters of the report. (eg "Sales for 2008").
I know I can add a link to the page that would and then I could code up a solution where I generated the PDF in code and the stream it to the browser, but I was hoping there might be a way to do this nativity in Crystal Reports.
// You could pass the parameters to the web page
// where you have theCrystalReportViewer control
protected void Page_Load(object sender, EventArgs e)
{
string reportId = Request["rid"];
string reportTitle = Request["rtitle"];
ReportDocument reportDocument = HttpContext.Current.Session[reportId] as ReportDocument;
this.CommonCrystalReportViewer.ReportSource = reportDocument;
this.CommonCrystalReportViewer.DataBind();
// Set the default export file name for the report.
this.CommonCrystalReportViewer.ID = reportTitle;
}
If you are using Visual Studio 2008 to create the report you could edit the ReportClass created to add your DefaultName property.
Natively there was a ReportExporter class to be used instead of ReportViewer class but it's not supported anymore. There are some third-parts similar.
I use this code samples:
Get parameters value from report (if you don't have already from Session, QueryString or somewhere else)
string myParamName="XXX";
object myParamValue;
foreach (ParameterField field in reportDocument.ParameterFields)
{
if (string.Compare(field.Name.TrimStart('#'), myParamName, true) == 0)
myParamValue= field.CurrentValues;
}
Export using report name needed
string myReportName = "sales for " + myParamValue.ToString() + ".pdf";
try
{
reportDocument.ExportToHttpResponse(
ExportFormatType.PortableDocFormat
,Response, true, myReportName);
}
catch (System.Threading.ThreadAbortException)
{
//System.Threading.ThreadAbortException is thrown
//because, Response.End is called internally in ExportToHttpResponse method:
}
protected void Page_Init(object sender, EventArgs e) {
...
// Set the default export file name for the report.
this.mainReportViewer.ID = reportTitle;
...
}
It is mandatory to change reportViewer id in Page_Init function, otherwise will not work.