Java poi 操作Excel高版本

最近使用java导入高版本Excel技术,写下以后可能用到。

目前只有POI方式导入。导入POI3.5版本的 相关的jar包。

<!--StartFragment -->
 
	public static void main(String[] args) {

		XSSFWorkbook xs;
		try {
			xs = new XSSFWorkbook("D:/ss.xlsx");
			XSSFSheet sheet = xs.getSheetAt(0);
			XSSFRow rows = null;
			String cells = null;
			rows = sheet.getRow(0);
			// int xsRows = sheet.getPhysicalNumberOfRows();
			rows = sheet.getRow(0);
			for (int i = 0; i < sheet.getPhysicalNumberOfRows(); i++) {
				rows = sheet.getRow(i);
				cells = rows.getCell(0).toString();
				System.out.println(cells + " : " + rows.getCell(1).toString()
						+ " rows:" + rows.getCell(2).toString());
				for (int j = rows.getFirstCellNum(); j < rows
						.getPhysicalNumberOfCells() - 1; j++) {
					// 通过 row.getCell(j).toString() 获取单元格内容,
					System.out.print(rows.getCell(j).toString() + "  ");
				}
				System.out.println();
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
 

你可能感兴趣的:(java,poi,Excel)