public ActionResult ExportTo(string OutputFormat) { var model = Session["TypedListModel"]; switch (OutputFormat.ToUpper()) { case "CSV": return(GridViewExtension.ExportToCsv(GridViewHelper.ExportGridViewSettings, model)); case "PDF": return(GridViewExtension.ExportToPdf(GridViewHelper.ExportGridViewSettings, model)); case "RTF": return(GridViewExtension.ExportToRtf(GridViewHelper.ExportGridViewSettings, model)); case "XLS": return(GridViewExtension.ExportToXls(GridViewHelper.ExportGridViewSettings, model)); case "XLSX": return(GridViewExtension.ExportToXlsx(GridViewHelper.ExportGridViewSettings, model)); default: return(RedirectToAction("Index")); } }
static Dictionary <GridViewExportFormat, GridViewExportMethod> CreateExportFormatsInfo() { return(new Dictionary <GridViewExportFormat, GridViewExportMethod> { { GridViewExportFormat.Pdf, GridViewExtension.ExportToPdf }, { GridViewExportFormat.Xls, (settings, data) => GridViewExtension.ExportToXls(settings, data, new XlsExportOptionsEx { ExportType = DevExpress.Export.ExportType.WYSIWYG }) }, { GridViewExportFormat.Xlsx, (settings, data) => GridViewExtension.ExportToXlsx(settings, data, new XlsxExportOptionsEx { ExportType = DevExpress.Export.ExportType.WYSIWYG }) }, { GridViewExportFormat.Rtf, GridViewExtension.ExportToRtf }, { GridViewExportFormat.Csv, (settings, data) => GridViewExtension.ExportToCsv(settings, data, new CsvExportOptionsEx { ExportType = DevExpress.Export.ExportType.WYSIWYG }) } }); }
public ActionResult ExportTo() { XlsxExportOptionsEx exportOptions = new XlsxExportOptionsEx(); exportOptions.ExportType = DevExpress.Export.ExportType.WYSIWYG; return(GridViewExtension.ExportToXlsx(GridViewHelper.ExportGridViewSettings, MyModel.GetProducts(), exportOptions)); }
public ActionResult ExportTo() { XlsxExportOptionsEx exportOptions = new XlsxExportOptionsEx(); exportOptions.CustomizeCell += new DevExpress.Export.CustomizeCellEventHandler(exportOptions_CustomizeCell); return(GridViewExtension.ExportToXlsx(GridViewHelper.ExportGridViewSettings, MyModel.GetProducts(), exportOptions)); }
public ActionResult PayrollExportXlsx(DateTime targetDate, bool commit, string filter) { var filterValue = PayrollFilterListItem.GetEnumValue(filter); ProviderService.PayrollExportXlxs(targetDate, commit, filterValue, out GridViewSettings gridViewSettings, out IEnumerable <PayrollGridItemVM> data); return(GridViewExtension.ExportToXlsx(gridViewSettings, data)); }
//----------------------------------------------------------------------------------------------------- public ActionResult ExportarExcel() { string companyName = ViewBag.companyName; string systemName = ViewBag.systemName; string userName = (string)HttpContext.Session.Contents[SessionUtils.SESSION_USER_NAME]; return(GridViewExtension.ExportToXlsx(CreateExportGridViewSettings(userName, companyName, systemName), SalesService.Instance.listVendedores())); }
public ActionResult Exportar(string IdRol = null, int?TipoAlumno = null, int?IdProvincia = null, int?IdLocalidad = null, string texto = "") { List <AspNetUsers> usuarios = null; usuarios = consultar(IdRol, TipoAlumno, IdProvincia, IdLocalidad, texto); ExportSettings.DefaultExportType = ExportType.WYSIWYG; return(GridViewExtension.ExportToXlsx(CrearGridViewSettingsExportar("Alumnos"), usuarios, true)); }
public ActionResult DownloadUnfinalizedProviders(DateTime period) { var data = repository.GetUnfinalizedProviderExportItems(period); var s = new GridViewSettings { Name = "gvDownloadUnfinalizedProviders" }; s.Settings.ShowFilterRow = false; s.SettingsBehavior.AllowSort = false; s.SettingsBehavior.AllowGroup = false; s.SettingsBehavior.AllowFocusedRow = false; s.SettingsBehavior.AllowSelectSingleRowOnly = true; s.SettingsExport.ExportSelectedRowsOnly = false; s.SettingsExport.FileName = "UnfinalizedProviders_" + DateTime.Now.ToString("yyyy-MM-dd") + ".xlsx"; s.Columns.Add(col => { col.Name = "colFirstName"; col.FieldName = "FirstName"; col.Caption = "First Name"; }); s.Columns.Add(col => { col.Name = "colLastName"; col.FieldName = "LastName"; col.Caption = "Last Name"; }); s.Columns.Add(col => { col.Name = "colEmail"; col.FieldName = "Email"; col.Caption = "Email"; }); s.Columns.Add(col => { col.Name = "colHoursCount"; col.FieldName = "HoursCount"; col.Caption = "Hours Count"; }); s.Columns.Add(col => { col.Name = "colHasFinalization"; col.FieldName = "HasFinalization"; col.Caption = "Has Finalization"; }); try { return(GridViewExtension.ExportToXlsx(s, data)); } catch (Exception e) { Exceptions.Handle(e, Global.GetWebInfo()); throw e; } }
public ActionResult Exportar(string hiddenUsuario = "", int?IdSede = null, int?IdCurso = null, int?IdOferta = null, string estado = "", int?IdPeriodo = null, int?IdConcepto = null, int?IdTipoCurso = null, int?NroCuotaDesde = null, int?NroCuotaHasta = null, decimal?ImporteDesde = null, decimal?ImporteHasta = null, decimal?Importe2Desde = null, decimal?Importe2Hasta = null, DateTime?FechaVtoDesde = null, DateTime?FechaVtoHasta = null, DateTime?FechaVto2Desde = null, DateTime?FechaVto2Hasta = null, DateTime?FechaPagoDesde = null, DateTime?FechaPagoHasta = null, DateTime?FechaBajaDesde = null, DateTime?FechaBajaHasta = null) { var cuotas = new List <Cuota>(); if (User.IsInRole("Ventanilla")) { IdSede = ApplicationUser.GetSede(); } cuotas = CuotaData.consultarCuotas(hiddenUsuario, IdSede, IdCurso, IdOferta, estado, IdPeriodo, IdConcepto, IdTipoCurso, NroCuotaDesde, NroCuotaHasta, ImporteDesde, ImporteHasta, Importe2Desde, Importe2Hasta, FechaVtoDesde, FechaVtoHasta, FechaVto2Desde, FechaVto2Hasta, FechaPagoDesde, FechaPagoHasta, FechaBajaDesde, FechaBajaHasta ); ExportSettings.DefaultExportType = ExportType.WYSIWYG; return(GridViewExtension.ExportToXlsx(CrearGridViewSettingsExportar("Cuotas"), cuotas, true)); }
static Dictionary <string, GridViewExportMethod> CreateExportFormatsInfo() { return(new Dictionary <string, GridViewExportMethod> { { "CustomExportToXLS", (settings, data) => GridViewExtension.ExportToXls(settings, data, new XlsExportOptionsEx { ExportType = DevExpress.Export.ExportType.WYSIWYG }) }, { "CustomExportToXLSX", (settings, data) => GridViewExtension.ExportToXlsx(settings, data, new XlsxExportOptionsEx { ExportType = DevExpress.Export.ExportType.WYSIWYG }) } }); }
public ActionResult ExportToExcel2(string TYP_ID, string Year, string Month) { DateTime.TryParse(Year + "/" + Month + "/01", out DateTime dateBeg); var dateEnd = dateBeg.AddMonths(1).AddDays(-1); var dt = GetGridView2SessionData(TYP_ID, dateBeg.ToString("yyyyMMdd"), dateEnd.ToString("yyyyMMdd")); var settings = new GridViewSettings(); settings.Name = "GridView2"; settings.Width = 300; settings.CallbackRouteValues = new { Controller = "RP01V2", Action = "GridView2" }; settings.CustomActionRouteValues = new { Controller = "RP01V2", Action = "GridViewRefreshData2" }; settings.ClientSideEvents.BeginCallback = "GridView2BegCallback"; settings.ClientSideEvents.EndCallback = "GridView2EndCallback"; settings.Styles.Header.BackColor = System.Drawing.ColorTranslator.FromHtml("#e9e9e9"); settings.Styles.Header.ForeColor = System.Drawing.ColorTranslator.FromHtml("#0076c2"); settings.Columns.Add( column => { column.FieldName = "BA02A_ID"; column.Caption = Resources.Resource.BA02A_ITM_NM; column.EditorProperties().ComboBox( p => { p.TextField = "ITM_NM"; p.ValueField = "BA02A_ID"; p.DataSource = ERP_V2.CacheCommonDataModule.GetBA02A(); }); }); settings.Columns.Add( column => { column.FieldName = "TOT_PR"; column.Caption = Resources.Resource.TOT_PR; column.EditorProperties().SpinEdit(s => { s.DisplayFormatString = "#,0"; }); }); settings.Settings.ShowFooter = false; settings.SettingsPager.Mode = GridViewPagerMode.ShowAllRecords; return(GridViewExtension.ExportToXlsx(settings, dt, "類別採購項目", new XlsxExportOptionsEx { ExportType = DevExpress.Export.ExportType.WYSIWYG })); }
public ActionResult Index(DateTime dateBegin, DateTime dateEnd, string supplierIdList, string producerIdList, string catalogIdList, bool?exportToExcel = null) { IEnumerable result = GetData(dateBegin, dateEnd, supplierIdList, producerIdList, catalogIdList); if (exportToExcel.HasValue) { return(GridViewExtension.ExportToXlsx(GridViewHelper.ExportGridViewSettings, result)); } ViewBag.DateFrom = dateBegin; ViewBag.DateTo = dateEnd; ViewBag.CurrentProducers = SearchProducers("", producerIdList); ViewBag.CurrentCatalogs = SearchCatalogs("", catalogIdList); ViewBag.CurrentSuppliers = SearchSuppliers(supplierIdList); return(View(result)); }
public ActionResult ExportToExcel3(string Year) { var dt = GetGridViewSessionData3(Year); var settings = new GridViewSettings(); settings.Name = "GridView3"; //settings.Width = Unit.Percentage(100); settings.CallbackRouteValues = new { Controller = "RP01V2", Action = "GridView3" }; settings.CustomActionRouteValues = new { Controller = "RP01V2", Action = "GridViewRefreshData3" }; settings.ClientSideEvents.BeginCallback = "GridViewBegCallback3"; settings.ClientSideEvents.EndCallback = "GridViewEndCallback3"; settings.Styles.Header.BackColor = System.Drawing.ColorTranslator.FromHtml("#e9e9e9"); settings.Styles.Header.ForeColor = System.Drawing.ColorTranslator.FromHtml("#0076c2"); settings.Columns.Add( column => { column.FieldName = "TYP_NM"; column.Caption = Resources.Resource.TYP_ID; }); foreach (System.Data.DataColumn item in dt.Columns) { var month = item.ColumnName.Substring(4); if (System.Text.RegularExpressions.Regex.IsMatch(item.ColumnName, "^[0-9]*$") && int.Parse(month) <= DateTime.Now.Month) { settings.Columns.Add( column => { column.FieldName = item.ColumnName; column.Caption = item.ColumnName.Insert(4, "-"); column.EditorProperties().SpinEdit(s => { s.DisplayFormatString = "#,0"; }); }); } } settings.Settings.ShowFooter = false; settings.SettingsPager.Mode = GridViewPagerMode.ShowAllRecords; return(GridViewExtension.ExportToXlsx(settings, dt, Year + "採購彙總", new XlsxExportOptionsEx { ExportType = DevExpress.Export.ExportType.WYSIWYG })); }
public ActionResult ExportToExcel(SearchViewModel search) { var dt = GetData(search, false); var newDataTable = dt.Copy(); var row = newDataTable.NewRow(); var summaryRow = SummaryRow; row["ACC_NO"] = ""; row["ACC_NM"] = summaryRow["ACC_NM"]; row["CUR_MY"] = summaryRow["CUR_MY"]; row["TOT_MY"] = summaryRow["TOT_MY"]; newDataTable.Rows.Add(row); return(GridViewExtension.ExportToXlsx(GetExortSetting(), newDataTable, new XlsxExportOptionsEx { ExportType = DevExpress.Export.ExportType.WYSIWYG })); }
public ActionResult ExportTo(string id, string OutputFormat) { ActionResult obj; var model = Session[id + "_resultado"] as ListadoResultado; var settings = Session[id + "Settings"] as GridViewSettings; if (settings.Columns["Action"] != null) { settings.Columns.Remove(settings.Columns["Action"]); } switch (OutputFormat.ToUpper()) { case "CSV": obj = GridViewExtension.ExportToCsv(settings, model.Listado, true); break; case "PDF": obj = GridViewExtension.ExportToPdf(settings, model.Listado, true); break; case "RTF": obj = GridViewExtension.ExportToRtf(settings, model.Listado, true); break; case "XLS": obj = GridViewExtension.ExportToXls(settings, model.Listado, true); break; case "XLSX": obj = GridViewExtension.ExportToXlsx(settings, model.Listado, true); break; default: obj = RedirectToAction("Index", "Home"); break; } var result = obj as FileStreamResult; result.FileDownloadName = (model.TituloListado ?? "ListadosMarfil") + "." + OutputFormat.ToLower(); return(result); }
public ActionResult ExportTo(string exportid, string OutputFormat) { ActionResult obj; var model = Session[session] as TarifasModel; var settings = Session["TarifasSettings"] as GridViewSettings; if (settings.Columns["Action"] != null) { settings.Columns.Remove(settings.Columns["Action"]); } switch (OutputFormat.ToUpper()) { case "CSV": obj = GridViewExtension.ExportToCsv(settings, model.Lineas, true); break; case "PDF": obj = GridViewExtension.ExportToPdf(settings, model.Lineas, true); break; case "RTF": obj = GridViewExtension.ExportToRtf(settings, model.Lineas, true); break; case "XLS": obj = GridViewExtension.ExportToXls(settings, model.Lineas, true); break; case "XLSX": obj = GridViewExtension.ExportToXlsx(settings, model.Lineas, true); break; default: obj = RedirectToAction("Index"); break; } var result = obj as FileStreamResult; result.FileDownloadName = (model.Descripcion ?? Tarifas.TituloEntidad) + "." + OutputFormat.ToLower(); return(result); }
public ActionResult ExportDetailsTo(string OutputFormat) { ActionResult obj; var model = Session["_tablasvariaslin_"] as BaseTablasVariasModel;; var settings = Session["TablavariaSettings"] as GridViewSettings; if (settings.Columns["Action"] != null) { settings.Columns.Remove(settings.Columns["Action"]); } switch (OutputFormat.ToUpper()) { case "CSV": obj = GridViewExtension.ExportToCsv(settings, model.Lineas, true); break; case "PDF": obj = GridViewExtension.ExportToPdf(settings, model.Lineas, true); break; case "RTF": obj = GridViewExtension.ExportToRtf(settings, model.Lineas, true); break; case "XLS": obj = GridViewExtension.ExportToXls(settings, model.Lineas, true); break; case "XLSX": obj = GridViewExtension.ExportToXlsx(settings, model.Lineas, true); break; default: obj = RedirectToAction("Index"); break; } var result = obj as FileStreamResult; result.FileDownloadName = (model.DisplayName ?? "ExportMarfil") + "." + OutputFormat.ToLower(); return(result); }
public ActionResult ExportTo(GridViewExportFormat format) { var setting = GetGridViewSetting(); var data = QuotesProvider.GetQuotes(); if (format == GridViewExportFormat.Pdf) { return(GridViewExtension.ExportToPdf(setting, data)); } if (format == GridViewExportFormat.Rtf) { return(GridViewExtension.ExportToRtf(setting, data)); } if (format == GridViewExportFormat.Xls) { return(GridViewExtension.ExportToXls(setting, data, new XlsExportOptionsEx { ExportType = DevExpress.Export.ExportType.WYSIWYG })); } if (format == GridViewExportFormat.Xlsx) { return(GridViewExtension.ExportToXlsx(setting, data, new XlsxExportOptionsEx { ExportType = DevExpress.Export.ExportType.WYSIWYG })); } if (format == GridViewExportFormat.Csv) { return(GridViewExtension.ExportToCsv(setting, data, new CsvExportOptionsEx { ExportType = DevExpress.Export.ExportType.WYSIWYG })); } return(Content(string.Empty)); }
private ActionResult ExportToType(string OutputFormat, GridViewSettings exportSettings, dynamic model) { switch (OutputFormat.ToUpper()) { case "CSV": return(GridViewExtension.ExportToCsv(exportSettings, model)); case "PDF": return(GridViewExtension.ExportToPdf(exportSettings, model)); case "RTF": return(GridViewExtension.ExportToRtf(exportSettings, model)); case "XLS": return(GridViewExtension.ExportToXls(exportSettings, model)); case "XLSX": return(GridViewExtension.ExportToXlsx(exportSettings, model)); default: return(RedirectToAction("Index")); } }
public ActionResult ExportToExcel(string Year) { var dt = GetData(Year); var settings = new GridViewSettings(); settings.Name = "GridView"; settings.Styles.Header.BackColor = System.Drawing.ColorTranslator.FromHtml("#e9e9e9"); settings.Styles.Header.ForeColor = System.Drawing.ColorTranslator.FromHtml("#0076c2"); settings.Columns.Add( column => { column.FieldName = "BA04A_ID"; column.Caption = Resources.Resource.TYP_ID; column.EditorProperties().ComboBox( p => { p.TextField = "key"; p.ValueField = "value"; p.DataSource = ERP_V2.CacheCommonDataModule.GetBA04A(ERP_V2.UserInfo.LanguageType, false); }); }); settings.Columns.Add( column => { column.FieldName = "YearTotal"; column.Caption = Resources.Resource.TOT_PR; // "採購金額"; column.EditorProperties().SpinEdit(s => { s.DisplayFormatString = "#,0"; }); }); return(GridViewExtension.ExportToXlsx(settings, dt, Year + Resources.Resource.YearTypePurchaseRatio, new XlsxExportOptionsEx { ExportType = DevExpress.Export.ExportType.WYSIWYG })); }
public ActionResult ExportTo(GridViewExportFormat?exportFormat, int stationId, DateTime d_From, DateTime d_To) { Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR"); string _stationName = (from tt in DB.Stations where tt.ID == stationId && tt.IS_DELETED == false select new { tt.NAME }).FirstOrDefault().NAME; if (exportFormat == null || !GridViewExportHelper.ExportFormatsInfo.ContainsKey(exportFormat.Value)) { return(RedirectToAction("AlarmListPartial", stationId)); } //DateTime dts = Convert.ToDateTime(datePck); string date1 = Convert.ToString(d_From); date1 = date1.Substring(0, date1.Length - 9); DateTime date_1 = Convert.ToDateTime(date1); DateTime date_2; DateTime date2 = Convert.ToDateTime(d_To); if (date2.Hour == 00) { date_2 = date2.AddHours(23); date_2 = date_2.AddMinutes(59); } else { date_2 = date2; } var stationName = DB.Stations.Where(a => a.ID == stationId).FirstOrDefault().NAME; var _listAlarmDesc = DB.AlarmDesc.ToList(); var _list = DB.AlarmStatus.Where(x => x.STATION_ID == stationId).OrderBy(x => x.START_DATE).ToList(); var _listInv = DB.Inverters.ToList(); List <AlarmStatusDTO> _ListDataSource = new List <AlarmStatusDTO>(); for (int i = 0; i < _list.Count; i++) { AlarmStatusDTO alarmStatus = new AlarmStatusDTO(); alarmStatus.INVERTER_ID = _list[i].INVERTER_ID; TBL_INVERTER _TblInv = _listInv.Where(x => x.ID == _list[i].INVERTER_ID).FirstOrDefault(); if (_TblInv != null) { alarmStatus.INV_NAME = _TblInv.NAME; } else { alarmStatus.INV_NAME = stationName; } alarmStatus.ERROR_NUMBER = _list[i].ERROR_NUMBER; //alarmStatus.STATUS = _list[i].STATUS; alarmStatus.START_DATE = _list[i].START_DATE; alarmStatus.END_DATE = _list[i].END_DATE; alarmStatus.STATION_ID = _list[i].STATION_ID; alarmStatus.ERROR_NUMBER_NAME = _listAlarmDesc.Where(a => a.ERROR_NUMBER == _list[i].ERROR_NUMBER).FirstOrDefault().ERROR_DESC; _ListDataSource.Add(alarmStatus); } List <AlarmStatusExportDTO> _ListExport = new List <AlarmStatusExportDTO>(); var _TempList = _ListDataSource.Where(x => x.START_DATE >= date_1 && x.START_DATE <= date_2) /*.OrderBy(x => x.START_DATE)*/.ToList(); for (int i = 0; i < _TempList.Count; i++) { AlarmStatusExportDTO _ExportDto = new AlarmStatusExportDTO(); _ExportDto.ID = i + 1; _ExportDto.DEVICE = _TempList[i].INV_NAME; _ExportDto.ERROR_DEFINITION = _TempList[i].ERROR_NUMBER_NAME; _ExportDto.ALERT_START_DATE = _TempList[i].START_DATE.ToString(); _ExportDto.ALERT_END_DATE = _TempList[i].END_DATE.ToString(); _ListExport.Add(_ExportDto); } string filename = _stationName + " (" + date1.ToString() + " - " + date2.ToShortDateString() + ")"; GridHelper gh = new GridHelper(stationId); if (exportFormat == GridViewExportFormat.Xls) { XlsExportOptionsEx exportOptions = new XlsExportOptionsEx(); exportOptions.CustomizeCell += new DevExpress.Export.CustomizeCellEventHandler(exportOptions_CustomizeCell); return(GridViewExtension.ExportToXls(gh.GridStationSetting, _ListExport, filename, exportOptions)); } else if (exportFormat == GridViewExportFormat.Pdf) { return(GridViewExtension.ExportToPdf(gh.GridStationSetting, _ListExport, filename)); } else if (exportFormat == GridViewExportFormat.Xlsx) { return(GridViewExtension.ExportToXlsx(gh.GridStationSetting, _ListExport, filename)); } return(View(stationId)); }
public ActionResult ExportToXls() { var data = GetListIndex(); return(GridViewExtension.ExportToXlsx(CreateExportGridViewSettings(), data)); }
public ActionResult MBHBillingPeriodCommitAndExport(DateTime period) { var data = repository.GetMHBExportItems(period, null); var s = new GridViewSettings { Name = "gvMBHBilling" }; //s.KeyFieldName = "ID"; s.SettingsBehavior.AllowSort = false; s.SettingsBehavior.AllowGroup = false; s.SettingsBehavior.AllowFocusedRow = false; s.SettingsBehavior.AllowSelectSingleRowOnly = true; s.Settings.ShowFilterRow = false; //s.CallbackRouteValues = new { Action = "PayrollGridCallback" }; s.SettingsExport.ExportSelectedRowsOnly = false; s.SettingsExport.FileName = "MBH-Billing_" + DateTime.Now.ToString("yyyy-MM-dd") + ".xlsx"; s.Columns.Add(col => { col.Name = "colPatientID"; col.FieldName = "PatientID"; col.Caption = "Patient ID"; }); s.Columns.Add(col => { col.Name = "colProviderID"; col.FieldName = "ProviderID"; col.Caption = "Provider ID"; }); s.Columns.Add("AuthorizedProviderID"); s.Columns.Add(col => { col.Name = "colSupervisingBCBAID"; col.FieldName = "SupervisingBCBAID"; col.Caption = "Supervising BCBA ID"; }); s.Columns.Add(col => { col.Name = "colIsBCBATimesheet"; col.FieldName = "IsBCBATimesheet"; col.Caption = "Is BCBA Timesheet"; }); s.Columns.Add(col => { col.Name = "colDateOfService"; col.FieldName = "DateOfService"; col.Caption = "Date Of Service"; }); s.Columns.Add(col => { col.Name = "colStartTime"; col.FieldName = "StartTime"; col.Caption = "Start Time"; col.PropertiesEdit.DisplayFormatString = "t"; }); s.Columns.Add(col => { col.Name = "colEndTime"; col.FieldName = "EndTime"; col.Caption = "End Time"; col.PropertiesEdit.DisplayFormatString = "t"; }); s.Columns.Add(col => { col.Name = "colTotalTime"; col.FieldName = "TotalTime"; col.Caption = "Total Time"; }); s.Columns.Add(col => { col.Name = "colServiceCode"; col.FieldName = "ServiceCode"; col.Caption = "Service Code"; }); s.Columns.Add(col => { col.Name = "colPlaceOfService"; col.FieldName = "PlaceOfService"; col.Caption = "Place Of Service"; }); s.Columns.Add(col => { col.Name = "colPlaceOfServiceID"; col.FieldName = "PlaceOfServiceID"; col.Caption = "Place Of Service ID"; }); repository.CommitMHBPeriodExport(period); try { return(GridViewExtension.ExportToXlsx(s, data)); } catch (Exception e) { Exceptions.Handle(e, Global.GetWebInfo()); throw e; } }
public static ActionResult ExportToXlsx(string metaViewName, DataTable dt) { var settings = GridExportHelper.GetGridViewSettings(metaViewName, dt); return(GridViewExtension.ExportToXlsx(settings, dt)); }
public ActionResult ExportToExcel1(string BA02A_ID, string DateBeg, string DateEnd) { DateTime.TryParse(DateBeg, out DateTime dateBeg); DateTime.TryParse(DateEnd, out DateTime dateEnd); var dt = GetData(BA02A_ID, dateBeg.ToString("yyyyMMdd"), dateEnd.ToString("yyyyMMdd")); var settings = new GridViewSettings(); settings.Name = "GridView"; settings.CallbackRouteValues = new { Controller = "RP01V2", Action = "GridView" }; settings.CustomActionRouteValues = new { Controller = "RP01V2", Action = "GridViewRefreshData" }; settings.ClientSideEvents.BeginCallback = "GridViewBegCallback"; settings.Styles.Header.BackColor = System.Drawing.ColorTranslator.FromHtml("#e9e9e9"); settings.Styles.Header.ForeColor = System.Drawing.ColorTranslator.FromHtml("#0076c2"); settings.Columns.Add( column => { column.FieldName = "PUR_NO"; column.Caption = Resources.Resource.TR01A_PUR_NO; }); settings.Columns.Add( column => { column.FieldName = "PUR_DT"; column.Caption = Resources.Resource.TR01A_PUR_DT; }); settings.Columns.Add( column => { column.FieldName = "ITM_NM"; column.Caption = Resources.Resource.BA02A_ITM_NM; }); settings.Columns.Add( column => { column.FieldName = "INC_NM"; column.Caption = Resources.Resource.BA01A_INC_NM; }); settings.Columns.Add( column => { column.FieldName = "PUR_PR"; column.Caption = Resources.Resource.EachPrice; column.EditorProperties().SpinEdit(s => { s.DecimalPlaces = 2; s.DisplayFormatString = "G29"; }); }); settings.Columns.Add( column => { column.FieldName = "Each_PR"; column.Caption = Resources.Resource.ReceiveMY; column.EditorProperties().SpinEdit(s => { s.DecimalPlaces = 2; s.DisplayFormatString = "G29"; }); }); settings.Columns.Add( column => { column.FieldName = "PUR_QT"; column.Caption = Resources.Resource.RP01_PUR_QT; column.EditorProperties().SpinEdit(s => { s.DecimalPlaces = 2; s.DisplayFormatString = "G29"; }); }); settings.Columns.Add( column => { column.FieldName = "TOT_QT"; column.Caption = Resources.Resource.TR01M_ARR_QT; column.EditorProperties().SpinEdit(s => { s.DecimalPlaces = 2; s.DisplayFormatString = "G29"; }); }); settings.Columns.Add( column => { column.FieldName = "DIF_QT"; column.UnboundType = DevExpress.Data.UnboundColumnType.Decimal; //column.UnboundExpression = "[PUR_QT]-[TOT_QT]"; column.Caption = Resources.Resource.NotEnoughQT; column.EditorProperties().SpinEdit(s => { //s.DisplayFormatString = "#,#.#"; s.DisplayFormatString = "G29"; }); }); settings.CustomUnboundColumnData = (s, e) => { if (e.Column.FieldName == "DIF_QT") { decimal PUR_QT = (decimal)e.GetListSourceFieldValue("PUR_QT"); decimal?TOT_QT = e.GetListSourceFieldValue("TOT_QT") as decimal?; if (!TOT_QT.HasValue) { TOT_QT = 0; } e.Value = PUR_QT - TOT_QT; } }; settings.HtmlDataCellPrepared = (s, e) => { if (e.DataColumn.FieldName == "TOT_QT") { var ss = s as MVCxGridView; var cellValue = ss.GetRowValues(e.VisibleIndex, "PUR_QT") as decimal?; var currentCell = e.CellValue as decimal?; if (cellValue.HasValue && currentCell.HasValue) { if (Decimal.Compare(cellValue.Value, currentCell.Value) != 0) { e.Cell.ForeColor = System.Drawing.Color.Red; } } } else if (e.DataColumn.FieldName == "DIF_QT") { var currentCell = e.CellValue as decimal?; if (currentCell.HasValue && currentCell.Value > 0) { e.Cell.ForeColor = System.Drawing.Color.Red; } } else if (e.DataColumn.FieldName == "Each_PR") { var ss = s as MVCxGridView; var cellValue = ss.GetRowValues(e.VisibleIndex, "PUR_PR") as decimal?; var currentCell = e.CellValue as decimal?; if (currentCell.HasValue) { if (Decimal.Compare(cellValue.Value, currentCell.Value) == 0) { e.Cell.ForeColor = System.Drawing.Color.Green; } else { e.Cell.ForeColor = System.Drawing.Color.Red; } } } }; return(GridViewExtension.ExportToXlsx(settings, dt, "商品採購紀錄", new XlsxExportOptionsEx { ExportType = DevExpress.Export.ExportType.WYSIWYG })); }
public ActionResult ExportarExcel() { return(GridViewExtension.ExportToXlsx(CreateExportGridViewSettings(), SalesService.Instance.listCustomers())); }
public ActionResult ExportTo(GridViewExportFormat?exportFormat, int companyId, DateTime d_From, DateTime d_To) { Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR"); string _CompanyName = (from tt in DB.Companies where tt.ID == companyId && tt.IS_DELETED == false select new { tt.NAME }).FirstOrDefault().NAME; if (exportFormat == null || !GridViewExportHelper.ExportFormatsInfo.ContainsKey(exportFormat.Value)) { return(RedirectToAction("CompanyAlarmListPartial", companyId)); } //DateTime dts = Convert.ToDateTime(datePck); string date1 = Convert.ToString(d_From); date1 = date1.Substring(0, date1.Length - 9); DateTime date_1 = Convert.ToDateTime(date1); DateTime date_2; DateTime date2 = Convert.ToDateTime(d_To); if (date2.Hour == 00) { date_2 = date2.AddHours(23); date_2 = date_2.AddMinutes(59); } else { date_2 = date2; } var _list = (from tt in DB.AlarmStatus join t in DB.Stations on tt.STATION_ID equals t.ID where t.COMPANY_ID == companyId select new { tt.INVERTER_ID, tt.ERROR_NUMBER, tt.START_DATE, tt.STATION_ID, tt.END_DATE, t.NAME }).OrderBy(X => X.START_DATE).ToList(); var _listInv = DB.Inverters.ToList(); var _listAlarmDesc = DB.AlarmDesc.ToList(); List <AlarmStatusDTO> _ListDataSource = new List <AlarmStatusDTO>(); for (int i = 0; i < _list.Count; i++) { AlarmStatusDTO alarmStatus = new AlarmStatusDTO(); alarmStatus.INVERTER_ID = _list[i].INVERTER_ID; TBL_INVERTER _TblInv = _listInv.Where(x => x.ID == _list[i].INVERTER_ID).FirstOrDefault(); if (_TblInv != null) { alarmStatus.INV_NAME = _TblInv.NAME; } else { alarmStatus.INV_NAME = "-"; } alarmStatus.ERROR_NUMBER = _list[i].ERROR_NUMBER; //alarmStatus.STATUS = _list[i].STATUS; alarmStatus.START_DATE = _list[i].START_DATE; alarmStatus.STATION_NAME = _list[i].NAME; alarmStatus.END_DATE = _list[i].END_DATE; alarmStatus.STATION_ID = _list[i].STATION_ID; alarmStatus.ERROR_NUMBER_NAME = _listAlarmDesc.Where(a => a.ERROR_NUMBER == _list[i].ERROR_NUMBER).FirstOrDefault().ERROR_DESC; //switch (_list[i].ERROR_NUMBER) //{ // case "0001": // alarmStatus.ERROR_NUMBER_NAME = "Communication Error"; // break; // case "0002": // alarmStatus.ERROR_NUMBER_NAME = "Station Voltage L2 Fault"; // break; // case "0003": // alarmStatus.ERROR_NUMBER_NAME = "Station Voltage L1 Fault"; // break; // case "0004": // alarmStatus.ERROR_NUMBER_NAME = "Station Voltage L3 Fault"; // break; // case "0005": // alarmStatus.ERROR_NUMBER_NAME = "EKK No Connection"; // break; // case "0006": // alarmStatus.ERROR_NUMBER_NAME = "No Main Voltage"; // break; // case "0007": // alarmStatus.ERROR_NUMBER_NAME = "No Production"; // break; // case "0008": // alarmStatus.ERROR_NUMBER_NAME = "AC Voltage Fault"; // break; //} _ListDataSource.Add(alarmStatus); } List <CompanyAlarmStatusExportDTO> _ListExport = new List <CompanyAlarmStatusExportDTO>(); var _TempList = _ListDataSource.Where(x => x.START_DATE >= date_1 && x.START_DATE <= date_2) /*.OrderBy(x => x.START_DATE)*/.ToList(); for (int i = 0; i < _TempList.Count; i++) { CompanyAlarmStatusExportDTO _ExportDto = new CompanyAlarmStatusExportDTO(); _ExportDto.ID = i + 1; _ExportDto.DEVICE = _TempList[i].INV_NAME; _ExportDto.ERROR_DEFINITION = _TempList[i].ERROR_NUMBER_NAME; _ExportDto.ALERT_START_DATE = _TempList[i].START_DATE.ToString(); _ExportDto.ALERT_END_DATE = _TempList[i].END_DATE.ToString(); _ExportDto.STATION_NAME = _TempList[i].STATION_NAME; _ListExport.Add(_ExportDto); } string filename = _CompanyName + " (" + date1.ToString() + " - " + date2.ToShortDateString() + ")"; GridHelper gh = new GridHelper(companyId); if (exportFormat == GridViewExportFormat.Xls) { XlsExportOptionsEx exportOptions = new XlsExportOptionsEx(); exportOptions.CustomizeCell += new DevExpress.Export.CustomizeCellEventHandler(exportOptions_CustomizeCell); return(GridViewExtension.ExportToXls(gh.GridStationSetting, _ListExport, filename, exportOptions)); } else if (exportFormat == GridViewExportFormat.Pdf) { return(GridViewExtension.ExportToPdf(gh.GridStationSetting, _ListExport, filename)); } else if (exportFormat == GridViewExportFormat.Xlsx) { return(GridViewExtension.ExportToXlsx(gh.GridStationSetting, _ListExport, filename)); } return(View(companyId)); }