如何在C#中显示Excel页面? [英] how to show excel page in c#?

查看:607
本文介绍了如何在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());
            }
  
        }

推荐答案

您的问题对您想要的内容有点含糊,但是如果我理解正确的话,您希望在Excel中显示您的Crystal报表. br/>
检查以下有关如何将Crystal报表导出到Excel的链接:
在C#中如何从中导出将水晶报表转换为excel文件 [ C#Crystal Reports导出到Excel [从Crystal Reports导出为PDF, Word,Excel和HTML [
Your question is a bit vague on what you want, but if I understand it correctly you wish to show your Crystal report in Excel.

Check these link on how to export a Crystal report to Excel:
In C# how to export from crystal report to excel file[^]
C# Crystal Reports Export to Excel [^]
Exporting from Crystal Reports to PDF, Word, Excel and HTML[^]


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页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆