求代码,谢谢。。就是写一个jsp程序实现orcale数据库中的某个表数据导出功能,生成文件为excel或者txt都行,谢谢!!!!

解决方案 »

  1.   

    http://topic.csdn.net/u/20090512/08/f2cc1ceb-00b1-4383-8d97-6df7bb129a72.html
      

  2.   

    http://www.oracle-base.com/articles/8i/ShellCommandsFromPLSQL.php
      

  3.   


    package com.testing.Service;import java.io.File;
    import java.io.IOException;
    import java.sql.SQLException;
    import java.util.List;
    import jxl.Workbook;
    import jxl.write.Label;
    import jxl.write.WritableCellFormat;
    import jxl.write.WritableFont;
    import jxl.write.WritableSheet;
    import jxl.write.WritableWorkbook;
    import jxl.write.WriteException;
    import jxl.write.biff.RowsExceededException;
    /** 
     * description:  Used to generate a excel file, which store the latest proxy ID map.
     * @author  Shawn Xiao 
     * Jun 29, 2010 15:48:47 PM 
     */
    public class GenProxyIDMapExtractor {
    public void writeProxyIDMapExcel() throws RowsExceededException,
    WriteException, SQLException, IOException { String fileName = "c:/ProxyIDMap.csv"; //create the workbook and sheet
    WritableWorkbook wwb = Workbook.createWorkbook(new File(fileName));
    WritableSheet ws = wwb.createSheet(("Sheet" + "1"), 0); // set the font
        WritableFont wf = new WritableFont(WritableFont.TIMES, 11, WritableFont.BOLD, false);
    WritableCellFormat wcfF = new WritableCellFormat(wf); wcfF.setAlignment(jxl.format.Alignment.CENTRE);
    wcfF.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE); // generate the Header
    generateHeader(ws, wcfF); List list = new GenProxyIDMapQuery().getProxyIDMap_temp();
    wcfF = new WritableCellFormat();

    int index = 1;
    for (int i = 0; i < list.size(); i++) {
    ProxyIDmapData test = (ProxyIDmapData)list.get(i);

    ws.setColumnView(0, 20);
    ws.setColumnView(1, 20);
    ws.setColumnView(2, 20);
    ws.setColumnView(3, 20); Label data1 = new Label(0, index, ("" + test.getAs_of_date()), wcfF);
    Label data2 = new Label(1, index, ("" + test.getSec_id()), wcfF);
    Label data3 = new Label(2, index, ("" + test.getProxy_id()), wcfF);
    Label data4 = new Label(3, index, ("" + test.getData_source()), wcfF);

    ws.addCell(data1);
    ws.addCell(data2);
    ws.addCell(data3);
    ws.addCell(data4);
    index++;
    }
    wwb.write();
    wwb.close();
    }

    /**
    * generate the Header for the file
    */
    private void generateHeader(WritableSheet ws, WritableCellFormat wcfF) throws WriteException, RowsExceededException {
    Label labelCF1 = new Label(0, 0, "as_of_date", wcfF);
    Label labelCF2 = new Label(1, 0, "sec_id", wcfF);
    Label labelCF3 = new Label(2, 0, "proxy_id", wcfF);
    Label labelCF4 = new Label(3, 0, "data_source", wcfF); // bond the values
    ws.addCell(labelCF1);
    ws.addCell(labelCF2);
    ws.addCell(labelCF3);
    ws.addCell(labelCF4);
    }

    /**
    * Main class used to testing.
    */
        public static void main(String[] args) throws RowsExceededException, WriteException, SQLException, IOException {
    new GenProxyIDMapExtractor().writeProxyIDMapExcel();
    }
            
    }
    刚好昨天写了个简单的。
      

  4.   

    可以参考我的BLOG,服务器端导出,客户端导出.....