First of all, include the namespace below on top of the code:
using CrystalDecisions.Shared;
then write below code in the page load event as:
protected void Page_Load (object sender, EventArgs e) {
CrystalReportViewer2.AllowedExportFormats = (int) (ViewerExportFormats.ExcelRecordFormat | ViewerExportFormats.PdfFormat); }
source share