I use CrystalReports 13 (13.0.2000.0) in an ASP.NET 4.0 application.
I need to export report in HTML because i want a static report page, without reporviewer that allows user interaction.
If i try the following code:
Source1.ReportDocument.ExportToHttpResponse(
CrystalDecisions.Shared.ExportFormatType.HTML32 /*or HTML40*/
, this.Response , false, "report");
Application generates an error (Detail: Export in HTTP response in HTML format is not supported.)
If i try ReportExporter, HTML32 and HTML40 are not available ase ExportFormat.
Can someone help?
Report can be viewed in HTML as
MemoryStream oStream; // using System.IO
oStream = (MemoryStream)
rd.ExportToStream(
CrystalDecisions.Shared.ExportFormatType.HTML40);
Response.Clear();
Response.Buffer = true;
Response.ContentType = "text/html";
Response.BinaryWrite(oStream.ToArray());
Response.End();
But the format may suffer.
Reference: How to Export Crystal Report in ASP.NET
Because you marked it up I thought I'd upgrade it to an answer for closure and the rep:
you could save the html document to disk and then use a redirect to that as a workaround but I can't find any other way of doing it. if you are going to do it that way make sure you add uniqueness to the fime name (I find datetime is a useful string) to support concurrency,
MD
Would pdf help (the examples that I have seen use pdf export)? if so that is easy to do but does require that your users have acrobat reader installed. From the error it seems that exporting to an http response in html format was not implemented at release but there may be a patch to fix it so try patching to latest version,
MD
Related
I use "Filedownload.save" to download files with Zk, but i have a problem.
Zk cut my filenames in some characters, for example, if the linema is "FISH#CHIPS.pdf", the file dowload as "FISH.pdf"
Anyone knows how to solve it?
UPDATE:
I have follow the instructions, and i finally see that the server response this JSON:
{"rs":[["download",["/myApp/zkau/view/z_aq5/dwnmed-3/son/FISH#CHIPS.pdf"]]],"rid":9}
And i am lost now, what do Zk with this JSON on the cliente side?
The official ZK-Bug is tracked as ZK-3809
A server side workaround is the following:
split download code such as ...
Filedownload.save("test content", "text/plain", "test#test.txt");
... into ...
AMedia media = new AMedia("test#test.txt", "txt", "text/plain", "test content");
Clients.response(new AuDownload((DeferredValue) () ->
Executions.getCurrent().getDesktop().getDownloadMediaURI(
media, "test#test.txt").replace("#", "%23")));
... allowing to encode special chars as needed.
UPDATE: ZK-3809 has been fixed and will be included in ZK version 8.5.1
The problem is that # is one of those "reserved characters" that, while valid in a URL, are treated in special ways. Look at this question for more details. My guess is that everything after the # is interpreted as a fragment on the page, and hence ignored in this case.
There are ways to fix this, for example by replacing # by %23. But doing this on the server side when calling Filedownload.save changes the filename to literally FISH%23CHIPS.pdf.
Instead, we can intercept the client side method that downloads the file when the response you showed arrives. This way, zk will still give the file its normal name, and only the download will sanitize the URL. Add this to a script tag or loaded js file:
zk.afterLoad('zk', function() {
var oldMethod = zAu.cmd0.download;
zAu.cmd0.download = function(filename) {
return oldMethod(filename.replace(new RegExp('#', 'g'), '%23'));
}
});
Then it will download the file with the complete name. You might want to take the extra time and sanitize the other reserved characters as well. Read this wiki article about "percent encoding" for the right codes.
I have also filed a support ticket with zk, I think this should be handled by the client side method out-of-the-box.
I have to code a PHP front end for my Jasper reports. I could successfully connect to the server, authenticate and view the repositories using the jasper REST calls. However, when I try to access a report, I get the following error in the response body:
Report not found (uuid not found in session)
The php code is given below:
$uri = "http://localhost:8080/jasperserver/rest/report/samples/Client_Information_Report?RUN_OUTPUT_FORMAT=html";
//PUT request to run the report
$response = Httpful\Request::put($uri, $payload)
->authenticateWith("jasperadmin", "jasperadmin")
->send();
$xml = new SimpleXMLElement($response->body);
$uuid = (String)$xml->uuid; //The uuid is successfully returned
$uri = "http://localhost:8080/jasperserver/rest/report/$uuid?file=report";
$report = Httpful\Request::get($uri)
->authenticateWith("jasperadmin", "jasperadmin")
->send();
I am able to confirm that a uuid is returned with the first PUT. Is there anything I am missing here? Any help is appreciated.
Janenz,
First check the info that is coming from the PUT response to see if there is actually a report being generated and that is not empty, you should receive something like this:
<report>
<uuid>d7bf6c9-9077-41f7-a2d4-8682e74b637e</uuid>
<originalUri>/reports/samples/AllAccounts</originalUri>
<totalPages>43</totalPages>
<startPage>1</startPage>
<endPage>43</endPage>
<file type="image/png">img_0_0_0</file>
<file type="image/gif">px</file>
<file type="text/html">report</file>
<file type="image/jpeg">img_0_42_27</file>
<file type="image/png">img_0_42_26</file>
</report>
Notice the number of pages and the files available.
I have not used the Httpful library, but another thing to check is the way that library uses the Basic Authentication. It may happen that the second call is logging you in again and creating a new session; that is why you cannot find the UUID of the current session.
I have a full JasperServer and PHP sample in GitHub that you can check, it has the repository browsing and input control rendering implemented.
I'm not sure what version of JasperReports Server you are using but in the new version there is a new REST API that makes requesting reports a lot easier; check the JasperReports Server Web Services Guide (Section 3.2). I have that implemented in the JRS-Wrapper Branch of my project.
Hope this helps!!
MarianoL
We need to access a sharepoint 2007 site from javascript. Basically we need to use the search.asmx service but since that does not support rest nor jsonp it can't be used directly.
The original plan was to make custom wcf service with support for rest and jsonp. This was a small undertaking but when I gave the service to the Sharepoint guys none of them could package it to a wsp package for installation in sharepoint 2007 and get it working.
According to this question Rest Webservices for Sharepoint 2007 this might not be so easy and a httpmodule is required for rest-typed urls. The other idea about running it as a standalone app might not be enough since I think that the service needs access to SPContext.
Would it be possible to just create an Application Page and there in the code behind override Render, clear the output buffer, change mime type and render the json-serialized data? So the url would be http://spsite/mycustomquery.aspx?q=mysearchtext&start=0&count=200&callback=mycallbackfunction.
An application page would at least support Get but does it have access to SPContext?
Here is the wcf service I started with.
Contract
[ServiceContract]
public interface IRestSPQuery
{
[OperationContract]
[WebGet(UriTemplate = "query/{queryText}/{startAt}/{count}?callback={callback}", ResponseFormat = WebMessageFormat.Json)]
[JSONPBehavior(callback = "callback")]
ResultTable Query(string queryText, string startAt, string count, string callback);
}
Implementation
public ResultTable Query(string queryText, string startAt, string count, string callback)
{
//http://sharepointsite/_vit_bin/CustomQuery/RestSPQuery.svc/Query/searchtext/0/200?callback=myfunction
KeywordQuery keywordQuery = new KeywordQuery(SPContext.Current.Site);
keywordQuery.StartRow = startAt;
keywordQuery.RowLimit = count;
keywordQuery.SortList.Add("Rank", SortDirection.Descending);
keywordQuery.QueryText = queryText;
ResultTableCollection searchResults = keywordQuery.Execute();
ResultTable relevantResultsTable = searchResults[ResultType.RelevantResults];
return relevantResultsTable;
}
You could try adding an ".ashx" file to your solution that implements IHttpHandler. According to this blog article you can do it by adding an Application Page to your solution but save it as a ".ashx" extension. The article is written for SharePoint 2010 but you will have to check if it works for 2007. Following the rest of the article you should be able to set it up for REST/JSONP.
I ended up creating a custom aspx page and override the Render method and there output json/jsonp and also change the content type to application/json.
The solution and a ready to deploy wsp-file can be found here http://www.filedropper.com/restqueryservice.
I'm testing out the new API, but having no luck downloading a test image file. The file exists, is accessible through the web UI, and is retrievable using the v1.0 API.
I'm able to access the metadata ("https://api.box.com/2.0/files/{fileid}") using both commandline curl and pycurl. However, calls to "https://api.box.com/2.0/files/{fileid}/data" bring back nothing. An earlier post (5/1) received the answer that the download feature had a bug and that "https://www.box.com" should be used as the base URL in the interim. That, however, just provokes a 404.
Please advise.
You should be able to download via http://api.box.com/2.0/files/<fildID>/content ... Looks like we have a bug somewhere in the backend. Hope to have it fixed soon.
Update 11/13/2012 -- This got fixed at least a month ago. Just updated the URL to our newer format
For me it works when its /content instead of /data... python code below
import requests
fileid = str(get_file_id(filenumber))
url = https://api.box.com/2.0/files/1790744170/content
r = requests.get(url=url, headers=<HEADERS>, proxies=<PROXIES>)
infoprint("Downloading...")
filerecieved = r.content
filename = uni_get_id(fileid, "name", "file")
f = open(filename, 'w+')
infoprint("Writing...")
f.write(filerecieved)
f.close()
I am trying to use HTTP to POST a file to an outside API from within a grails service. I've installed the rest plugin and I'm using code like the following:
def theFile = new File("/tmp/blah.txt")
def postBody = [myFile: theFile, foo:'bar']
withHttp(uri: "http://picard:8080/breeze/project/acceptFile") {
def html = post(body: postBody, requestContentType: URLENC)
}
The post works, however, the 'myFile' param appears to be a string rather than an actual file. I have not had any success trying to google for things like "how to post a file in grails" since most of the results end up dealing with handling an uploaded file from a form.
I think I'm using the right requestContentType, but I might have missed something in the documentation.
POSTing a file is not as simple as what you have included in your question (sadly). Also, it depends on what the API you are calling is expecting, e.g. some API expect files as base64 encoded text, while others accept them as mime-multipart.
Since you are using the rest plugin, as far as I can recall it uses the Apache HttpClient, I think this link should provide enough info to get you started (assuming you are dealing with mime-multipart). It shouldn't be too hard to change it around to work with your API and perhaps make it a bit 'groovy-ier'