1 foreach (ReportDataSource rds in rdss)
2 {
3 MyReportViewer.LocalReport.DataSources.Add(rds);
4 }
5 MyReportViewer.LocalReport.SetParameters(rpList);
6 MyReportViewer.LocalReport.Refresh();
7
8 Warning[] warnings;
9 string[] streamids;
10 string mimeType;
11 string encoding;
12 string extension;
13
14 byte[] bytes = MyReportViewer.LocalReport.Render(
15 "Excel", null, out mimeType, out encoding, out extension,
16 out streamids, out warnings);
17 System.IO.Directory.CreateDirectory(excelPath + "\\" + DateTime.Now.ToString("yyyyMMdd"));
18 FileStream fs =
19 new FileStream(excelPath + "\\" + DateTime.Now.ToString("yyyyMMdd") + "\\" + Category + ".xls",
20 FileMode.Create);
21 fs.Write(bytes, 0, bytes.Length);
22 fs.Close();
An error occurred during local report processing.
Microsoft.Reporting.WebForms.LocalProcessingException: An error occurred during local report processing. ---> Microsoft.ReportingServices.ReportProcessing.ProcessingAbortedException: An error has occurred during report processing. ---> System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.Collections.Generic.List`1.Add(T item)
at Microsoft.ReportingServices.Library.MemoryReportSnapshot.CreateReportChunk(String name, ReportChunkTypes type, String mimeType)
at Microsoft.ReportingServices.ReportProcessing.ChunkManager.DataChunkWriter.Flush()
at Microsoft.ReportingServices.ReportProcessing.ChunkManager.DataChunkWriter.FinalFlush()
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RuntimeReportDataSetNode.FirstPassCleanup(Boolean flushData)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RuntimeDataSetNode.FirstPass()
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RuntimeDataSetNode.FirstPassProcess(Boolean& closeConnWhenFinish)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RuntimeReportDataSetNode.Process()
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RuntimeDataSetNode.ProcessConcurrent(Object threadSet)
--- End of inner exception stack trace ---
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.ProcessingContext.AbortHelper.ThrowAbortException(Int32 reportUniqueName)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.ProcessingContext.CheckAndThrowIfAborted()
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.Merge.Process(ParameterInfoCollection parameters, Boolean mergeTran)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.ProcessReport(Report report, ProcessingContext pc, ProcessingContext context)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.ProcessReport(Report report, ProcessingContext pc, Boolean snapshotProcessing, Boolean processWithCachedData, GetReportChunk getChunkCallback, ErrorContext errorContext, DateTime executionTime, CreateReportChunk cacheDataCallback, ProcessingContext& context)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RenderReport(IRenderingExtension renderer, DateTime executionTimeStamp, GetReportChunk getCompiledDefinitionCallback, ProcessingContext pc, RenderingContext rc, CreateReportChunk cacheDataCallback, Boolean& dataCached)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RenderReport(IRenderingExtension renderer, DateTime executionTimeStamp, GetReportChunk getCompiledDefinitionCallback, ProcessingContext pc, RenderingContext rc)
at Microsoft.Reporting.LocalService.RenderWithDataCache(PreviewItemContext itemContext, ParameterInfoCollection reportParameters, IEnumerable dataSources, DatasourceCredentialsCollection credentials, IRenderingExtension renderer, ReportProcessing repProc, CreateAndRegisterStream createStreamCallback, ReportRuntimeSetup runtimeSetup)
at Microsoft.Reporting.LocalService.Render(PreviewItemContext itemContext, Boolean allowInternalRenderers, ParameterInfoCollection reportParameters, IEnumerable dataSources, DatasourceCredentialsCollection credentials, CreateAndRegisterStream createStreamCallback, ReportRuntimeSetup runtimeSetup, ProcessingMessageList& warnings)
at Microsoft.Reporting.WebForms.LocalReport.InternalRender(String format, Boolean allowInternalRenderers, String deviceInfo, CreateAndRegisterStream createStreamCallback, Warning[]& warnings)
--- End of inner exception stack trace ---
at Microsoft.Reporting.WebForms.LocalReport.InternalRender(String format, Boolean allowInternalRenderers, String deviceInfo, CreateAndRegisterStream createStreamCallback, Warning[]& warnings)
at Microsoft.Reporting.WebForms.LocalReport.InternalRender(String format, Boolean allowInternalRenderers, String deviceInfo, String& mimeType, String& encoding, String& fileNameExtension, String[]& streams, Warning[]& warnings)
at Microsoft.Reporting.WebForms.LocalReport.Render(String format, String deviceInfo, String& mimeType, String& encoding, String& fileNameExtension, String[]& streams, Warning[]& warnings)
at TimeTask.Service.ReportManager.AnalyzedService.AnalyzedToExcel(String excelPath, String beginDate, String endDate) in E:\TimeTask\TimeTask.Service\ReportManager\AnalyzedService.cs:line 399
你好,我也遇到了类似的问题,请问你是怎么样解决的?非常感谢你的关注!急..