日期:2014-05-18  浏览次数:20498 次

数据库sql语句问题
以下是数据库中其中一个学校(共有20多个学校)数据:如图:

要导入word变成以下(以下是一个学校数据导出后格式)这样应该怎么做:

各位兄弟姐妹看完后请多指教,谢谢了

------解决方案--------------------
还真不好意思,没有做过这类的 顶你一下
------解决方案--------------------
你的意思是你要弄报表还是??
------解决方案--------------------
你数据里读取信息出来,然后根据c#生成word的规则来写生成代码,
参考:http://apps.hi.baidu.com/share/detail/34297588
------解决方案--------------------
word支持html
您完全可以写一个html在word里面

您可以吧一个word另存为web,您看他是怎么写的
------解决方案--------------------
用com组件实现
------解决方案--------------------
你查询出来的数据在Lable还是GRIDvIEW?

------解决方案--------------------
小弟这有师傅写的生成表报方法,非常好用
------解决方案--------------------
这个如果不弄报表,只想在页面中显示,只要用一个Gridview添加列,然后把这个列弄成模版列,然后在html代码视图中,想添加什么就添加什么了

注意先看一下,Gridview是获取数据的那个代码
------解决方案--------------------
以下代碼你可以實現這個功能..(只是導出的時候你導出doc就行了這個是導出excel)
C# code

        /// <summary>
        /// EmportDataSetToExcel2 傳入dt 導出規定格式excel
        /// </summary>
        /// <param name="dt"></param>
        public static void EmportDataTableToExcel2(DataTable dt, String[] arrText, String[] arrFil)
        {
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Charset = "";
            HttpContext.Current.Response.Write("<meta http-equiv=Content-Type content=text/html;charset=utf-8>");
            HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
            HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
            StringWriter stringWrite = new StringWriter();
            HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);

            DataGrid dg = new DataGrid();
            dg.AutoGenerateColumns = false;///////自动产生列设置为False; 
            //dg.GridLines = System.Web.UI.WebControls.GridLines.Both;//横线与竖线 
            dg.HeaderStyle.BackColor = System.Drawing.Color.Silver;
            dg.HeaderStyle.ForeColor = System.Drawing.Color.Black;
            //dg.HeaderStyle.BorderWidth = 3;
            //dg.HeaderStyle.Height = 10; 

            for (int i = 0; i < arrText.Length;i++ )
            {
                BoundColumn BC = new BoundColumn();
                BC.HeaderText = arrText[i];//这个就是字段汉字名称 
                BC.DataField = arrFil[i];//这个是字段的实际名称 
                dg.Columns.Add(BC);
            }
          
            dg.DataSource = dt;
            dg.DataMember = "dt";
            //dg.DataKeyField = "EmpID"; 
            dg.DataBind();

            dg.RenderControl(htmlWrite);
            HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=result.xls");

            HttpContext.Current.Response.Write(stringWrite.ToString());
            HttpContext.Current.Response.End();
        }
        
    }