public void Test() { using (var dbContext = GetConnection()) { Guid communityId = Guid.Parse("6b8cc193-1f72-4b50-ad49-65c470405186"); Guid contactId = Guid.Parse("862c17f4-6522-4806-9c63-b345bd4e4c07"); var serviceFactory = new ServiceFactory(dbContext, contactId); CommunityExport communityExport = new CommunityExport(serviceFactory, communityId, @"c:\temp\temp.xlsx"); communityExport.Export(); } }
public ActionResult Export(Guid communityId) { try { ServiceFactory serviceFactory = new ServiceFactory(this._faciTechDbContext, this._contactId); var outputFilePath = FileManager.GetTempFolderPath(Guid.NewGuid().ToString() + ".xlsx"); FileManager fileManager = new FileManager(outputFilePath); var attach = _faciTechDbContext.Attachment .Where(e => e.TableName == "Community") .FirstOrDefault(); CommunityExport communityExport = new CommunityExport(serviceFactory, communityId, fileManager.FilePath); communityExport.Export(); return(File(fileManager.GetByteArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")); } catch (Exception ex) { return(new UnknownErrorResult(ex, base._errorEnabled)); } }