本文介绍了如何在C#中显示Excel页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在使用水晶报表,在该报表中,我有两个按钮.一个按钮会生成另一个节目,以便在excel中进行报告.
请解决我的问题.
我写了这段代码.

Hi,
I''m using crystal report and in that report I have two buttons. One button is generate another one show to report in excel.
Please solve my problem.
I wrote this code.

private void btnexcel_Click(object sender, EventArgs e)
        {
            try
            {
                ExportOptions CrExportOptions;

                DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
                ExcelFormatOptions CrFormatTypeOptions = new ExcelFormatOptions();
                CrDiskFileDestinationOptions.DiskFileName = "C:\\Documents and Settings\\Admin\\Desktop\\EmployeeAttendanceEntry.xlsx";
                CrExportOptions = crystalReportViewer1.ExportOptions;
                CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                CrExportOptions.ExportFormatType = ExportFormatType.Excel;
                CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
                CrExportOptions.FormatOptions = CrFormatTypeOptions;
                crystalReportViewer1.Export();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

        }

推荐答案


CrystalReportViwer1.ReportSource = crystalReport;
        if (typ == "Excel")
            crystalReport.ExportToHttpResponse(ExportFormatType.Excel, Response, false, "PackListDetail");




希望对您有帮助.
让我知道是否可以使用上面的方法解决.

Yogesh.




I hope it will help you.
let me know if it get solved using above.

Yogesh.


这篇关于如何在C#中显示Excel页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 13:39