Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将报表呈现为CSV文件的备选方案_C#_Csv_Reportviewer_Localreport - Fatal编程技术网

C# 将报表呈现为CSV文件的备选方案

C# 将报表呈现为CSV文件的备选方案,c#,csv,reportviewer,localreport,C#,Csv,Reportviewer,Localreport,我需要将报告呈现为CSV,但我在一些论坛中发现LocalReport不呈现CSV。我有很多关于rdlc的报告,我想改变它会非常困难 我想以Excel的形式呈现,获取字节并将其转换为CSV,但我不知道怎么做 下面是一些代码: if (FormatoRelatorioEnum.XLS == (FormatoRelatorioEnum)formatoRelatorio){ bytes = lr.Render("Excel", deviceInfo); if (temMais || part

我需要将报告呈现为CSV,但我在一些论坛中发现LocalReport不呈现CSV。我有很多关于rdlc的报告,我想改变它会非常困难

我想以Excel的形式呈现,获取字节并将其转换为CSV,但我不知道怎么做

下面是一些代码:

if (FormatoRelatorioEnum.XLS == (FormatoRelatorioEnum)formatoRelatorio){
   bytes = lr.Render("Excel", deviceInfo);
   if (temMais || parte > 1){
      nomeArquivoDownload = "Relatorio_" + relatorioModel.nomeRelatorio + "_Parte_" + parte + ".xls";
   }
   else{
      nomeArquivoDownload = "Relatorio_" + relatorioModel.nomeRelatorio + ".xls";
   }
   contentType = "application/vnd.ms-excel";
}
else if(FormatoRelatorioEnum.PDF == (FormatoRelatorioEnum)formatoRelatorio){
   bytes = lr.Render("PDF", deviceInfo);
   nomeArquivoDownload = "Relatorio_" + relatorioModel.nomeRelatorio + ".pdf";
   contentType = "application/pdf";
}
else{
   bytes = lr.Render("CSV", deviceInfo);
   nomeArquivoDownload = "Relatorio_" + relatorioModel.nomeRelatorio + ".csv";
   contentType = "text/csv";
}

这回答了你的问题吗?我可以导出到EXCEL,但使用
LocalReport
无法导出到CSVIt。建议的解决方案是编写自己的CSV输出系统。其次,最好使用支持CSV的SSRS报表服务器。最糟糕的可能是输出Excel,然后使用Office Automation将其转换为CSV,但这在web服务器上是极不推荐的,在桌面客户机上也是一个坏主意。有没有插件可以直接将数据转换为CSV格式?如果我有字节,我想可以继续了。