protected void clink_CreateDetailArea(object sender, EventArgs e) { Link self = (Link)sender; for (int i = 0; i < ASPxGridView1.VisibleRowCount; i += ASPxGridView1.SettingsPager.PageSize) { int endIndex = i + ASPxGridView1.SettingsPager.PageSize; DataTable dt = CreateRange(ASPxGridView1, i, endIndex); exportGrid.DataSource = dt; exportGrid.DataBind(); DevExpress.Web.ASPxGridView.Export.Helper.GridViewLink linkdata = new DevExpress.Web.ASPxGridView.Export.Helper.GridViewLink(ASPxGridViewExporter1); linkdata.PrintingSystem = self.PrintingSystem; self.PrintingSystem.InsertPageBreak(0); ASPxGridViewExporter1.DataBind(); BrickModifier skipArea = linkdata.SkipArea; linkdata.SkipArea = self.SkipArea; linkdata.AddSubreport(System.Drawing.PointF.Empty); linkdata.SkipArea = skipArea; } }
protected void mnuPrincipal_ItemClick(object source, MenuItemEventArgs e) { try { switch (e.Item.Name) { case "btnExport": { ASPxGridViewExporter1.GridViewID = "gv"; XlsExportOptions xlsOpciones = new XlsExportOptions(TextExportMode.Text, true, false); ASPxGridViewExporter1.DataBind(); ASPxGridViewExporter1.WriteXlsToResponse(xlsOpciones); break; } case "btnLimpiar": { gv.DataSource = null; gv.DataBind(); mnuPrincipal.Items[0].Enabled = false; break; } default: break; } } catch (Exception ex) { string a = ex.Message; } }
protected void ASPxButton1_Click(object sender, EventArgs e) { if (ASPxGridView1.GroupCount == 0) { ASPxGridViewExporter1.WritePdfToResponse(); } else { string groupField = ASPxGridView1.GetGroupedColumns()[0].FieldName; object[] groupValues = FindGroupValues(ASPxGridView1); PrintingSystem ps = new PrintingSystem(); Link clink = new Link(ps); clink.CreateDetailArea += new CreateAreaEventHandler(delegate(object sender2, CreateAreaEventArgs e2) { Link self = (Link)sender2; for (int i = 0; i < groupValues.Length; i++) { DevExpress.Web.ASPxGridView.Export.Helper.GridViewLink linkdata = new DevExpress.Web.ASPxGridView.Export.Helper.GridViewLink(ASPxGridViewExporter1); linkdata.PrintingSystemBase = self.PrintingSystem; if (i > 0) { self.PrintingSystem.InsertPageBreak(0); } string filter = ASPxGridView1.FilterExpression; ASPxGridView1.FilterExpression = new GroupOperator(GroupOperatorType.And, CriteriaOperator.Parse(filter), new BinaryOperator(groupField, groupValues[i])).ToString(); ASPxGridView1.ExpandAll(); ASPxGridViewExporter1.DataBind(); BrickModifier skipArea = linkdata.SkipArea; linkdata.SkipArea = self.SkipArea; linkdata.AddSubreport(System.Drawing.PointF.Empty); linkdata.SkipArea = skipArea; ASPxGridView1.FilterExpression = filter; } }); clink.CreateDocument(); ps.PageSettings.Landscape = true; System.IO.MemoryStream stream = new System.IO.MemoryStream(); ps.ExportToPdf(stream); WriteToResponse("export", true, "pdf", stream); stream.Close(); } }
protected void Page_Load() { try { if (Page.IsPostBack) { Mostrado = 1; gv.DataSource = Tabla; gv.DataBind(); } if (!Page.IsPostBack) { Mostrado = 0; } if (Mostrado == 0) { AnioMes = Request.QueryString["AnioMes0"]; Estado = Request.QueryString["Estado0"]; Origen = Request.QueryString["Origen0"]; Mostrado = Convert.ToInt32(Request.QueryString["Mostrado0"]); ArmarCabecera(); DataRow f1 = Tabla.NewRow(); Tabla.Rows.Add(f1); AgregarTotales(); DataRow f2 = Tabla.NewRow(); Tabla.Rows.Add(f2); AgregarPorcentajes(); Mostrado = 0; } ASPxGridViewExporter1.GridViewID = "gv"; ASPxGridViewExporter1.DataBind(); } catch (Exception ex) { string a = ex.Message; } }
protected void mnuPrincipal_ItemClick(object source, MenuItemEventArgs e) { try { switch (e.Item.Name) { case "btnExport": { ASPxGridViewExporter1.GridViewID = "gv"; gv.DataSource = Tabla; ASPxGridViewExporter1.DataBind(); if (ASPxGridViewExporter1 != null) { XlsExportOptions xlsExportOptions = new XlsExportOptions(TextExportMode.Text, true, false); string Titulo = ucEstado.Text.Trim() + " - " + ucOrigen.Text.Trim() + " " + deAnoMes.Text; xlsExportOptions.SheetName = Titulo; ASPxGridViewExporter1.WriteXlsToResponse(xlsExportOptions); } break; } case "btnLimpiar": { gv.DataSource = null; gv.DataBind(); break; } default: break; } } catch (Exception ex) { } }
protected void btnXuat_Click(object sender, EventArgs e) { _DataBind(); ASPxGridViewExporter1.DataBind(); ASPxGridViewExporter1.WriteXlsxToResponse(); }
private void DataBindX() { string ident = (string)Session["valueX"]; if (string.IsNullOrEmpty(ident)) { return; } DataTable dane = GetTable(data1.Date, data2.Date, ident, "databind"); grid.DataSource = dane; try { grid.SettingsPager.PageSize = int.Parse(cm.odczytajWartosc("kontrolka_wiersze")); } catch { grid.SettingsPager.PageSize = 500; } DataTable parameters = cm.makeParameterTable(); parameters.Rows.Add("@ident", ident); int szerokoscKolumny = 0; int rozmiarCzcionki = 0; int szerokosctabeli = 0; try { szerokoscKolumny = int.Parse(cm.getQuerryValue("SELECT szerokoscKolumny FROM konfig WHERE (ident = @ident)", cm.con_str, parameters)); } catch { } try { rozmiarCzcionki = int.Parse(cm.getQuerryValue("SELECT rozmiarczcionki FROM konfig WHERE (ident = @ident)", cm.con_str, parameters)); } catch { } try { szerokosctabeli = int.Parse(cm.getQuerryValue("SELECT szerokosctabeli FROM konfig WHERE (ident = @ident)", cm.con_str, parameters)); } catch { } cm.log.Info("Kontrolka -rozmiar czcionki: " + rozmiarCzcionki.ToString()); cm.log.Info("Kontrolka -szerokosc Kolumny: " + szerokoscKolumny.ToString()); cm.log.Info("Kontrolka -szerokosc tabeli: " + szerokosctabeli.ToString()); Session["rozmiarCzcionki"] = rozmiarCzcionki; Session["szerokoscKolumny"] = szerokoscKolumny; Session["szerokosctabeli"] = szerokosctabeli; for (int i = 0; i < grid.Columns.Count; i++) { if (rozmiarCzcionki > 0) { grid.Columns[i].CellStyle.Font.Size = rozmiarCzcionki; } if (szerokoscKolumny > 0) { grid.Columns[i].Width = szerokoscKolumny; grid.Columns[i].MinWidth = szerokoscKolumny; grid.Style.Add("width", szerokoscKolumny.ToString()); grid.Style.Add("min-width", szerokoscKolumny.ToString()); } } try { if (szerokosctabeli > 0) { grid.Width = szerokosctabeli; } } catch { } foreach (GridViewDataColumn dCol in grid.Columns) { string name = dCol.Name; Type typ = dCol.GetType(); Type typRef = typeof(DateTime); GridViewDataColumn id = new GridViewDataColumn(); id.FieldName = name; // grid.Columns.Add(id); cm.log.Info("kontrolka reftype: " + typRef.FullName); cm.log.Info("kontrolka type: " + typ.FullName); if (typ == typRef) { grid.DataColumns[name].SettingsHeaderFilter.Mode = GridHeaderFilterMode.DateRangePicker; grid.DataColumns[name].Settings.AllowHeaderFilter = DevExpress.Utils.DefaultBoolean.True; } } foreach (GridViewDataColumn col in grid.Columns) { if (col is GridViewDataColumn) { ((GridViewDataColumn)col).Settings.AutoFilterCondition = AutoFilterCondition.Contains; } } ASPxGridViewExporter1.DataBind(); }