我需要将报告呈现为 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";
}