Back to all postsPrevious Post
Crystal ReportsSQL ServerExcel
Guide to Excel Reporting with MS SQL Data Using Crystal Report
SathishMarch 4, 2010
Crystal Reports provides excellent capabilities for generating Excel reports from SQL Server data.
Setting Up the Report
- Create a new Crystal Report in Visual Studio
- Connect to your SQL Server database
- Select the tables and fields you need
- Design your report layout
Exporting to Excel
csharp
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
ReportDocument report = new ReportDocument();
report.Load("SalesReport.rpt");
// Set database connection
report.SetDatabaseLogon("username", "password", "server", "database");
// Export to Excel
ExportOptions exportOptions = report.ExportOptions;
exportOptions.ExportFormatType = ExportFormatType.Excel;
exportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
DiskFileDestinationOptions diskOptions = new DiskFileDestinationOptions();
diskOptions.DiskFileName = "SalesReport.xls";
exportOptions.DestinationOptions = diskOptions;
report.Export();Export Formats
- Excel (XLS)
- Excel Data Only
- Excel Workbook (XLSX)
- Word
- CSV
Recommended PDF Readers – BlackBerry 8900
Next PostHow to Change Formula Field Variables in Crystal Report Programmatically
Comments
No comments yet. Be the first to comment.