直接上代码
pom引入:
org.jxls
jxls-jexcel
1.0.6
代码实现
try {
// List arr[] = new ArrayList<>();
FileInputStream file = new FileInputStream("E://one.xls");
// File file = new File("E://one.xls"); // 创建文件对象
Workbook wb = Workbook.getWorkbook(file); // 从文件流中获取Excel工作区对象(WorkBook)
Sheet sheet = wb.getSheet(0); // 从工作区中取得页(Sheet)
for (int i = 0; i < sheet.getRows(); i++) { // 循环打印Excel表中的内容
for (int j = 0; j < sheet.getColumns(); j++) {
//for (int j = 0; j < 195; j++) {
Cell cell = sheet.getCell(j, i);
// System.out.printf(cell.getContents()+" ");
StringBuffer ss = new StringBuffer();
String[] chrstr = cell.getContents().split("_");
for(int k=0;k<chrstr.length;k++){
// System.out.println(chrstr[1]+k);
// ss.append(chrstr[0].toLowerCase());
// ss.append(chrstr[1].substring(0,1).toUpperCase().concat(chrstr[1].substring(1).toLowerCase()));
// ss.append(chrstr[2].substring(0,1).toUpperCase().concat(chrstr[2].substring(1).toLowerCase()));
String aa = cell.getContents().split("_")[cell.getContents().split("_").length-1];
if( k == 0){
System.out.println( chrstr[0].toLowerCase()
+ chrstr[1].substring(0,1).toUpperCase().concat(chrstr[1].substring(1).toLowerCase())+
aa.substring(0,1).toUpperCase().concat(aa.substring(1).toLowerCase())
);
}
// System.out.println(chrstr[2].substring(0,1).toUpperCase().concat(chrstr[2].substring(1).toLowerCase()));
}
}
// System.out.println(i);
}
} catch (Exception e) {
e.printStackTrace();
}
}