zoukankan      html  css  js  c++  java
  • RDLC

    最近做报表功能,用到了.net的报表组件rdlc。

    其中有个功能就是后台代码直接输出Excel/PDF/Word格式的文件,
    网上看了些资源,做个总结:

    参考地址

    我直接贴出代码:

    //自动导出excel/pdf/word
            private void ResponseFile(int oType, string fileName)
            {
                string outType;
                if (oType == 0)
                {
                    outType = "Excel";
                }
                else if (oType == 1)
                {
                    outType = "Word";
                }
                else
                {
                    outType = "Word"; 
                }
                try
                {
                    Warning[] warnings;
                    string[] streamids;
    
                    string mimeType;
                    string encoding;
                    string extension;
    
    
                    byte[] bytes = ReportViewer1.LocalReport.Render(
                            outType, null, out mimeType, out encoding, out extension,
                            out streamids, out warnings);
                        Response.Clear();
                        Response.Buffer = true;
                        Response.ContentType = mimeType;
                        Response.AddHeader("content-disposition", "attachment;filename=" + fileName + "." + extension);
                        Response.BinaryWrite(bytes);
    
                        Response.Flush();
    
                }
    
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
  • 相关阅读:
    javaee_正则表达式基础和常用表达式
    hello2源代码分析
    servlet_filterj简介
    hello1的web.xml解析
    Annotation
    注入(Injection)
    容器(Container)
    Building Tool(Maven/Gradle)
    JavaWeb的历史与发展趋势
    Build Tools
  • 原文地址:https://www.cnblogs.com/zhangzhi19861216/p/3677896.html
Copyright © 2011-2022 走看看