();//用于模板固定字符替换
public Exxx(String url, int rowNum) {
File file = new File(url);
String realPath = ("H://uploadfile");
String newFileName = System.currentTimeMillis() + ".xlsx";
// 判断路径是否存在
File dir = new File(realPath);
if (!dir.exists()) {
dir.mkdirs();
}
// 写入到新的excel
File newFile = new File(realPath, newFileName);
try {
newFile.createNewFile();
// 写数据
fileChannelCopy(file, newFile);
InputStream io = new FileInputStream(newFile);
this.workbook = new XSSFWorkbook(io);// 创建workbook,
this.sheet = workbook.getSheetAt(0);//获取工作表(1)
if(sheet!=null) {
this.fos = new FileOutputStream(newFile);
}else {
log.debug("Write error: ["+row.getRowNum()+"] 数据为空");
}
//检测是否有数据,因为是走的模板所以不需要
row = sheet.getRow(5);
if (row == null) {
row = sheet.createRow(5);
}
XSSFCell cell = row.getCell(1);
if (cell == null) {
cell = row.createCell(1);
}
} catch (Exception e) {
e.printStackTrace();
}
this.rowNum = rowNum;
}
/**
*
*@param m当前插入行数
*@return Row对象
*/
publi