public FileContentResult RacunReportCollection(string jqGridFilters) { DataAccessAdapterBase adapter = Helpers.Helper.GetDataAccessAdapter(); long firmaId = UserEntity.GetFirmaId(adapter, User.Identity.Name); string reportPath = Server.MapPath(string.Format("~/ReportTemplates/{0}/Racun.xls", firmaId)); FlexCel.XlsAdapter.XlsFile xls = new FlexCel.XlsAdapter.XlsFile(); xls.Open(reportPath); short godina = ConfigEntity.GetInstance(adapter, firmaId).AktivnaGodina; RelationPredicateBucket bucket = RacunGlavaPager.CreateBucket(godina, jqGridFilters); bucket.PredicateExpression.Add(RacunGlavaFields.FirmaId == firmaId); IEnumerable <RacunReport> racunReportCollection = CoolJ.DatabaseGeneric.BusinessLogic.RacunReport.GetRacunReportCollection(adapter, bucket, firmaId); FlexCel.Report.FlexCelReport report = new FlexCel.Report.FlexCelReport(); report.AddTable("Racun", racunReportCollection); report.Run(xls); using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) { FlexCel.Render.FlexCelPdfExport pdfExport = new FlexCel.Render.FlexCelPdfExport(xls); pdfExport.BeginExport(ms); pdfExport.ExportAllVisibleSheets(false, ""); pdfExport.EndExport(); //xls.Save(ms); ms.Position = 0; return(File(ms.ToArray(), "application/pdf")); } }
public FileContentResult RacunReport(long racunGlavaId) { DataAccessAdapterBase adapter = Helpers.Helper.GetDataAccessAdapter(); long firmaId = UserEntity.GetFirmaId(adapter, User.Identity.Name); string reportPath = Server.MapPath(string.Format("~/ReportTemplates/{0}/Racun.xls", firmaId)); FlexCel.XlsAdapter.XlsFile xls = new FlexCel.XlsAdapter.XlsFile(); xls.Open(reportPath); List <RacunReport> racunGlavaList = new List <RacunReport>(); racunGlavaList.Add(new RacunReport(adapter, racunGlavaId)); FlexCel.Report.FlexCelReport report = new FlexCel.Report.FlexCelReport(); report.AddTable("Racun", racunGlavaList); report.Run(xls); using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) { FlexCel.Render.FlexCelPdfExport pdfExport = new FlexCel.Render.FlexCelPdfExport(xls); pdfExport.BeginExport(ms); pdfExport.ExportAllVisibleSheets(false, ""); pdfExport.EndExport(); //xls.Save(ms); ms.Position = 0; return(File(ms.ToArray(), "application/pdf")); } }