本帖最后由 893559686 于 2017-3-27 09:45 编辑
1.想问一下,批量导出到报表可以使用,GrapeCity.ActiveReports.Viewer.Win.Viewer 进行批量的导出吗?按照下面的写法,出现了一个错误,Operation is not supported for section report,所以想问下:
GrapeCity.ActiveReports.PageReport _repPage = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(aPath));
GrapeCity.ActiveReports.Document.PageDocument _reportRuntime = new GrapeCity.ActiveReports.Document.PageDocument(_repPage);
_reportRuntime.LocateDataSource += (send, args) =>
{
object reportData = null;
if (item.ReportDataSourceDic != null)
reportData = item.ReportDataSourceDic.Where(i => i.Key.Equals(args.DataSetName)).FirstOrDefault().Value;
args.Data = reportData;
};
GrapeCity.ActiveReports.Viewer.Win.Viewer ReportViewer = new GrapeCity.ActiveReports.Viewer.Win.Viewer();
ReportViewer.LoadDocument(_reportRuntime);
GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtensionSettings Settings = new GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtensionSettings();
GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtension RenderingExtension = new GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtension();
StreamProvider StreamProvider = new FileStreamProvider(new DirectoryInfo(Path.GetDirectoryName(aExportPath)), Path.GetFileNameWithoutExtension(aExportPath));
ReportViewer.Render(RenderingExtension, StreamProvider, Settings.GetSettings());
2.之前是按照下面的方式批量导出的,但是出现一个问题,同一张报表,用GrapeCity.ActiveReports.Viewer.Win.Viewer 和GrapeCity.ActiveReports.Export.Excel.Section.XlsExport 分别导出,导出的样式不一样,GrapeCity.ActiveReports.Viewer.Win.Viewer 的导出方式样式是没有问题的。
string aNewFileName = string.Empty;//新文件 string aPath = RegSettings.ReportPath + item.Path + item.FileName;//报表路径
GrapeCity.ActiveReports.PageReport _repPage = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(aPath));
GrapeCity.ActiveReports.Document.PageDocument _reportRuntime = new GrapeCity.ActiveReports.Document.PageDocument(_repPage);
_reportRuntime.LocateDataSource += (send, args) =>
{
object reportData = null;
if (item.ReportDataSourceDic != null)
reportData = item.ReportDataSourceDic.Where(i => i.Key.Equals(args.DataSetName)).FirstOrDefault().Value;
args.Data = reportData;
};
aNewFileName = item.Name + aFileSuffix;
GrapeCity.ActiveReports.Export.Excel.Section.XlsExport xlsExport1 = new GrapeCity.ActiveReports.Export.Excel.Section.XlsExport();
xlsExport1.FileFormat = GrapeCity.ActiveReports.Export.Excel.Section.FileFormat.Xlsx;
string aExportPath = aTempFolder + "\\" + aNewFileName;
xlsExport1.Export(_reportRuntime, aExportPath);
|
|