我需要获取多个excel文件(SSRS报告),将它们放在文件夹中并压缩它。这就是我尝试的方式,但它不起作用:
public ActionResult PricingReports( List<int> productIds )
{
MemoryStream memStream = new MemoryStream();
using ( ZipArchive archive = new ZipArchive( memStream, ZipArchiveMode.Update ) )
{
foreach ( int id in productIds )
{
//preparing single excel file
ReportModel model = PrepareReportModel( values );
_ssrs.GetReport( model, "EXCEL" );
ZipArchiveEntry singleReport = archive.CreateEntry( "PricingReport" + " - " + id );
using ( BinaryWriter binWriter = new BinaryWriter( singleReport.Open() ) )
{
binWriter.Write( model.ReportBits );
}
}
}
return File( memStream.ToArray(), System.Net.Mime.MediaTypeNames.Application.Octet, "Pricing reports" );
}