apache POI技术

        Apache POI是Apache软件基金会的开放源码函式库,POI提供API给Java程序对MicrosoftOffice格式档案读和写的功能。

    

apache POI技术_第1张图片


apache POI技术_第2张图片

1、在项目中引入POI的依赖:


			org.apache.poi
			poi
			3.11
		

2、POI使用:

@Test
	public void test1() throws FileNotFoundException, IOException{
		String filePath = "C:\\Users\\zhaoqx\\Desktop\\BOS项目(黑马32期)\\BOS-day05\\资料\\区域导入测试数据.xls";
		//包装一个Excel文件对象
		HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(new File(filePath)));
		//读取文件中第一个Sheet标签页
		HSSFSheet hssfSheet = workbook.getSheetAt(0);
		//遍历标签页中所有的行
		for (Row row : hssfSheet) {
			System.out.println();
			for (Cell cell : row) {
				String value = cell.getStringCellValue();
				System.out.print(value + " ");
			}
		}
	}

3、pinyin4J


	
		
			com.belerweb
			pinyin4j
			2.5.0
		
@Test
	public void test1(){
		//河北省	石家庄市	桥西区
		String province = "河北省";
		String city = "石家庄市";
		String district = "桥西区";
		//简码---->>HBSJZQX
		
		province = province.substring(0, province.length() - 1);
		city = city.substring(0, city.length() - 1);
		district = district.substring(0, district.length() - 1);
		
		String info = province + city + district;
		
		String[] headByString = PinYin4jUtils.getHeadByString(info);
		String shortcode = StringUtils.join(headByString);
		System.out.println(shortcode);
		
		//城市编码---->>shijiazhuang
		String citycode = PinYin4jUtils.hanziToPinyin(city, "");
		System.out.println(citycode);
	}



你可能感兴趣的:(apache POI技术)