public async Task <IActionResult> FetchMasterFilterData([FromBody] FilterSortingDto filterSortingDto, int filterId, int pageSize, string langName, int pageIndex = 0, bool forCount = false) { try { var data = await _globalGridManager.GetMasterFilterAppliedDataAsync(filterId, pageSize, pageIndex, forCount, filterSortingDto, langName); //// creating the azioni object passing the related details and description. //var azioniDto = await _utilityManager.GetAzioniDtoObject(User, "get", "AG GRID DATA of " + tableName); //// logging the activity record by the user. //await _talentBLLWrapper.AzuiniBll.AzioniInsert(azioniDto); return(Ok(data)); } catch (Exception x) { var errorObj = await _utilityManager.ReturnErrorObj(x, User, "AG GRID ERROR"); if (x.Message == "Token Expired") { return(Unauthorized()); } return(BadRequest(errorObj)); } }
public async Task <IActionResult> OnPostExport([FromBody] FilterSortingDto filterSortingDto, int filterId, string fileName) { IronPdf.HtmlToPdf Renderer = new IronPdf.HtmlToPdf(); // Render an HTML document or snippet as a string Renderer.RenderHtmlAsPdf("<h1>Hello World</h1>").SaveAs("html-string.pdf"); // Advanced: // Set a "base url" or file path so that images, javascript and CSS can be loaded var PDF = Renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\"); PDF.SaveAs("html-with-assets.pdf"); string sWebRootFolder = "../Talent.Web/TempUpload"; FilterSortingDto FilterSortingDto = new FilterSortingDto(); //var dataList = await talentBLLWrapper.GridBll.GetMasterFilterAppliedData(filterId); var dataList = await _globalGridManager.GetMasterFilterAppliedDataAsync(filterId, 0, 0, false, filterSortingDto, "ENG"); var iDataList = dataList.data.ToList(); //var uploads = System.IO.Path.Combine("../Talent.Web/", "TempUpload"); //if (!Directory.Exists(uploads)) //{ // Directory.CreateDirectory(uploads); //} //string sWebRootFolder = "../Talent.Web/TempUpload"; fileName = fileName + ".xlsx"; string sFileName = @fileName; string URL = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, sFileName); FileInfo file = new FileInfo(Path.Combine(sWebRootFolder, sFileName)); var memory = new MemoryStream(); using (var fs = new FileStream(Path.Combine(sWebRootFolder, sFileName), FileMode.Create, FileAccess.Write)) { IWorkbook workbook; workbook = new XSSFWorkbook(); ISheet excelSheet = workbook.CreateSheet("Log_Operazioni"); var rowIndex = 0; IRow row = excelSheet.CreateRow(0); rowIndex++; var cellIndex = 0; row.CreateCell(cellIndex).SetCellValue("Id"); cellIndex++; row.CreateCell(cellIndex).SetCellValue("Description"); cellIndex++; row.CreateCell(cellIndex).SetCellValue("Details"); cellIndex++; row.CreateCell(cellIndex).SetCellValue("User"); cellIndex++; row.CreateCell(cellIndex).SetCellValue("Client_Id"); cellIndex++; foreach (var iData in iDataList) { LogOperazioni logOperazioniDto = (LogOperazioni)iData; row = excelSheet.CreateRow(rowIndex); rowIndex++; cellIndex = 0; row.CreateCell(cellIndex).SetCellValue(logOperazioniDto.LogId); cellIndex++; row.CreateCell(cellIndex).SetCellValue(logOperazioniDto.LogDescr); cellIndex++; row.CreateCell(cellIndex).SetCellValue(logOperazioniDto.LogDettaglio); cellIndex++; row.CreateCell(cellIndex).SetCellValue(logOperazioniDto.LogUteId); cellIndex++; row.CreateCell(cellIndex).SetCellValue(logOperazioniDto.LogCliId); } //row = excelSheet.CreateRow(2); //row.CreateCell(0).SetCellValue(2); //row.CreateCell(1).SetCellValue("Martin Guptil"); //row.CreateCell(2).SetCellValue(33); //row = excelSheet.CreateRow(3); //row.CreateCell(0).SetCellValue(3); //row.CreateCell(1).SetCellValue("Colin Munro"); //row.CreateCell(2).SetCellValue(23); workbook.Write(fs); } using (var stream = new FileStream(Path.Combine(sWebRootFolder, sFileName), FileMode.Open)) { await stream.CopyToAsync(memory); } memory.Position = 0; return(File(memory, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", sFileName)); }