c# - exporting rdlc report into multiple word files - Stack Overflow

admin2025-05-02  1

I am exporting a RDLC report into word file manually and download it into Downloads Folder of user's profile, but when I click the export button I split it into several files, the problem is that it downloads only the first file and ends the action

for (int i = 0; i < lsUniv.Count; i++)
{
  RenderAndDownloadWord(ReportViewer_Split.LocalReport,lsUniv[i].ToString());
}

private void RenderAndDownloadWord(LocalReport report,string fileName)
{
 //LocalReport report = ReportViewer_Split.LocalReport;
 string mimeType, encoding, extension;
 string[] streamIds;
 Warning[] warnings;

 byte[] bytes = report.Render("WORDOPENXML", null, out mimeType, out encoding, out extension, out streamIds, out warnings);


  Response.Clear();
  Response.ContentType = mimeType; // Set the MIME type for Word Open XML
  Response.AddHeader("Content-Disposition", $"attachment; filename=Report_{fileName}.docx");
  Response.OutputStream.Write(bytes, 0, bytes.Length);
  Response.Flush();
  Response.End();     
 }

it just download the first file and the rest won't be downloaded

转载请注明原文地址:http://www.anycun.com/QandA/1746118646a91925.html