Create a "fake" file to pass in to Crystal Report API - crystal-reports

Attempting to create a PDF from a Crystal Report file in C# using the Crystal Report API (version 13) - The API requires that the Crystal Report file be passed in as a file. I currently have the report as a memory stream and would prefer to not save it to a file, use it, then delete the file when done.
Is there any way to "fake" sending a file without creating an actual file? (Parameter it requires is a filename.)
This application runs on a server in the cloud and will have multiple instances and other things that make me not want to try to deal with permissions and file structure and things like that that may crop up when creating a "real" file.
Thanks for your help!

Of course not. If it's expecting a filename as a parameter, it's using OpenFile() or the equivalent to open a physical file on disk. How do you fake it?
Every OS I've ever worked with has a mechanism for getting a temporary filename; in .NET, you can use System.IO.Path.GetTempFileName for exactly this sort of purpose.

Related

How can i browse file without uploading in GXT?

i'm beginner with GXT and i'm wondering if there is a way to parse a file and extract some informations without uploading it.
i created a formpanel that contains an uploadFile form but i don't know waht's next, how to get the complete path of the file so i can read/write with java io or how to retrieve the file or is there an alternatif solution, thank you.
Best Regards.
You can do it in some modern browsers using bleeding edge HTML5 apis for which you would need to use GWT JSNI code. There are no api's from GWT team as is.
HTML5 FileReader
FileReader includes four options for reading a file, asynchronously:
FileReader.readAsBinaryString(Blob|File) - The result property will contain the file/blob's data as a binary string.
FileReader.readAsText(Blob|File, opt_encoding) - The result property will contain the file/blob's data as a text string.
FileReader.readAsDataURL(Blob|File) - The result property will contain the file/blob's data encoded as a data URL.
FileReader.readAsArrayBuffer(Blob|File) - The result property will contain the file/blob's data as an ArrayBuffer object.
Example of GWT wrapper over these -
https://github.com/bradrydzewski/gwt-filesystem
You can read about it more from here - How to retrieve file from GWT FileUpload component?
IMHO you cannot read it .
Due to security reasons javascript(gwt) doesn't have access to the system drives files.
http://en.wikipedia.org/wiki/JavaScript#Security
see Opening a file in local file system in javascript
In order to get the file you need to make a server call.
Instead you can do your validation server side and throw proper messages to user.
P.S : i am not considering modern browser concept.What happens if someone opened in other than so called modern browsers?? Will the programm runs same?? Its always better to do server side validation..

Report generation in web applications

As part of my web application, i am using iReport tool to generate reports and its working fine but my doubt is, is it possible to generate xls type report in browser like pdf (we can show the pdf file in the browser)? Means I need to show reports in xls file or word document in the client machine, is it possible? Can anybody clear my doubt?
Although it is a bit late, I'll try to give a generic answer
you can fetch your data to your local Jasper Reports server via JSON.
There is a sample of JsonDataSource in the 4.5.0 version of jasperreports at *\demo\samples\jsondatasource
to run report and receive output pdf, etc. you can use REST API for Jasper Server
then you send output to end user

running a script from within crystal reports

I have an application that creates a report using crystal reports. The data for the report is created in db tables that are built on the fly and then deleted after the report has been created. I would like to save the database that create the report.
I have access to the reports, so I was wondering if it is possible to embed a script in the crystal report that would run when the report is created and move the data to another location, such as via a batch script.
Can anyone tell me if this can or cannot be done? Thanks for any thoughts.
Try this. In the .rpt, go to Database Export and Add Command as shown below.
I don't know what the proper SQL syntax is (the query in the sample image threw an error), but once you work it out, you could probably do it this way. This example from Business Objects uses this command as part of a larger question.
(However, since the original DB is immediately deleted, you'll have to specify a new database to put the table in. I don't know if that's possible.)

create jrxml file at run time and modify at run time

I have a requirement to develop custom reports where we already have some reoprts developed using JasperReports using iReport tool. Now the requirement is to modify those reports design at run time. I should use those existing jrxml files and save as to new report then change the design at run time. Also I should see those newly created reports whenever I want.
I have gone through the Jasper API and Dynamic Reports where we can create the reports dynamically at run time but we can't save the design (like JRXML).
I am looking for any other JRXML design API to create and modify and save the Jasper Reports at run time.
I appreciate if any one can help me.
Thanks in Advance
Srinivas
It seems DynamicJasper can do this.
First thing you will need to draw a flow chart of how you want to do things.
For example, if the report already exists, and you want it as is, what will you do?
In case you want to modify it a little, do you want to save as jrxml and compile each time?
Or do you want to compile to jasper, store on local storage then populate later.
It seems you want to build a reporting engine and answering all those questions is basic. In that case here is something to start from.
Find a factory called DocumentBuilderFactory which will help you parse the XML into DOM object, modify then save it.
Here is a good tutorial on using it

Changing Crystal Reports reports shipped with an application and a runtime version

We have a purchased application (I'm told it's .NET, it's client server, running on Windows XP, connecting to SQL Server 2005) that uses a Crystal Reports runtime and separate report files (.rpt) to do it's reporting function. I have a copy of the CR Designer program but we don't have the CR Enterprise software. I can open the reports in the designer, get to the SQL Server data source (and any others, I guess), add them to the report, run it, print it -- but I can't figure out how to use the same Datasource, which is a subset of the tables in the database that it's connecting to, to do it, and I can't figure out how to save the report files so they'll work with the application. Real gravy would be coming up with new reports.
Is this even possible?
If you open up the report and then go to Database, Set Datasource Location, under the Properties section you will find a lot of info about the datasource and where it is getting it's info from. If the purchased application is creating its own datasource internally though and supplying it to the report at runtime, the best option that I can think of is to start a trace on the SQL Server and then run a report. You should be able to see the SQL that is issued by the Datasource and replicate it in your own version.
You have the possibility to manage your connection's properties at runtime (ie while launching CR from your app). Here is a proposal: Crystal Reports Datasource remap
If you cannot access your app code, you should then do as proposed by #Anthony, by updating all your connection strings in your rpt files, save the rpt files, and copy then on the corresponding report folder of your app: you might have to find where it's located in your system.
First of all, you'd better make sure you're not violating the application's license agreement by attempting to add to it in this way.
It may simply not be possible to add reports to the app in any case - it depends how it loads them and what it does with them.
To use the same datasource, you should just be able to open one of the .rpt files, then go to File > Save As, and give it a new name. Then modify it to what you want. Of course, if you don't know the authentication credentials the app passes to the report to connect, it would be tricky to test it.
It would help greatly if you gave us the name of the purchased application, as we don't really know what you're up against.
It could be that the application is passing through a filter of the data. So when you run the report from Crystal Reports Designer you get the whole data base, however when run through the program the parameters being passed to the report restrict the data back down.
Create a backup of the report. Then edit the existing report, make the changes you require, preview the report to get an idea it looks right, save the report and run the report via the application.
Warning:
As it has already been stated some vendors may not allow you to edit existing reports, your warranty/sport may be voided by editing existing reports, or reports could even be overwritten on the next update.