Hi all,
"Only export to PDF format from ReportViewer add-in"...Is this possible? Right now the reportviewer has two options of exporting the current report-Excel and PDF...Is it possible to have PDF as the only option. I don't want my clients to export it to excel.
Thanks in advance....
bullpit
----------------------------
As far as I know you can't remove excel export from ReportViewer.
You can only hide export control and only allow user to print the page.
----------------------------
Or you can use a button outside the reportviewer and use the local report's render function to export to pdf only.
----------------------------
I got this code. but I don't want to save. I want to Export the Report into PDF and open directly but How?????.
string mimeType;
string encoding;
string fileNameExtension;
string[] streams;
Microsoft.Reporting.WebForms.Warning[] warnings;
byte[] pdfContent = ReportViewer1.LocalReport.Render("PDF", null, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);
//Creatr PDF file on disk
string pdfPath = @"C:\temp\reportBarcode.pdf";
System.IO.FileStream pdfFile = new System.IO.FileStream(pdfPath, System.IO.FileMode.Create);
pdfFile.Write(pdfContent, 0, pdfContent.Length);
pdfFile.Close();
----------------------------
Heres what I have.
private void saveRptAsBas(String s_rptType) { Warning[] warnings; string[] streamids; string mimeType; string encoding; string extension; // string deviceInfo; DataSet ds = GetSalesDataFull(); // This if() block may not be required for you // It just the nRows parameter in the report before exporting if ((s_rptType == "EXCEL") || (s_rptType == "PDF")) { ReportParameter param = new ReportParameter("nRows", ds.Tables[0].Rows.Count.ToString()); this.ReportViewer2.LocalReport.SetParameters(new ReportParameter[] { param }); } byte[] bytes = ReportViewer2.LocalReport.Render( s_rptType, null, out mimeType, out encoding, out extension, out streamids, out warnings); /* FileStream stream = File.OpenWrite(@"C:\Documents and Settings\michael.shorten\Local Settings\Temp\sample.pdf"); stream.Write(bytes, 0, bytes.Length); stream.Close(); */ Response.Buffer = true; Response.Clear(); Response.ContentType = mimeType; Response.AddHeader("content-disposition", "attachment; filename=Report." + extension); Response.BinaryWrite(bytes); Response.Flush(); Response.End(); }
----------------------------
http://forums.asp.net/p/1067131/2328201.aspx#2328201
----------------------------
<script type="text/javascript" language="javascript">
var obj=document.getElementById('ReportViewer1_ctl01_ctl05_ctl00');
if (obj)
{ var element_length=obj.length;
var index=-1;
for(z=0;z<element_length;z++)
{
if (obj.options[z].value=='Excel')
{index=z;}
}
if(index!=-1)
obj.remove(index); //obj.options.remove(index);
}
</script>