문제

FNAME, SNAME 및 ASERS와 같은 직원에 대한 정보를 보유하고있는 ArrayList가 있습니다.Apache Poi를 사용하여 Excel 통합 문서에이를 작성하고 있습니다.

Excel 시트에서 한 직원의 모든 정보가 동일한 행에 오도록 원합니다.나는 행 1과 셀 0에 이름을 쓸 수 있습니다 (행 0은 표제를 보유하고 있음).모든 것이 수직으로 좋은 순서입니다.성을 추가하려고 할 때 모든 것이 여기에서 점프하기 시작합니다.

어떻게 해당 하자리에 서있는 일치합니까?

여기에 내 Excel 코드의 일부가 있습니다

private void writeEmployeeInfo() {

    ListIterator<Employee> employeeListIterator = Employee
            .getEmployeeList().listIterator();

    int rowIndex = 1;
    int cellIndex = 0;


    while (employeeListIterator.hasNext()) {

        Employee employee = employeeListIterator.next();

        Row row = sheet.createRow(rowIndex++);

        Cell cell = row.createCell(cellIndex);

        cell.setCellValue(employee.getfName());
.

// 올바른 셀에 직원의 성을 추가하려고합니다.

            while(employeeListIterator.hasNext()){
            Employee emp = employeeListIterator.next();
            row = sheet.createRow(rowIndex++);
            cell = row.createCell(cellIndex++);
            cell.setCellValue(emp.getsName());
        }
    }
}
.

여기에 첫 번째 게시물이므로 내가 가난한 방식을 작성하거나 행할 수있는 일을 말해 주시면 사람들이 내 질문을 이해할 수 있도록 쉽게 할 수 있습니다.

더 많은 코드를 볼 필요가있는 경우 프로젝트에 대한 링크가 있습니다. http://1drv.ms/1ksgfdm

도움이 되었습니까?

해결책

다른 셀을 어떻게 추가하고 있습니까?다음과 같이 시도하십시오 :

private void writeEmployeeInfo() {

    ListIterator<Employee> employeeListIterator = Employee
            .getEmployeeList().listIterator();

    int rowIndex = 1;

    while (employeeListIterator.hasNext()) {

        Employee employee = employeeListIterator.next();

        Row row = sheet.createRow(rowIndex++);

        row.createCell(0).setCellValue(employee.getfName());
        row.createCell(1).setCellValue(employee.getSName());
        row.createCell(2).setCellValue(employee.getAddress);
    }
}
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top