public void actionPerformed(ActionEvent e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
log.append("begin to convert ..." + TLSwing.newline);
if (txt_source.getText().equals("")) {
log.append("please input source file...");
} else {
log.append("begin to convert ..." + txt_source.getText() + TLSwing.newline);
file_source = new File(txt_source.getText());
try {
in = new FileInputStream(file_source);
if (file_source.getName().endsWith("xlsx")) {
workbook = new XSSFWorkbook(in);
XSSFSheet sheet = workbook.getSheetAt(0);
Sheet sheet2 = workbook.getSheetAt(0);
for (Row row : sheet2) {
if (row.getRowNum() != 0) {
for (Cell cell : row) {
// log.append(getCellValue(sheet.getRow(2).getCell(2)));
log.append(getCellValue((XSSFCell) cell) + TLSwing.newline);
try {
Thread.currentThread().sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace(pw);
log.append("InterruptedException"+TLSwing.newline+sw.toString()+TLSwing.newline);
}
}
}
}
} else {
}
} catch (IOException e1) {
e1.printStackTrace(pw);
log.append("IOException"+TLSwing.newline+sw.toString()+TLSwing.newline);
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e2) {
e2.printStackTrace(pw);
log.append("IOException"+TLSwing.newline+sw.toString()+TLSwing.newline);
}
}
}
}
}
}).start();
}