各位高手:
    怎样吧excel的数据用java导入到sql server中。

解决方案 »

  1.   

    用jxl(jexcelapi)或者jakarta的POI读出excel文件内容,再写入数据库
      

  2.   

    http://www.pconline.com.cn/pcjob/ittest/java/js/10308/207813.html
      

  3.   

    导出用jxl,上面的说明很清楚的。
    导入的话直接用SQL SERVER ,SQL SERVER支持EXECL文件的导入,你写个SQL SEVER的存储过程来导,用JAVA调就行了
      

  4.   

    poi:
    1.  把poi的包放到web-inf的lib目录下就行了  
    2. 
    import  org.apache.poi.hssf.usermodel.HSSFWorkbook;  
    import  org.apache.poi.hssf.usermodel.HSSFSheet;  
    import  org.apache.poi.hssf.usermodel.HSSFRow;  
    import  org.apache.poi.hssf.usermodel.HSSFCell;  
    import  java.io.FileInputStream;  
    public  class  ReadXL  {  
     /**  Excel文件的存放位置。注意是正斜线*/  
     public  static  String  fileToBeRead="D:/JTest/  gongye.xls";  
     public  static  void  main(String  argv[]){    
     try{  
      //  创建对Excel工作簿文件的引用  
      HSSFWorkbook  workbook  =  new  HSSFWorkbook(new  FileInputStream(fileToBeRead));  
      //  创建对工作表的引用。  
      //  本例是按名引用(让我们假定那张表有着缺省名"Sheet1")  
      HSSFSheet  sheet  =  workbook.getSheet("Sheet1");  
      //  也可用getSheetAt(int  index)按索引引用,  
      //  在Excel文档中,第一张工作表的缺省索引是0,  
      //  其语句为:HSSFSheet  sheet  =  workbook.getSheetAt(0);  
      //  读取左上端单元  
      HSSFRow  row  =  sheet.getRow(0);  
      HSSFCell  cell  =  row.getCell((short)0);  
      //  输出单元内容,cell.getStringCellValue()就是取所在单元的值  
      System.out.println("左上端单元是:  "  +  cell.getStringCellValue());    
     }catch(Exception  e)  {  
      System.out.println("已运行xlRead()  :  "  +  e  );  
     }  
    }  
    }
      

  5.   

    我的二维数组,想把这个一维数组转换成二维的Object[] p={tag,name,val,data,dsec,cat},其中:tag,name,val,data,dsec,cat都是String类型的变量,接受String类型的值,我想吧这个转换成二维,为了用在JTable里,JTable table=new JTable(Object[][],object[]),,就是为了把数组p[]转换成二维的,就可以了吧数据直接方在JTable里了。。那位可以把忙啊
      

  6.   

    我最近也在作这方面的东西,给你贴点POI的资料
    先看poi的examples包中提供的最简单的例子,建立一个空xls文件。import org.apache.poi.hssf.usermodel.HSSFWorkbook;import java.io.FileOutputStream;import java.io.IOException;public class NewWorkbook{public static void main(String[] args)throws IOException{HSSFWorkbook wb = new HSSFWorkbook();//建立新HSSFWorkbook对象FileOutputStream fileOut = new FileOutputStream("workbook.xls");wb.write(fileOut);//把Workbook对象输出到文件workbook.xls中fileOut.close();}}通过这个例子,我们建立的是一个空白的xls文件(不是空文件)。在此基础上,我们可以进一步看其它的例子。
    import org.apache.poi.hssf.usermodel.*;import java.io.FileOutputStream;import java.io.IOException;public class CreateCells{public static void main(String[] args)throws IOException{HSSFWorkbook wb = new HSSFWorkbook();//建立新HSSFWorkbook对象HSSFSheet sheet = wb.createSheet("new sheet");//建立新的sheet对象
    // Create a row and put some cells in it. Rows are 0 based.HSSFRow row = sheet.createRow((short)0);//建立新行// Create a cell and put a value in it.HSSFCell cell = row.createCell((short)0);//建立新cellcell.setCellValue(1);//设置cell的整数类型的值
    // Or do it on one line.row.createCell((short)1).setCellValue(1.2);//设置cell浮点类型的值row.createCell((short)2).setCellValue("test");//设置cell字符类型的值row.createCell((short)3).setCellValue(true);//设置cell布尔类型的值 HSSFCellStyle cellStyle = wb.createCellStyle();//建立新的cell样式cellStyle.setDataFormat(HSSFDataFormat.getFormat("m/d/yy h:mm"));//设置cell样式为定制的日期格式HSSFCell dCell =row.createCell((short)4);dCell.setCellValue(new Date());//设置cell为日期类型的值dCell.setCellStyle(cellStyle); //设置该cell日期的显示格式HSSFCell csCell =row.createCell((short)5);csCell.setEncoding(HSSFCell.ENCODING_UTF_16);//设置cell编码解决中文高位字节截断csCell.setCellValue("中文测试_Chinese Words Test");//设置中西文结合字符串row.createCell((short)6).setCellType(HSSFCell.CELL_TYPE_ERROR);//建立错误cell
    // Write the output to a fileFileOutputStream fileOut = new FileOutputStream("workbook.xls");wb.write(fileOut);fileOut.close();}}
      

  7.   

    另一个例子用apache的poi来抽取word,excel  poi是apache的一个项目,不过就算用poi你可能都觉得很烦,不过不要紧,这里提供了更加简单的一个接口给你:  下载经过封装后的poi包:http://www.matrix.org.cn/down_view.asp?id=14  下载之后,放到你的classpath就可以了,下面是如何使用它的一个例子:import java.io.*;
    import org.textmining.text.extraction.WordExtractor;
    /**
    * <p>Title: pdf extraction</p>
    * <p>Description: email:[email protected]</p>
    * <p>Copyright: Matrix Copyright (c) 2003</p>
    * <p>Company: Matrix.org.cn</p>
    * @author chris
    * @version 1.0,who use this example pls remain the declare
    */public class PdfExtractor {
    public PdfExtractor() {
    }
    public static void main(String args[]) throws Exception
    {
    FileInputStream in = new FileInputStream ("c:\\a.doc");
    WordExtractor extractor = new WordExtractor();
    String str = extractor.extractText(in);
    System.out.println("the result length is"+str.length());
    System.out.println("the result is"+str);
    }

      

  8.   

    还有我前天问的问题的链接,我可是用了200分呀
    http://community.csdn.net/Expert/topic/4075/4075965.xml?temp=.9065668希望对你有帮助吧至于存入SQL Server2000中就是另一个问题了,
    你慢慢学,总不能把代码都给你吧呵呵
      

  9.   

    如果机子上没有装excel是不是用了这个包也没有用啊?
      

  10.   

    http://www.chinajavalab.com/cgi-bin/topic.cgi?forum=1&topic=328jxl的详细用法