public ActionResult InvestmentByRegionExport(InvestmentByRegionViewModel model) { if (ModelState.IsValid) { try { using (var ms = new MemoryStream()) { model.InvestmentByRegions = ReportRepository.GetInvestmentByRegion(model); model.Regions = model.InvestmentByRegions.Select(s => s.Region).Distinct().OrderBy(c => c).ToList(); model.Sectors = StatusRepository.GetStatusByGroup("Sector"); var exporterService = new ExcelExportService(); var workbook = exporterService.ExportByRegion(model); //Write the Workbook to a memory stream workbook.Write(ms); var fileName = "Foreign investment Chart (" + DateTime.Now.ToString("ddMMyyyy-HHmmss") + ")." + exporterService.Extension; Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName); //Return the result to the end user return(File(ms.ToArray(), exporterService.MIME)); //Suggested file name in the "Save as" dialog which will be displayed to the end user } } catch (Exception ex) { ModelState.AddModelError("", "Error in - ExportToExcel :" + ex.Message); return(View("InvestmentByCountryExport")); } } return(View("InvestmentByCountryExport")); }
public ExcelExportController( UsageRecordsRepository repository, ExcelExportService excelExportService) { _repository = repository; _excelExportService = excelExportService; }
public void ExportTest() { List <ExportCar> list = new List <ExportCar>(); for (int i = 0; i < 5; i++) { list.Add(new ExportCar() { Name = "龚英韬", Age = 22, CarCode = "SSSS", Gender = GenderEnum.男, RegisterDate = DateTime.Now }); } for (int i = 0; i < 600; i++) { list.Add(new ExportCar() { Name = "龚英韬111", Age = 22, CarCode = "对对对对对对多多多多多多多多多多多多多多多多多多多多多多多多多多多多多多多多多多多多", Gender = GenderEnum.男, RegisterDate = DateTime.Now }); } IWorkbook wk = ExcelExportService.Export <ExportCar>(list); Assert.True(wk != null); File.WriteAllBytes(@"c:\test\test.xls", wk.ToBytes()); }
/// <summary> /// 初始化一个<see cref="BugFixesTest"/>类型的实例 /// </summary> public BugFixesTest(ITestOutputHelper output) { Output = output; ImportProvider = new ExcelImportProvider(); ImportService = new ExcelImportService(ImportProvider); ExportProvider = new ExcelExportProvider(); ExportService = new ExcelExportService(ExportProvider); CurrentDir = Environment.CurrentDirectory; }
public void ExcelExportService_Initialization_Test() { // Create new ExcelExportService IExportService excelexportservice = new ExcelExportService(); // Check the ExcelExportService object Assert.IsNotNull(excelexportservice); Assert.IsInstanceOfType(excelexportservice, typeof(ExcelExportService)); }
// // GET: /Admin/ public ActionResult Index() { var result = ExportService.Export(Request.QueryString); ExcelExportService service = new ExcelExportService(); service.Export(result, Response); return(View()); }
private void WriteDataTableToExcelAsync(string path, DataTable dataTable) { IExportService export = new ExcelExportService(); export.ExportAsync(path, dataTable) .ContinueWith(task => { MessageBox.Show("Kayıtlar başarıyla dışarıya aktarıldı..", "", MessageBoxButtons.OK, MessageBoxIcon.Information); dataTable.Dispose(); }); }
/// <summary> /// Создаёт файл экспорта данных из ORM. /// </summary> /// <param name="dataService">Сервис данных ORM.</param> /// <param name="parameters">Параметры экпорта.</param> /// <param name="objs">Объекты для экспорта.</param> /// <param name="queryParams">Параметры в запросе HTTP.</param> /// <returns>Возвращает файл экспорта в виде MemoryStream.</returns> public MemoryStream CreateExportStream(IDataService dataService, IExportParams parameters, DataObject[] objs, NameValueCollection queryParams) { var exportService = new DataExportLimitedService(parameters, dataService); var dataExport = exportService.GetDataExport(objs); var excelService = new ExcelExportService(parameters, queryParams); excelService.SpreadsheetCustomizer = new SpreadsheetCustomizer(); MemoryStream result = excelService.GetExportStream(dataExport); return(result); }
public void GetTweets() { var twitterService = new TwitterService(); twitterService.Authenticate(); var tweetSearchList = new List <TweetSearchModel>(); //tweetSearchList.Add(new TweetSearchModel { Query = "boyner", IsTurkishOnly = true, MaxTweetCount = 12000, IsUrlFree = true }); //tweetSearchList.Add(new TweetSearchModel { Query = "borusanoto%20OR%20borusanotomotiv%20OR%20kosifleroto", IsTurkishOnly = false, MaxTweetCount = 1000 }); //tweetSearchList.Add(new TweetSearchModel { Query = "borusan%20oto%20OR%20otomotiv%20OR%20bmw%20OR%20mini%20OR%20cooper%20OR%20minicooper%20OR%20clubman%20OR%20motor%20OR%20motorrad%20OR%20land%20OR%20range%20OR%20rover%20OR%20jaguar%20OR%20avcılar%20OR%20istinye%20OR%20esenboğa%20OR%20balgat%20OR%20birlik%20OR%20adana%20OR%20mersin%20OR%20bodrum%20OR%20samandıra%20OR%20vadi%20OR%20istanbul%20OR%20dolmabahçe%20OR%20çatalca%20OR%20ataşehir%20OR%20kıbrıs%20OR%20çorlu%20OR%20ankara", IsTurkishOnly = false, MaxTweetCount = 1000 }); //tweetSearchList.Add(new TweetSearchModel { Query = "kosifler%20oto%20OR%20otomotiv%20OR%20bmw%20OR%20mini%20OR%20cooper%20OR%20minicooper%20OR%20clubman%20OR%20motor%20OR%20motorrad%20OR%20land%20OR%20range%20OR%20rover%20OR%20jaguar%20OR%20bostancı%20OR%20kavacık%20OR%20antalya%20OR%20samsun%20OR%20istanbul", IsTurkishOnly = false, MaxTweetCount = 1000 }); //tweetSearchList.Add(new TweetSearchModel { Query = "bmw%20OR%20bmwmotor%20OR%20minicooper%20OR%20motorrad%20OR%20landrover%20OR%20rangerover", IsTurkishOnly = true, MaxTweetCount = 1000 }); //tweetSearchList.Add(new TweetSearchModel { Query = "land%20rover", IsTurkishOnly = true, MaxTweetCount = 1000 }); //tweetSearchList.Add(new TweetSearchModel { Query = "range%20rover", IsTurkishOnly = true, MaxTweetCount = 1000 }); //tweetSearchList.Add(new TweetSearchModel { Query = "mini%20cooper", IsTurkishOnly = true, MaxTweetCount = 1000 }); //tweetSearchList.Add(new TweetSearchModel { Query = "jaguar%20fpace%20OR%20ftype%20OR%20araç%20OR%20araçlar%20OR%20oto%20OR%20otomobil%20OR%20otomobiller", IsTurkishOnly = true, MaxTweetCount = 1000 }); //tweetSearchList.Add(new TweetSearchModel { Query = "to%3Aborusanoto%20OR%20to%3Aborusanotomotiv%20OR%20to%3Aborusanpremium%20OR%20to%3Abotoistinye%20OR%20to%3Abotoavcilar%20OR%20to%3Abotoankara%20OR%20to%3Abotoadana%20OR%20to%3Abotodbahce%20OR%20to%3Akosifleroto", IsTurkishOnly = false, MaxTweetCount = 1000 }); //tweetSearchList.Add(new TweetSearchModel { Query = "%40borusanoto%20OR%20%40borusanotomotiv%20OR%20%40borusanpremium%20OR%20%40botoistinye%20OR%20%40botoavcilar%20OR%20%40botoankara%20OR%20%40botoadana%20OR%20%40botodbahce%20OR%20%40kosifleroto", IsTurkishOnly = false, MaxTweetCount = 1000 }); tweetSearchList.Add(new TweetSearchModel { Query = "Renault%20OR%20Volkswagen%20OR%20Ford%20OR%20BMW%20OR%20Mercedes%20OR%20Hyundai%20OR%20Peugeot%20OR%20Audi%20OR%20Honda%20OR%20Citroen%20OR%20Skoda%20OR%20Seat%20OR%20Chevrolet%20OR%20Dacia%20OR%20Volvo%20OR%20Opel%20OR%20Nissan%20OR%20Toyota%20-maç%20-basketbol%20-arena%20-sanat%20-fashion%20-sahne%20-futbol%20-spor%20-basket", IsTurkishOnly = true, MaxTweetCount = 40000, MaxId = 0, SinceId = 980514266611675137 }); //tweetSearchList.Add(new TweetSearchModel { Query = "doğuş%20oto%20OR%20otomotiv%20OR%20vw%20OR%20volkswagen%20OR%20audi%20OR%20seat%20OR%20skoda", IsTurkishOnly = true, MaxTweetCount = 40000, MaxId = 0, SinceId = 0 }); //tweetSearchList.Add(new TweetSearchModel { Query = "borusan%20oto%20OR%20otomotiv%20OR%20bmw%20OR%20mini%20OR%20cooper%20OR%20land%20OR%20range%20OR%20rover%20OR%20jaguar", IsTurkishOnly = true, MaxTweetCount = 40000, MaxId = 0, SinceId = 0 }); //tweetSearchList.Add(new TweetSearchModel { Query = "kosifler%20oto%20OR%20otomotiv%20OR%20bmw%20OR%20mini%20OR%20cooper%20OR%20land%20OR%20range%20OR%20rover%20OR%20jaguar", IsTurkishOnly = true, MaxTweetCount = 40000, MaxId = 0, SinceId = 0 }); //tweetSearchList.Add(new TweetSearchModel { Query = "koç%20oto%20OR%20otomotiv%20OR%20otosan%20OR%20ford%20OR%20volvo%20-ali", IsTurkishOnly = true, MaxTweetCount = 40000, MaxId = 0, SinceId = 0 }); //tweetSearchList.Add(new TweetSearchModel { Query = "tofaş%20oto%20OR%20otomotiv", IsTurkishOnly = true, MaxTweetCount = 40000, MaxId = 0, SinceId = 0 }); //tweetSearchList.Add(new TweetSearchModel { Query = "hyundai%20oto%20OR%20otomotiv", IsTurkishOnly = true, MaxTweetCount = 40000, MaxId = 0, SinceId = 0 }); //tweetSearchList.Add(new TweetSearchModel { Query = "honda%20oto%20OR%20otomotiv", IsTurkishOnly = true, MaxTweetCount = 40000, MaxId = 0, SinceId = 0 }); var tweets = new List <TweetModel>(); foreach (var tweetSearch in tweetSearchList) { tweets.AddRange(twitterService.GetTweets(tweetSearch)); } var excelData = ExcelExportService.ExportExcel(tweets); File.WriteAllBytes(Guid.NewGuid().ToString() + ".xlsx", excelData); }
public async Task <string> ExportDataToExcelAsync([FromBody] LeadGetAllRequest request, uint?page = null, uint?pageSize = null) { Uri fileUrl; TimeSpan timeZoneOffset = TimeSpan.Zero; string fileName = $"TestDrive-Leads-{DateTime.UtcNow.FormatUtcDateTimeToUserFriendlyString(timeZoneOffset, "yyyyMMddHHmmss")}"; string worksheetsName = "leads"; using (var uow = UowManager.CurrentOrCreateNew(true)) { ExcelExportSettings <Lead> settings = new ExcelExportSettings <Lead>( fileName, worksheetsName, DomainService, ContentManager, ExcelExportLeadOptionsProvider.GetEntityOptions((r) => r.UseByDefault, (key) => key, timeZoneOffset), BuildRetrieveManyFilter(request), request.Sorting, page ?? 0 * pageSize ?? 0, pageSize); fileUrl = await ExcelExportService <Lead> .ExportDataAsync(settings); } return(fileUrl.ToString()); }
public void ExcelExportService_ExportData_Test() { // Create new ExcelExportService and the Test-Data ExcelExportService excelexportservice = new ExcelExportService(); // Create test data to fill the Excel file IProject testproject = new ProjectModel(new ProjectEN()); IProjectStatistic teststatistic = new ProjectStatisticModel(); teststatistic.ChartData = new List <KeyValuePair <string, int> >(); string testpath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\TEST.xlsx"; // Execute ExportData Function excelexportservice.ExportData(testpath, "", testproject, teststatistic); System.Threading.Thread.Sleep(1000); // Check if a new Excel File was created bool fileexists = File.Exists(testpath); Assert.IsTrue(fileexists); }
public UsageRecordsController( UsageRecordsRepository usageRecordsRepository, UsageRecordsRecycleBin usageRecordsRecycleBin, DynamicQueryService dynamicQueryService, ExcelExportService excelExportService, ProjectsWebCacheService projectsWebCacheService, EquipmentHourlyRatesLocalCacheService equipmentHourlyRatesLocalCacheService, ElasticSearchInteropService elasticSearch ) { _usageRecordsRepository = usageRecordsRepository; _usageRecordsRecycleBin = usageRecordsRecycleBin; _dynamicQueryService = dynamicQueryService; _excelExportService = excelExportService; _projectsWebCacheService = projectsWebCacheService; _equipmentHourlyRatesLocalCacheService = equipmentHourlyRatesLocalCacheService; _elasticSearch = elasticSearch; }
private async void ExportPlanungCommandExecute() { if (!CanExportPlanungCommandExecute()) { return; } IsBusy = true; try { var woche = SelectedArbeitswoche.MapViewmodelToArbeitswoche(); var ms = await Task.Run(() => { var service = new ExcelExportService(); return(service.SchreibeIstZeiten(woche, woche.Mitarbeiter, SelectedArbeitswoche.ShowThemen)); }); var pfad = ExcelExportService.PfadExcel; var filename = $"Planung_{woche.Jahr}_{woche.KalenderWoche.ToString("00")}.xlsx"; if (string.IsNullOrWhiteSpace(pfad)) { ms.CreateXlsxFileOnTempPath(true); } else { ms.CreateFile(true, pfad + filename); } } catch (Exception ex) { MessageBox.Show($"Fehler beim Export der Planung.{Environment.NewLine}{ex.GetAllErrorMessages()}"); } finally { IsBusy = false; CommandManager.InvalidateRequerySuggested(); } }
public ActionResult ExportExcel() { IEnumerable <dynamic> bankData = null; if (TempData["xlsTemp"] != null) { bankData = TempData["xlsTemp"] as IEnumerable <客戶銀行資訊>; bankData = bankData.Select(x => new { Id = x.Id, 銀行名稱 = x.銀行名稱, 分行代碼 = x.分行代碼, 銀行代碼 = x.銀行代碼, 帳戶名稱 = x.帳戶名稱, 帳戶號碼 = x.帳戶號碼 }); } else { bankData = _BankRepository.All().Select(x => new { Id = x.Id, 銀行名稱 = x.銀行名稱, 分行代碼 = x.分行代碼, 銀行代碼 = x.銀行代碼, 帳戶名稱 = x.帳戶名稱, 帳戶號碼 = x.帳戶號碼 }).AsEnumerable <dynamic>(); } var header = new List <string>() { "Id", "銀行名稱", "分行代碼", "銀行代碼", "帳戶名稱", "帳戶號碼" }; var fileName = ExcelExportService.Export(Server.MapPath("~/App_Data"), "客戶銀行資訊", header, bankData); return(File(fileName, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "ExportFile.xlsx")); }
public ActionResult ExportExcel() { IEnumerable <dynamic> contactData = null; if (TempData["xlsTemp"] != null) { contactData = TempData["xlsTemp"] as IEnumerable <客戶聯絡人>; contactData = contactData.Select(x => new { Id = x.Id, 姓名 = x.姓名, 職稱 = x.職稱, 手機 = x.手機, 電話 = x.電話 }); } else { contactData = _ContactRepository.All().Select(x => new { Id = x.Id, 姓名 = x.姓名, 職稱 = x.職稱, 手機 = x.手機, 電話 = x.電話 }).AsEnumerable <dynamic>(); } var header = new List <string>() { "Id", "姓名", "職稱", "手機", "電話" }; var fileName = ExcelExportService.Export(Server.MapPath("~/App_Data"), "客戶聯絡人", header, contactData); return(File(fileName, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "ExportFile.xlsx")); }
public async Task <IActionResult> Download([FromServices] ExcelExportService excel) { var bytes = await excel.CreateExcelFile(); return(File(bytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", $"Basar_Neufelden_{DateTime.UtcNow:yyyy-MM-dd_HH-mm-ss}.xlsx")); }
public CounselorController(UnitOfWork unitOfWork) { this.unitOfWork = unitOfWork; excelExportService = new ExcelExportService(unitOfWork); }