I have a problem with exporting rpt file to excel,
My requirement is to:
Display page numbers when printing from a Crystal Report (rpt) file and
Suppress the page number when exporting this to excel,
I am having trouble with the suppression and need help.
One way you can achieved by creating a static parameter as ExportFormat and put two value as 'default' and another one 'excel'..
Then add this parameter to your report with any string field notequalto the parameter..
finally in the PageNumber field in the suppress put this formula
if {?ExportFormat} = 'excel' then true else false
When ever user want to export to excel select "excel" if user want to view in crystal or any other export format select default..So that page number will suppress only when user select export format as 'excel'...
Related
I'm creating a jasper report using iReports 5.2.0 and I want to display the report file name in it.
Can't find any variable that has that information and I would like to get an alternative to pass it in the parameters.
How can I do it?
When you design your report, make a new PARAMETER named, for instance: NAME_REPORT.
After that, put a TextField in your report, for example, in your Title section, and
put as value of your TextField the parameter like a expression: $P{NAME_REPORT}
When you preview your report, ask you to give a value to this parameter and then, you see the title with the name
of your report file.
In your java code you will do somethink like that:
parameters.put("NAME_REPORT", "myreport.jrxml");
.....
JasperFillManager.fillReport(report, parameters, connection)
.....
I have a report containing some sub reports and in my main report i am showing the sub reports based on scan mode and status coming from query.
Now i need to show a message whenever sub reports don't have data.
I tried like this.
checked supress blank sub report and supress blank section for all reports.
1.Kept a text box in report footer of main report.
2.Took a field (Say Barcode) from sub report and passed to main report using shared variable.
3.In section expert of text box wrote like this.
not isnull(Barcode)
But it is not working.
Please suggest.
If I have understood this correctly the code below should work. Tip, avoid using NOT ISNULL. If possible just change the outcome order of your IF statement as below.
To make your formula more robust also, it's a great idea to add in the:
OR = ""
To account for any blank entries.
Final code:
IF Isnull({Barcode}) OR {Barcode} = "" THEN FALSE ELSE TRUE
I am using the Crystal Reports 2011 designer just to test it out. I need to be able to hide certain components, e.g. a sub-report, when exporting to different formats like Excel or .pdf. I'm guessing this can be achieved through the Suppress field with a formula, but I can't find the right syntax. Needs to be something like this:
If ExportFormat="Excel" then Suppress
Else if ExportFormat="PDF" then Show
It doesn't seem like there is a variable to represent the ExportFormat type when using expressions in Crystal Reports.
It is possible to overcome this problem by setting a parameter programmatically during an export event i.e. create a parameter #ExportFormat and during the export event set this parameter depending on the type of export e.g. if the export taking place is to Excel, set #ExportFormat="Excel". Then the following expression can be used to suppress a control:
{?#ExportFormat}='Excel'
You got it almost completely right:
If ExportFormat='Excel' then TRUE
Else if ExportFormat='PDF' then FALSE
This formula goes into the suppress formula. (You need to click this small button with the "x-2" and pencil on it...)
Trying to export a report to excel, the generated document has kind of page break. The column header is repeated. The "page break" are in the same positition than if I generate a PDF report.
How can I remove this page break when exporting to excel? Is there some page size definition?
Have you tried ExportFormatType.ExcelRecord instead of ExportFormatType.Excel? The xls file will be created without formatting.
If actually the user is exporting report using ReportViewer Toolbar Export button you can:
Replace the CrystalReportViewer Control with the ReportExporter Control. It will export the report in the format you choose.
Or hide Export button from toolbar and put in the page buttons that exports programmatically
Call ExportToHttpResponse method
CrystalReportSource1.ReportDocument.ExportToHttpResponse(ExportFormatType.ExcelRecord, this.Response , false, "report.xls");
Call ExportToDisk method
reportDocument.ExportToDisk(ExportFormatType.ExcelRecord, "report.xls");
Export dataset to excel (Look at Ahmed answer)
You can choose the way that best fits your needs, but you must try if it works with the runtime you use either in development or in release server.
ExportFormatType.ExcelRecord means that is generated an xls file, without formatting. If you set ExportFormatType.Excel fields that are marked as "Can Grow" are merged with an otherwise blank row below them.
I am working on crystal report, i need to pass value(from Winforms) to crystal report
Textbox control's like Period:10-11-2009 To 13-11-20009 this value I want pass for crystal report textbox control
advance wishes...
see this link it shows how to pass parametar to crystal report.There are many more examples for this just ask google
link to an example
You can pass values to crystal using parameters. Then you can display these in the reports.
See the code below
//Initialize your report
sample_report yourReport = new sample_report();
CrystalDecisions.CrystalReports.Engine.TextObject variableName=
(CrystalDecisions.CrystalReports.Engine.TextObject)
yourReport.Section2.ReportObjects["nameoftheTextboxInyourReport"];
variableName.Text = "Period:10-11-2009 To 13-11-20009";
You can add the from date and to date in the details or header column that you are passing through the data source to the crystal report .. drag those fields from the field explorer and put them into the text field
Just use parameters and pass the Textbox value :
Example in VB.NET :
Dim rptList As ReportDocument = New ReportDocument()
With rptList
.Load(strPath)
.SetDataSource(dtsData)
rptList.SetParameterValue("SomeName", yourTextBox.Text.trim)
End With
strPath is the path to your .rpt file and dtsData is the dataset.
in SetParameterValue define a name and value, just notice that you should create a parameter with the same name in your crystal report.
' txtName = textbox name in crystal report
' txtValue = text value to be passed to report
Dim objText As CrystalDecisions.CrystalReports.Engine.TextObject =RtpDocument.ReportDefinition.Sections(1).ReportObjects(txtName)
objText.Text = txtValue
CrystalReportViewer1.ReportSource = RtpDocument