예제 #1
0
        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();
            }
        }