Databases Reference
In-Depth Information
The Render method of the ReportingService object passes back a byte array that can be used in a number
of ways. For the web, you will write this information directly back to the HTTP Response object. Before you
write back the data though, you need to set some information about the report, namely, the report MIME
type and a filename. You will start by assembling a filename for the report. To do this, you use the name of
the report followed by an extension that you determine using the value returned in the MIME type
parameter. Following is a sample function for determining a file extension based on the MIME type. There
are a number of MIME types that can be passed back from Reporting Services that are not shown here, so
you might want to add more code to this function for your application needs.
C#
string GetExtension(string mimeType)
{
string retVal=””;
switch(mimeType)
{
case “text/html”: //HTML3.2, HTML4.0
retVal = “html”;
break;
case “multipart/related”: //MHTML
retVal = “html”;
break;
case “text/xml”: //XML
retVal = “xml”;
break;
case “text/plain”: //CSV
retVal = “csv”;
break;
case “image/tiff”: //IMAGE
retVal = “tif”;
break;
case “application/pdf”: //PDF
retVal = “pdf”;
break;
case “application/vnd.ms-excel”: //EXCEL
retVal = “xls”;
break;
}
VB
Public Function GetExtension(ByVal mimeType As String) As String
Dim retVal As String
Select Case mimeType
Case “text/html” 'HTML3.2, HTML4.0
retVal = “html”
Case “multipart/related” 'MHTML
retVal = “html”
Case “text/xml” 'XML
retVal = “xml”
Search WWH ::




Custom Search