다음 예제 코드와 예제 콘솔 출력을 참조하십시오. 이 코드는 소스 엑셀 파일을 읽고 셀 A1 ~ A10의 이름과 해당 값을 인쇄합니다.
자바
// Open the workbook with inputstream or filepath
Workbook wb = new Workbook();
wb.open("source.xlsx");
// Access first worksheet
Worksheet ws = wb.getWorksheets().getSheet(0);
// Read cells A1 to A10 and print their values
for (int i = 0; i < 10; i++) {
int row = i;
int col = 0;
// Access the cell by row and col indices
Cell cell = ws.getCells().getCell(row, col);
// Print cell name and its value
System.out.println(cell.getName() + ": " + cell.getStringValue());
}
샘플 콘솔 출력
A1: 13
A2: 16
A3: 87
A4: 73
A5: 69
A6: 91
A7: 59
A8: 46
A9: 82
A10: 54
참고 : 내가 Aspose에서 개발자 전도사로 일하고 있어요