public virtual ActionResult ExportTo(int id) { List<Electronics> list = Electronics.GetData(); ExportList<Electronics> exp = new ExportList<Electronics>(); exp.PathTemplateFolder = Server.MapPath("~/ExportTemplates/electronics"); string filePathExport = Server.MapPath("~/exports/a" + ExportBase.GetFileExtension((ExportToFormat)id)); exp.ExportTo(list, (ExportToFormat)id, filePathExport); return this.File(filePathExport, "application/octet-stream", System.IO.Path.GetFileName(filePathExport)); }
static void Main(string[] args) { List <Electronics> list = Electronics.GetData(); ExportList <Electronics> exp = new ExportList <Electronics>(); exp.PathTemplateFolder = Path.Combine(Environment.CurrentDirectory, "templates/electronics"); exp.ExportTo(list, ExportToFormat.HTML, "a.html"); exp.ExportTo(list, ExportToFormat.CSV, "a.csv"); exp.ExportTo(list, ExportToFormat.XML, "a.xml"); exp.ExportTo(list, ExportToFormat.Word2003XML, "a_2003.doc"); exp.ExportTo(list, ExportToFormat.Excel2003XML, "a_2003.xls"); exp.ExportTo(list, ExportToFormat.Excel2007, "a.xlsx"); exp.ExportTo(list, ExportToFormat.Word2007, "a.docx"); exp.ExportTo(list, ExportToFormat.itextSharpXML, "a.xml"); exp.ExportTo(list, ExportToFormat.PDFtextSharpXML, "a.pdf"); }
private void ExportToExcelButton_Click(object sender, RoutedEventArgs e) { List <Note> list = db.Notes.ToList(); ExportList <Note> exp = new ExportList <Note>(); MessageBox.Show("Готово файл сохранился в текущей папке!!!"); exp.PathTemplateFolder = Directory.GetCurrentDirectory(); exp.ExportTo(list, ExportToFormat.Excel2007, "result.xlsx"); }
public virtual ActionResult ExportTo(int id) { List <Electronics> list = Electronics.GetData(); ExportList <Electronics> exp = new ExportList <Electronics>(); exp.PathTemplateFolder = Server.MapPath("~/ExportTemplates/electronics"); string filePathExport = Server.MapPath("~/exports/a" + ExportBase.GetFileExtension((ExportToFormat)id)); exp.ExportTo(list, (ExportToFormat)id, filePathExport); return(this.File(filePathExport, "application/octet-stream", System.IO.Path.GetFileName(filePathExport))); }
static void Main(string[] args) { List<Electronics> list = Electronics.GetData(); ExportList<Electronics> exp = new ExportList<Electronics>(); exp.PathTemplateFolder = Path.Combine(Environment.CurrentDirectory, "templates/electronics"); exp.ExportTo(list, ExportToFormat.HTML, "a.html"); exp.ExportTo(list, ExportToFormat.CSV, "a.csv"); exp.ExportTo(list, ExportToFormat.XML, "a.xml"); exp.ExportTo(list, ExportToFormat.Word2003XML, "a_2003.doc"); exp.ExportTo(list, ExportToFormat.Excel2003XML, "a_2003.xls"); exp.ExportTo(list, ExportToFormat.Excel2007, "a.xlsx"); exp.ExportTo(list, ExportToFormat.Word2007, "a.docx"); exp.ExportTo(list, ExportToFormat.itextSharpXML, "a.xml"); exp.ExportTo(list, ExportToFormat.PDFtextSharpXML, "a.pdf"); }
public ActionResult ExportPDF(string[] region, string[] country, string[] sector, string[] document, string[] year, string[] period, string[] last_Update, string[] counterpart, string[] DocCheckboxData, string[] thematicCheckboxData, string[] designProcessCheckboxData, string[] pagesize, string[] page, int?sortColumnIndex, int?sortDirection, string filetype) { SearchMapModel model = new SearchMapModel(); #region [Page] int pageSize = 20000; //if (pagesize != null) //{ // int.TryParse(pagesize[0], out pageSize); //} int Pages = 1; if (page != null) { int.TryParse(page[0], out Pages); } #endregion SearchAttributes searchParam = new SearchAttributes(); searchParam.CurrentPageNumber = Pages; // searchParam.RecordsPerPage = AppSettingsUtility.GetInt(AppSettingsKeys.RecordsPerPage); searchParam.RecordsPerPage = pageSize; if (sortColumnIndex.HasValue) { searchParam.SortColumnIndex = sortColumnIndex.Value; } else { searchParam.SortColumnIndex = 1; } searchParam.SortDirection = (sortDirection.HasValue && sortDirection.Value == 1) ? Entity.SortDirection.Descending : Entity.SortDirection.Ascending; model.SearchParam = searchParam; List <ExportRecordData> exportRecordData = new List <ExportRecordData>(); exportRecordData = model.GetExportFilteredData(region, country, sector, document, year, period, last_Update, counterpart, DocCheckboxData, thematicCheckboxData, designProcessCheckboxData, pageSize, model.SearchParam, sortColumnIndex, sortDirection); ExportList <ExportRecordData> exp = new ExportList <ExportRecordData>(); string filePathExport = string.Empty; exp.PathTemplateFolder = Server.MapPath("~/ExportTemplates/"); if (filetype == "excel") { filePathExport = Server.MapPath("~/ExportFiles/" + DateTime.Now.Ticks + ".xlsx"); exp.ExportTo(exportRecordData, ExportToFormat.Excel2007, filePathExport); } else if (filetype == "pdf") { filePathExport = Server.MapPath("~/ExportFiles/" + DateTime.Now.Ticks + ".csv"); exp.ExportTo(exportRecordData, ExportToFormat.CSV, filePathExport); } else if (filetype == "csv") { filePathExport = Server.MapPath("~/ExportFiles/" + DateTime.Now.Ticks + ".csv"); exp.ExportTo(exportRecordData, ExportToFormat.CSV, filePathExport); } else { filePathExport = Server.MapPath("~/ExportFiles/" + DateTime.Now.Ticks + ".csv"); exp.ExportTo(exportRecordData, ExportToFormat.CSV, filePathExport); } //return this.File(filePathExport, "application/octet-stream", System.IO.Path.GetFullPath(filePathExport)); return(Json(new { fileurl = "/ExportFiles/" + System.IO.Path.GetFileName(filePathExport) }, JsonRequestBehavior.AllowGet)); }