Well, I'm having a problem in exporting a single record to word document. In other words, I want the chosen record to be exported in a single word document every time the user clicks the cmdExportandSend button.
private ReportDocument hierarchicalGroupingReport;
private string exportPath;
private DiskFileDestinationOptions diskFileDestinationOptions;
private ExportOptions exportOptions;
protected void Page_Load(object sender, EventArgs e)
{
hierarchicalGroupingReport = new ReportDocument();
hierarchicalGroupingReport.Load(Server.MapPath("CrystalReport1.rpt"));
hierarchicalGroupingReport.SetDatabaseLogon
("admin", "admin", "localhost", "");
CrystalReportViewer1.ReportSource = hierarchicalGroupingReport;
}
private void ExportSetup()
{
exportPath = "C:\\Exported\\";
if (!System.IO.Directory.Exists(exportPath))
{
System.IO.Directory.CreateDirectory(exportPath);
}
diskFileDestinationOptions = new DiskFileDestinationOptions();
exportOptions = hierarchicalGroupingReport.ExportOptions;
exportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
exportOptions.FormatOptions = null;
}
private void ExportCompletion()
{
try
{
hierarchicalGroupingReport.Export();
lblWarning.Text = "SUCCESS";
}
catch (Exception ex)
{
lblWarning.Text = "FAILURE" + ex.Message;
}
lblWarning.Visible = true;
}
private void ConfigureExportToDoc()
{
exportOptions.ExportFormatType = ExportFormatType.WordForWindows;
diskFileDestinationOptions.DiskFileName = exportPath + "Word.doc";
exportOptions.DestinationOptions = diskFileDestinationOptions;
}
protected void cmdExportandSend_Click(object sender, EventArgs e)
{
ExportSetup();
ConfigureExportToDoc();
//ExportSelection();
ExportCompletion();
}
Best Regards,
Ernie

New Topic/Question
Reply



MultiQuote


|