使用HEADERS C#将晶体报告导出为ex​​cel数据 [英] Export crystal report to excel data with HEADERS C#

查看:70
本文介绍了使用HEADERS C#将晶体报告导出为ex​​cel数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

0
down vote
favorite
I'm trying to export the crystal report to Excel with HEADERS. When i use ExportFormatType.ExcelRecord we only get Data but not the headers(here we get .xls format). I know that ExportFormatType.Excel option will export with Headers but its in .CSV format with blanks and all which is of no use for the client to process the data further.

So wanted to know if there is any way to achieve this requirement where the formatting is good with HEADERS and process the data further.

Thanks.





我尝试过:



i尝试使用



What I have tried:

i have tried using

ExportFormatType.Excel

但它提供了一个csv文件,其中包含整个报告,如页脚,报告标题等。我尽力报告以避免空格。但仍然在Excel csv文件中获取空格。

but it gives a csv file with the entire report like footer,report header etc.Tried formatting the report to my best to avoid blank spaces.But still get blank spaces in the Excel csv file.

推荐答案

尝试此解决方案(来自MSDN)



Try this solution (From MSDN)

// Declare variables and get the export options.
ExportOptions exportOpts = new ExportOptions();
ExcelFormatOptions excelFormatOpts = new ExcelFormatOptions ();
DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();
exportOpts = Report.ExportOptions;

// Set the excel format options.
excelFormatOpts.ExcelUseConstantColumnWidth = true;
excelFormatOpts.ExcelTabHasColumnHeadings = true;
exportOpts.ExportFormatType = ExportFormatType.Excel;
exportOpts.FormatOptions = excelFormatOpts;

// Set the disk file options and export.
exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
diskOpts.DiskFileName = fileName;
exportOpts.DestinationOptions = diskOpts;

Report.Export ();





特别注意这一行:



Pay special attention to the line:

excelFormatOpts.ExcelTabHasColumnHeadings = true;


这篇关于使用HEADERS C#将晶体报告导出为ex​​cel数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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