http://www.csdn.net/expert/topic/797/797602.xml?temp=.9226648

解决方案 »

  1.   

    http://www.andykhan.com/jexcelapi/index.html
      

  2.   

    写入:
    public void CSVOUT(ClientRowSet rsQuery)
        {
            try
            {
                BufferedWriter bufout;
                File FilePath = new File(strCSVOUT_PATH+"\\"+
                  this.getSessionParam().getValueAsString(CMN_APP_ColConstant.MANNO)
                  +"_nof.csv");
                bufout = new BufferedWriter(new FileWriter(FilePath));
                bufout.write(",休暇届出設定,,");
                bufout.newLine();
                bufout.write("届出コード,届出内容,対象MHシート,日数");
                String outRow ="";
                rsQuery.moveFirst();
                for (int i=0;i<rsQuery.getRowCount();i++)
                {
                    outRow = rsQuery.getValueAsString(CMN_APP_ColConstant.NOTIF_CD);
                    outRow += ",";
                    outRow += rsQuery.getValueAsString(CMN_APP_ColConstant.NOTIF_NAME);
                    outRow += ",";
                    outRow += rsQuery.getValueAsString(CMN_APP_ColConstant.MHSHEET);
                    outRow += ",";
                    outRow += rsQuery.getValueAsString(CMN_APP_ColConstant.ABS_DAY);
                    rsQuery.moveNext();
                    bufout.newLine();
                    bufout.write(outRow);
                }
                bufout.close();        }
            catch (Exception e)
            {
                System.out.println(e);
            }
        }
    读取:
    public void CSVIN(java.util.Vector requestParamNames,
            java.util.Hashtable requestParamValues)
        {
            try
            {
                UploadFileData updfile = (UploadFileData)requestParamValues.get("UPLOAD");
                BufferedReader in = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(updfile.getContent()),"Cp943C"));
                String inStr = null;
                BufferedWriter bufout;
                File FilePath = new File(strCSVIN_PATH+"\\"+
                  this.getSessionParam().getValueAsString(CMN_APP_ColConstant.MANNO)
                  +"_nof.csv");
                bufout = new BufferedWriter(new FileWriter(FilePath));            int EleNo = 1;
                int PointPos = 0;
                String RowEle = "";
                String RowAll = "";
                CsvIn = "";
                rsCsvin.getParamSet().removeAllParams();
                while ((inStr = in.readLine()) != null)
                {
                    if (rowNo!=1)
                    {
                        bufout.newLine();
                    }
                    bufout.write(inStr);
                    //<--------------------------------->
                    if (rowNo==3)
                    {
                        CsvIn = CsvIn + inStr;
                    }
                    else if (rowNo>3)
                    {
                        CsvIn = CsvIn + "/n" + inStr;
                    }
                    //<--------------------------------->
                    rowNo++;
                }
                bufout.close();
                in.close();
                rsRowNo = 0;        }
            catch(Exception x)
            {
                x.printStackTrace();
            }
        }
    需要说明一下:
    这里的方法一般在JAVA里是可用的,但是我这些程序是用框架做的,所以呢?如果有什么问题,你只要修改一下就OK了!
    祝你好运...........