250x250
Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- JavaScript
- AJAX
- JDBC
- MSSQL
- SpringBoot
- ubuntu
- spring
- Thymeleaf
- 문서
- Open Source
- Spring Boot
- PostgreSQL
- jpa
- Source
- STS
- maven
- MySQL
- error
- Exception
- oracle
- git
- IntelliJ
- Docker
- 오픈소스
- Eclipse
- myBatis
- Tomcat
- Core Java
- 설정
- Python
Archives
- Today
- Total
헤르메스 LIFE
jxl의 사용 본문
728x90
홈페이지 : http://nexcel.sourceforge.net/
다운로드 : http://www.andykhan.com/jexcelapi/download.html
API : http://www.andykhan.com/jexcelapi/
import java.io.File;
import java.io.FileNotFoundException;
import jxl.Cell;
import jxl.CellType;
import jxl.Sheet;
import jxl.Workbook;
public class JxlTest {
public static void main(String[] args) {
try {
File file_1 = new File("c:\test.xls"); // Excel파일을 읽음.
Workbook workbook = Workbook.getWorkbook(file_1); // Workbook을 읽음.
Sheet sheet = workbook.getSheet(0); // 1번째 Sheet를 읽음.
for (int i=0; i < sheet.getRows(); ++i) { // Sheet의 로우수만큼 읽음.
Cell[] currCell = sheet.getRow(i) ; // 한개로우를 읽어서 Cell 배열에 담음.
for (int j = 0; j < currCell.length; j++){ // Cell의 갯수만큼 돌면서 출력.
System.out.println(currCell[j].getContents()); // Cell만큼 출력.
}
}
} catch(FileNotFoundException fnfe) {
fnfe.printStackTrace();
} catch(Exception e) {
e.printStackTrace();
}
}
}
문제점.
마지막셀이 공백이면 ArrayIndexOutOfBoundsException 이 뜸.
별도의 처리가 필요.
728x90
'Core Java' 카테고리의 다른 글
BigDecimal타입의 사칙연산 (0) | 2020.12.17 |
---|---|
Java에서 Stored Procedure 실행 (0) | 2020.12.17 |
JDBC 버전확인 (0) | 2020.12.17 |
HttpURLConnection 이용시 헤더값 세팅 방법 (0) | 2020.12.17 |
[오픈소스] DBConnectionManager.java (0) | 2020.12.17 |