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

📄 testcasexml.java

📁 通过apache 的jxl中件间,实现excel文件的导入导出的小例子
💻 JAVA
字号:
package cn.capitek.TorchRelay.util;

import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Properties;

import org.apache.commons.beanutils.BeanUtils;

//import java.util.List;


public class TestCaseXml {

	//private static final String Interger = null;

	/**
	 * @param args
	 * @throws InvocationTargetException 
	 * @throws ClassNotFoundException 
	 */
	public static void main(String[] args) throws ClassNotFoundException, InvocationTargetException {
		// TODO Auto-generated method stub
		// CacheConfig cacheconfig= ExamConfigUtil.getCacheConfig();
		//System.out.println(cacheconfig.getType());
		ExcelConfig excelconfig=ExcelConfigUtil.getExcelConfig();
		//System.out.println(excelconfig.getProperties());
		//List<ExcelType> alist=excelconfig.getProperties();
		TestCaseXml.testParseXml("1");
		System.out.println(TestCaseXml.testrelex().getName());
		//String temstr="testParseXml";
		
	/*	if(alist!=null&&alist.size()>0){
			for(int i=0;i<alist.size();i++){
				ExcelType atype=(ExcelType)alist.get(i);
				//System.out.println(atype.getType());
				
			}
		}*/

	}
	
	public static void testParseXml(String typeid){
		ExcelConfig excelconfig=ExcelConfigUtil.getExcelConfig();
		//System.out.println(excelconfig.getProperties());
		List<ExcelType> alist=excelconfig.getProperties();
		
		if(alist!=null&&alist.size()>0){
			for(int i=0;i<alist.size();i++){
				ExcelType atype=(ExcelType)alist.get(i);
				if(typeid.equals(atype.getType())){
					System.out.println(atype.getType());
					Properties pros =atype.getProperties();
					List<Property> blist=atype.getPropertys();
					if(blist!=null){
						System.out.println(blist.size());
						for(int j=0;j<blist.size();j++){
							Property prot=(Property)blist.get(j);
							if(prot.getColname()!=null){
							System.out.println(prot.getName()+" col:"+prot.getColname()+" value="+prot.getValue());
							//System.out.println(prot.getColname());
							//System.out.println();
							}
						}
						
					}
					/*if(pros!=null){
					System.out.println("aaaasd==="+pros.getProperty("tablename"));
					pros.getProperty("colsend");
					pros.getProperty("rowstart");
					pros.getProperty("rowsend");
					}
					*/
					//String colnum=;
					/*int colnum=Integer.parseInt(pros.getProperty("colnum"));
					if(colnum>0){
						for(int k=1;k<colnum+1;k++){
							pros.getProperty("col"+k);
							//System.out.println(pros.getProperty("col"+k));
						}
					}
					*/
					
					//Properties pros=(Properties).get(i);
				}
				
			}
		}
		
	}
	
	public static Property testrelex() throws ClassNotFoundException, InvocationTargetException{
		//ExcelConfig excelconfig=ExcelConfigUtil.getExcelConfig();
		//System.out.println(excelconfig.getProperties());
		//List<ExcelType> alist=excelconfig.getProperties();
		Object obj=null;
		try {
			obj=Class.forName("cn.capitek.TorchRelay.util.Property").newInstance();
			BeanUtils.setProperty(obj,"name","aaa");
			return (Property)obj;
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return (Property)obj;
	}

}

⌨️ 快捷键说明

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