package test;
import java.io.File;
import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;import java.io.InputStream;import java.sql.Connection;import java.sql.DriverManager;import java.sql.SQLException;import com.amarsoft.account.util.StringTools;
import com.amarsoft.are.sql.ConnectionManager;import com.amarsoft.are.sql.Transaction;import jxl.Sheet;
import jxl.Workbook; public class ExcelInsertSql {public static void main(String[] args) {
String excel="F:\\bb.xls"; insert(excel); } private static void insert(String excel){ System.out.println("开始了。。。。。。。。。。。。。"); Transaction sqlca = null; ConnectionManager cm=new ConnectionManager(); String URL = "jdbc:oracle:thin:@10.10.10.88:8080:orcl"; String USER = "user"; String PASSWORD = "password"; String NAME="oracle.jdbc.driver.OracleDriver"; try { Connection con=cm.getConnection(URL, NAME, USER,PASSWORD); System.out.println("con:"+con); sqlca=new Transaction(con); System.out.println("sqlca:"+sqlca); Workbook wb = Workbook.getWorkbook(new File(excel)); //得到工作薄 Sheet sheet= wb.getSheet("xx"); int clos=sheet.getColumns();//得到所有的列 int rows=sheet.getRows();//得到所有的行 System.out.println(clos+" rows:"+rows); for (int i = 1; i < rows; i++) { for (int j = 0; j < clos; j++) { //第一个是列数,第二个是行数 String serialnumber=sheet.getCell(j++, i).getContents();//默认最左边编号也算一列 所以这里得j++ String area=sheet.getCell(j++, i).getContents(); String school=sheet.getCell(j++, i).getContents(); String remarks=sheet.getCell(j++, i).getContents(); String status=sheet.getCell(j++, i).getContents(); String sql=""; //插入到数据库. } } System.out.println("结束了.............."); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }}