⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 excelhospital.java

📁 java swing源码 欢迎下载 有问题请联系 我一定负责到底
💻 JAVA
字号:
/**
 * 定点医院
 */
package com.NCL;

import java.util.*;
import com.sinosoft.common.*;
import java.io.File;
import jxl.*;

public class ExcelHospital {

	/**
	 * @param args
	 * @author vincent
	 * @date 2007-7-9
	 */	
	protected IndexMap propList;
	protected HashSet Property;
	private boolean EOF = false;
	private int COUNT;
	private String Type = "";
	private String area = "";
	/**
	 * 构造函数
	 *
	 */
	public ExcelHospital(){
		propList=new IndexMap();
		Property=new HashSet();
		Property.add("HospitalID");			//医院ID
		Property.add("HospitalName");		//医院名称
		Property.add("HospitalTel");		//医院电话
		Property.add("HospitalAddress");	//医院地址
		Property.add("Authority");			//特色权威
		Property.add("County");				//区县
		Property.add("HospitalLevel");		//医院级别			
		Property.add("Province");			//省	
		Property.add("City");				//市
		Property.add("Note");				//备注
		
	}
	/**
	 * 初始化
	 * @param HospitalID 医院ID
	 */
	public void init(String HospitalID){
		DBAccess d  = new DBAccess();
		String sql = "SELECT * from ExcelHospital where HospitalID=?";
		this.propList = d.init(sql,HospitalID,this.Property);		
	}
	/**
	 * 根据条件查询
	 * @param eh		对象
	 * @param pageSize	分页大小
	 * @param pageIndex	分页页码
	 * @return String
	 */
	public String findHospital(ExcelHospital eh,int pageSize,int pageIndex){
		String result="";		
		String HospitalName = eh.get("HospitalName");
		String ProvinceName = eh.get("Province");
		String CityName = eh.get("City");
		String CountyName = eh.get("County");		
		//	得到所省,市,县;sql所需的
		try{
			StringBuffer Condition = new StringBuffer("select HospitalID from ExcelHospital where 1=1");
			if(Data.hasValue(HospitalName))
				Condition.append(" and HospitalName like ?");			
			if(Data.hasValue(ProvinceName)){
				Condition.append(" and Province like ? ");
			}
			if(Data.hasValue(CityName)){
				Condition.append(" and City like ? ");
			}
			if(Data.hasValue(CountyName)){
				Condition.append(" and County like ? ");
			}
			DBAccess q = new DBAccess();
			result = q.executeQuery(Condition.toString(),eh.propList,pageSize,pageIndex);
			setCOUNT(q.COUNT);
			setEOF(q.EOF);
			return result;
		}catch(Exception e){
			System.out.println("ExcelHospital.findHospital() ERROR:" + e.getMessage());
			return "";
		}
	}
	/**
	 * 删除
	 * @return boolean
	 */
	public boolean delete(){			
		StringBuffer SQL = new StringBuffer("delete excelhospital");			
		DBAccess DBA = new DBAccess();
		return DBA.execute(SQL.toString());
	}
	
	/**
	 * 分析Excel文件并入库
	 * @param excelUrl Excel路径
	 * @return boolean
	 */
	public boolean FromExcelToOracle(String excelUrl){
		try{
			Workbook workbook = Workbook.getWorkbook(new File(excelUrl));
		    Sheet sheet = workbook.getSheet(0);
		    int rows=sheet.getRows();//得到总行数
		      //删除ExcelHospital表
		    if(!delete()) //20070831
		    	return false;
		    String sql = "insert into excelhospital values (HOSPITALID_SQE.nextval,?,?,?,?,?,?,?,?,?)";
		    List l = new ArrayList();
		    for(int i=1;i<rows;i++){
		    	String[] colValue = new String[9];	    	
		    	colValue[0] = sheet.getCell(0,i).getContents().trim().replaceAll("?", "");//医院名称
		    	colValue[1] = sheet.getCell(5,i).getContents().trim().replaceAll("?", "");//联系电话
		    	colValue[2] = sheet.getCell(6,i).getContents().trim().replaceAll("?", "");//联系地址
		    	colValue[3] = sheet.getCell(7,i).getContents().trim().replaceAll("?", "");//特色权威(类别)
		    	colValue[4] = sheet.getCell(3,i).getContents().trim().replaceAll("?", "");//区县
		    	colValue[5] = sheet.getCell(4,i).getContents().trim().replaceAll("?", "");//医院等级
		    	colValue[6] = sheet.getCell(1,i).getContents().trim().replaceAll("?", "");//省
		    	colValue[7] = sheet.getCell(2,i).getContents().trim().replaceAll("?", "");//市
		    	colValue[8] = sheet.getCell(8,i).getContents().trim().replaceAll("?", "");//备注
		        l.add(colValue);
		    }
		    DBAccess d = new DBAccess();
		    return d.mulExecute(sql,l);	
		}catch (Exception ex){
	    	ex.printStackTrace();
	    	return false;
	    }	
	}
	/**
	 * 在此映射中关联指定值与指定键
	 * @param name 指定键
	 * @param value 指定值
	 */
	public boolean set(String name, Object value){
		if(Property.contains(name)){
			propList.put(name,value);
			return true;
		}else
			return false;		
	}
	/**
	 * 返回指定键在此映射中所映射的值
	 * @param name 指定键
	 * @return
	 */
	public String get(String name){
		if (Property.contains(name)){
			String value = (String)propList.get(name);
			if(value != null && !value.equals(""))
				return value;
			else
				return "";
		}else 
			return "";
	}
	/**
	 * 返回COUNT
	 * @return int
	 */
	public int getCOUNT() {
		return COUNT;
	}
	/**
	 * 设置COUNT
	 * @param count
	 */
	public void setCOUNT(int count) {
		COUNT = count;
	}
	/**
	 * 返回EOF
	 * @return boolean
	 */
	public boolean isEOF() {
		return EOF;
	}
	/**
	 * 设置EOF
	 * @param eof
	 */
	public void setEOF(boolean eof) {
		EOF = eof;
	}
	/**
	 * 清空propList
	 *
	 */
	public void clear(){
		propList.clear();
	}
	/**
	 * 获取area
	 * @return String
	 */
	public String getArea() {
		return area;
	}
	/**
	 * 设置area
	 * @param area 地区
	 */
	public void setArea(String area) {
		this.area = area;
	}
	/**
	 * 获取Type
	 * @return String
	 */
	public String getType() {
		return Type;
	}
	/**
	 * 设置Type
	 * @param type 类型
	 */
	public void setType(String type) {
		Type = type;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -