import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.WorkbookFactory; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import java.io.*; public class Sample2_1{ public static void main(String[] args){ FileInputStream in = null; Workbook wb = null; try{ in = new FileInputStream("sample.xls"); wb = WorkbookFactory.create(in); }catch(IOException e){ System.out.println(e.toString()); }catch(InvalidFormatException e){ System.out.println(e.toString()); }finally{ try{ in.close(); }catch (IOException e){ System.out.println(e.toString()); } } Sheet sheet = wb.getSheetAt(0); Row row1 = sheet.getRow(1); Row row2 = sheet.createRow(2); for (int i = 0 ; i < 6 ; i++){ Cell cell = row1.getCell(i); if (cell != null){ row2.createCell(i).setCellValue("Check!"); } } FileOutputStream out = null; try{ out = new FileOutputStream("sample2_1.xls"); wb.write(out); }catch(IOException e){ System.out.println(e.toString()); }finally{ try { out.close(); }catch(IOException e){ System.out.println(e.toString()); } } } }