<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>moopoo.net &#187; export</title>
	<atom:link href="http://moopoo.net/tag/export/feed/" rel="self" type="application/rss+xml" />
	<link>http://moopoo.net</link>
	<description>Fishing, technology and anything else</description>
	<lastBuildDate>Fri, 09 Dec 2011 11:04:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Exporting Crystal Reports from the web.</title>
		<link>http://moopoo.net/web-development/exporting-crystal-reports-from-the-web/</link>
		<comments>http://moopoo.net/web-development/exporting-crystal-reports-from-the-web/#comments</comments>
		<pubDate>Tue, 23 Oct 2007 08:27:22 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[crystal reports]]></category>
		<category><![CDATA[export]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://moopoo.net/blog/2007/10/23/exporting-crystal-reports-from-the-web/</guid>
		<description><![CDATA[Exporting Crystal Reports from a report displayed in the browser can be a pain, not least because it&#8217;s long winded, but also that I primarily use Firefox and the report rendering in anything other than IE is a joke. For a while I have been trying to work out how I could export Crystal Reports [...]]]></description>
			<content:encoded><![CDATA[<p>Exporting Crystal Reports from a report displayed in the browser can be a pain, not least because it&#8217;s long winded, but also that I primarily use Firefox and the report rendering in anything other than IE is a joke.</p>
<p>For a while I have been trying to work out how I could export Crystal Reports in various formats such as Excel and PDF without having to render the report in the web browser first. Some of our customers wanted the data to put into their spreadsheet application so they could manipulate the data to their hearts content and I wanted to still use the power of Crystal Reports as it meant that the people who are good at writing the reports could do it and save me the work.</p>
<p>I&#8217;d seen it done in Crystal 8 but had not seen anything that pulled it all together in XI. I think I was looking a little too hard, the solution was in fact pretty straight forward.</p>
<p>The method employed is pretty similar to the post I made on displaying Crystal Reports in the browser, with only a couple of exceptions.</p>
<p>Firstly, you don&#8217;t need to employ the ReportViewer control as the report is not being rendered to the browser.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">// Declare variables</span>
<span style="color: #0600FF;">private</span> ReportDocument document1 <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> ReportDocument<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">private</span> TableLogOnInfos infos1 <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> TableLogOnInfos<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">private</span> TableLogOnInfo info2 <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> TableLogOnInfo<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">private</span> ConnectionInfo info1 <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> ConnectionInfo<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">//  default export type</span>
ExportFormatType expFormat <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> ExportFormatType<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
expFormat <span style="color: #008000;">=</span> ExportFormatType.<span style="color: #0000FF;">PortableDocFormat</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">// load the report</span>
document1.<span style="color: #0000FF;">Load</span><span style="color: #000000;">&#40;</span>Request.<span style="color: #0000FF;">PhysicalApplicationPath</span> <span style="color: #008000;">+</span> “myReport.<span style="color: #0000FF;">rpt</span>”<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">// Add the parameters</span>
document1.<span style="color: #0000FF;">SetParameterValue</span><span style="color: #000000;">&#40;</span>“param1″, “value1″<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
document1.<span style="color: #0000FF;">SetParameterValue</span><span style="color: #000000;">&#40;</span>“param2″, “value2″<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">//Set the login info for the database</span>
info1.<span style="color: #0000FF;">ServerName</span> <span style="color: #008000;">=</span> ConfigurationSettings.<span style="color: #0000FF;">AppSettings</span><span style="color: #000000;">&#91;</span>“server_name”<span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
info1.<span style="color: #0000FF;">DatabaseName</span> <span style="color: #008000;">=</span> ConfigurationSettings.<span style="color: #0000FF;">AppSettings</span><span style="color: #000000;">&#91;</span>“database_name”<span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
info1.<span style="color: #0000FF;">UserID</span> <span style="color: #008000;">=</span> ConfigurationSettings.<span style="color: #0000FF;">AppSettings</span><span style="color: #000000;">&#91;</span>“user_id”<span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
info1.<span style="color: #0000FF;">Password</span> <span style="color: #008000;">=</span> ConfigurationSettings.<span style="color: #0000FF;">AppSettings</span><span style="color: #000000;">&#91;</span>“password”<span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
Tables tables1 <span style="color: #008000;">=</span> document1.<span style="color: #0000FF;">Database</span>.<span style="color: #0000FF;">Tables</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">//Apply login info to the report</span>
<span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span>CrystalDecisions.<span style="color: #0000FF;">CrystalReports</span>.<span style="color: #0000FF;">Engine</span>.<span style="color: #0000FF;">Table</span> table1 <span style="color: #0600FF;">in</span> tables1<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    info2 <span style="color: #008000;">=</span> table1.<span style="color: #0000FF;">LogOnInfo</span><span style="color: #008000;">;</span>
    info2.<span style="color: #0000FF;">ConnectionInfo</span> <span style="color: #008000;">=</span> info1<span style="color: #008000;">;</span>
    table1.<span style="color: #0000FF;">ApplyLogOnInfo</span><span style="color: #000000;">&#40;</span>info2<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">// Export the document</span>
HttpResponse Response <span style="color: #008000;">=</span> HttpContext.<span style="color: #0000FF;">Current</span>.<span style="color: #0000FF;">Response</span><span style="color: #008000;">;</span>
document1.<span style="color: #0000FF;">ExportToHttpResponse</span><span style="color: #000000;">&#40;</span>expFormat,Response,<span style="color: #0600FF;">true</span>,”Exported Report”<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
document1.<span style="color: #0000FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://moopoo.net/web-development/exporting-crystal-reports-from-the-web/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

