• MS Chart 打印


     protected void btnPrint_Click(object sender, EventArgs e)
            {
               hidPrint.Value = "1";
    
                        //实例化打印对象
                        PrintDocument printdoc = new PrintDocument();
                        //定义打印对象的事件
                        printdoc.PrintPage += new PrintPageEventHandler(printdoc_PrintPage);
                        PaperSize ps = new PaperSize("print_ps", 2100, 2700);
                        printdoc.DefaultPageSettings.PaperSize = ps;
                        printdoc.DefaultPageSettings.Landscape = false;
    
                        //开始打印
                        printdoc.Print();
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "A", "showMessage('数据打印',true);", true);
                    }
      <asp:Chart ID="Chart1" runat="server" Width="630px" Height="450px" Style="text-align: left"
                        Palette="Excel" ImageLocation="~/TempImages/ChartPic_#SEQ(400,3)">
                        <Series>
                            <asp:Series ChartType="Pie" Name="Series1" ChartArea="ChartArea1" Legend="Legend1">
                            </asp:Series>
                        </Series>
                        <ChartAreas>
                            <asp:ChartArea Name="ChartArea1">
                            </asp:ChartArea>
                        </ChartAreas>
                        <Legends>
                            <asp:Legend Name="Legend1">
                            </asp:Legend>
                        </Legends>
                    </asp:Chart>
    protected void SetChartData()
            {
                Bms_SecurityHiddenTypeCollection collection = new Bms_SecurityHiddenTypeBLL().GetSecurityHiddenTypeRate(Conditions);
    
                //设置图表的数据源
                Chart1.DataSource = collection;
    
                //圆饼百分比
                Chart1.Series["Series1"].Label = "#PERCENT{P2}";
    
                //图列文字
                Chart1.Series["Series1"].LegendText = "#VALX";
                ////返回X轴上的一个值
                //Chart1.Series[0].PostBackValue = "#VALX";
                Chart1.Series["Series1"].Points.DataBindXY(collection, "TypeName", collection, "Rate");
                //绑定数据
                Chart1.DataBind();
    
                Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
                Chart1.ChartAreas["ChartArea1"].Area3DStyle.Inclination = 45;
                Chart1.ChartAreas["ChartArea1"].Area3DStyle.Rotation = 45;
                Chart1.Series["Series1"]["PieLabelStyle"] = "Outside";
            }
     void printdoc_PrintPage(object sender, PrintPageEventArgs e)
            {
                //设置字体
                string path = Server.MapPath(string.Format("../TempImageFiles/chart_{0}.png", DateTime.Now.ToString("yyyyMMddhhmmssfff")));
                Chart1.SaveImage(path, ChartImageFormat.Png);
                Bitmap b = new Bitmap(path);
                e.Graphics.DrawImage(b, e.MarginBounds.Left, e.MarginBounds.Top);
                e.PageSettings.Landscape = true;
    
            }
  • 相关阅读:
    Android使用SO库时要注意的一些问题
    android studio 生成引用arr
    android studio 改包名
    P2P通信原理与实现(C++)
    unity3d各种OpenFileDialog操作
    使用ffmpeg编码时,如何设置恒定码率,并控制好关键帧I帧间隔
    ffmpeg h264转h265
    照片人脸建模
    自动减面
    Unity3d 5.3.5使用sqlite3
  • 原文地址:https://www.cnblogs.com/FH-cnblogs/p/3494178.html
Copyright © 2020-2023  润新知