您的位置:首页 > 其它

把题库里面的试题导出成word的形式

2014-12-26 10:50 148 查看
public String TiKuWord() throws Exception{

              System.out.println("aa"+aa);

              listzujuan=ses.FindzuJuan(aa);

              //listzujuan=ses.FindLianxi(aa);

              //System.out.println(listzujuan.get(0).getShtitle());

              Configuration configuration = newConfiguration();

              configuration.setDefaultEncoding("utf-8");

              // 模板放在com.canyou.template包下面,通过classpath装载

              configuration.setClassForTemplateLoading(Tb_sc_selectAction.class,

                            "/com/ecsystem/action");

              String zuzhuangcjr=(String) ActionContext.getContext().getSession().get("user");

              Template t =configuration.getTemplate("yyyy"+".ftl");// 设置要装载的模板

              String path =ServletActionContext.getServletContext().getRealPath("/paper");

               File file = new File(path);

               if(!file.exists()) { 

                      

                  file.mkdirs(); 

              } 

               

               long d=(new Date()).getTime();

               path=path+"\\"+zuzhuangcjr+d+".doc";

              File outFile = new File(path);

              if (!outFile.exists()) {

                     outFile.createNewFile();

              }

              Writer out = new BufferedWriter(newOutputStreamWriter(

                            new FileOutputStream(outFile),"utf-8"));

              Map map = new HashMap<String,Object>();

              map.put("rows", listzujuan);

              if(listzujuan!=null &&listzujuan.size()>0){

                     map.put("titless",aa);

              }

              t.process(map, out);             

              ActionContext.getContext().getSession().put("daochu","导出成功");

              ActionContext.getContext().put("daochu1","http://218.69.93.91:8090/ECSystem/paper/"+zuzhuangcjr+d+".doc");

              ActionContext.getContext().put("daochu2","点击下载");

              return SUCCESS;

       }

 

                         /**

                      * 注意:在下载的时候必须使用流的形式将其输出,注意文件的路径获取,

                      */

                    

                       File file = newFile("/"+downloadDir.trim()+"/" + d);

                         InputStream is = newFileInputStream(file);  //以流的形式输出文件信息

                         return is;

<script
type="text/javascript">

function bao(s){

   if(s=="选择题"){

      document.getElementById("xzta").style.display='';

      document.getElementById("xztb").style.display='';

      document.getElementById("xztc").style.display='';

      document.getElementById("xztd").style.display='';

      var selectA = $.trim($("#selectA").val());

      var selectB = $.trim($("#selectB").val());

      var selectC = $.trim($("#selectC").val());

      var selectD = $.trim($("#selectD").val());

       if(selectA ==
"" || selectB == ""

           || selectC == ""||selectD==""){

         alert("输入信息不能为空!!!!");

         return
false
;

           }

     

     

      }else{

         document.getElementById("xzta").style.display='none';

         document.getElementById("xztb").style.display='none';

         document.getElementById("xztc").style.display='none';

         document.getElementById("xztd").style.display='none';  

         }

      }

  </script>

------------------------------------------------

<script
type="text/javascript">

   $(document).ready(function() {

      $("#sub").bind(

            "click",

            function(event) {         

               var cids=$("#cc1").combo("getValue");

               var xmids=$("#dd").combo("getValue");

               var ees=$("#ee").combo("getValue");

               var selectname = $.trim($("#selectname").val());          

               //var selectgrade = $.trim($("#selectgrade").val());

               var selectanswer = $.trim($("#selectanswer").val());

               var selecttype = $.trim($("#selecttype").val());

               //alert(8888);

               if (selectname ==
"" ||selectanswer==""||selecttype==""

                  ||cids=="" || xmids=="" ||ees=="") {

                  alert("输入信息不能为空!!!!");

                  return
false
;

               }

               if ($.trim($("#selectname").val()) !=
"") {

                  //查询username是否被占用

                  $.post("selectExist.action", {

                     selectname : $("#selectname").val()

                  }, function(data) {

                     if (data ==1) {

                     alert("试题题目已经存在");

                         return
false
;                       

                     }

                     if(bao($("#s").val())==false){

                        return false;

                        }

                    

                     else{              

                        document.addselect.action="addSelect.action";

                        document.addselect.target="i_frame"

                        document.addselect.submit();

                     }

                  });

               }

            }); 

      <select
name="selecttixing"
id="s"
onchange="bao(this.value)"
>

         <option
value="选择题">选择题</option>

         <option
value="判断题">判断题</option>

       </select>

 

 

<script type="text/javascript">

$(document).ready(function(){

    $("#sub").click(function(){

d27a

    if($('#cc1').combobox('getValue')==""){

    alert("请选择课程");

    } 

    else{

           //此处添加   id="xznum"  id="xzscore"  id="pdnum"  id="pdscore"

           var  xznum=parseInt($("#xznum").val());

           var  xzscore=parseInt($("#xzscore").val());

           var  pdnum=parseInt($("#pdnum").val());

           var  pdscore=parseInt($("#pdscore").val());

           var z = xzscore%xznum;

           var v = pdscore%pdnum;

           if(xzscore + pdscore==100){

            if(z == 0){

                if(v==0){

 

                       if ($.trim($("#shtitle").val()) != "") {

                                      //查询username是否被占用

                                      $.post("ShiJuanexist.action", {

                                             shtitle : $("#shtitle").val()

 

                                      }, function(data) {

                                              

                                             if (data ==0) {

                                             //alert("试卷名可以使用!!");         

                               

                                             $("#thform").submit();

                                             }else{                                                   

                                                     alert("试卷名不能使用!!");

                                                 }

                                            

                                      });

                               }

                               else{

                                       alert("试题名不能为空!!");

                                      

                                       }

 

                       // return true;

                         

                    }

                else{

                        alert("判断总分不能整除题目个数,请重新输入!!!");

                    // return false;

                    }

                }

            else{

                    alert("选择总分不能整除题目个数,请重新输入!!!");

                // return false;

                }

              

               }

           else{

                alert("选择和判断分数之和不为100,请重新输入!!!");

            // return false;

               }

          

    };

    });

 

  });

</script>

 

<body style="">

              <div id="WinPop" class="WinPop"

                     style="background-color: white; width: 390px; position: absolute; top: 100px; left: 100px; border: 1px solid #ddd; -webkit-box-shadow: 0px 0px 8px #ccc; -moz-box-shadow: 0px 0px 8px #ccc; box-shadow: 0px 0px 8px #ccc; z-index: 10">

                     <form action="suijizujuan.action" method="post" id="thform">

                            <div class="WinPopHeader"

                                   style="height: 32px; line-height: 32px; padding-left: 10px; background-color: #63b2e7; border-top-left-radius: 5px; border-top-right-radius: 5px; color: white">

                                   随机组卷

 

                            </div>

                            <div align="center">

                                   <table style='font-size:12px'>

 

                                          <tr>

                                                 <th>

                                                        课程名:

                                                 </th>

                                                 <td>

                                                        <input name="cid" id="cc1" class="easyui-combobox"

                                                               data-options=" valueField: 'cid',  editable:false ,  textField: 'cname',  url: 'AllCouurse.action'" />

                                                 </td>

                                          </tr>

                                          <tr>

                                                 <th>

                                                        试卷标题:

                                                 </th>

                                                 <td>

                                                        <input name="shtitle" id="shtitle" type="text">

                                                 </td>

                                                <td>

                                                        <div id="usernamead" style="font-size: 12; width: 100px"></div>

                                                 </td>

                                          </tr>

                                          <tr>

                                                 <th>

                                                        选择题个数:

                                                 </th>

                                                 <td>

                                                        <input type="text" name="XuangeShu" style="width: 130px"

                                                               id="xznum" />

                                                 </td>

                                                 <td>

                                                        分数:

                                                        <input type="text" name="XuanfenShu" style="width: 50px"

                                                               id="xzscore" />

                                                 </td>

                                          </tr>

                                          <tr>

                                                 <th>

                                                        判断题个数:

                                                 </th>

                                                 <td>

                                                        <input type="text" name="PangeShu" style="width: 130px"

                                                               id="pdnum" onblur="checkSupnum2('pdnum')" />

                                                 </td>

                                                 <td>

                                                        分数:

                                                        <input type="text" name="PanfenShu" style="width: 50px"

                                                               id="pdscore" />

                                                 </td>

 

                                          </tr>

                                          <tr>

                                                 <th>

                                                        考试时间

                                                 </th>

                                                 <td>

                                                        <input name="shtime" id="shtime" type="text"

                                                               onClick="WdatePicker()" class="Wdate" />

                                                 </td>

                                          </tr>

                                          <tr>

                                                 <th>

                                                        试卷描述

                                                 </th>

                                                 <td>

                                                        <textarea rows="10" cols="20" id="shcontent" name="shcontent"></textarea>

                                                 </td>

                                          </tr>

                                          <tr>

                                                 <td colspan="3" style="text-align:center">

                                                        <input type="button" value="添加" id="sub" class="btn" style="margin-right:30px;">

 

                                                        <input type="reset" value="重置" class="btn">

                                                 </td>

                                          </tr>

                                   </table>

                            </div>

                     </form>

              </div>

       </body>

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: