2013년 10월 17일 목요일

excel - File formats that are supported in Excel

0. JAVA Excel API
 JAVA Excel API크게 두가지가 있다.
1. Exception in thread "main" java.lang.IllegalArgumentException: Sheet index (0) is out of range (0..-1)
 그런데 위 API를 사용하던 중 위 에러를 만나게 되었는데, 삽질도 이런 삽질이 없다. -_-; 
 원인은 Excel 2007 부터 다양한 포맷을 지원하기 때문인데 POI의 overview를 보면..
HSSF is the POI Project's pure Java implementation of the Excel '97(-2007) file format. XSSF is the POI Project's pure Java implementation of the Excel 2007 OOXML (.xlsx) file format.
 위와 같이 나와 있는데 결국은 OOXML 파일 포맷을 지원한다는 말이다.
 즉 파일 확장자는 xls 이지만 파일 포멧을 확인하지 않고 작업을 하면 위의 에러를 만나게 된다.

2. File formats that are supported in Excel
http://office.microsoft.com/en-us/excel-help/file-formats-that-are-supported-in-excel-HP010014103.aspx
 위 사이트를 방문해 보면 Excel도 크게 Excel formats, Text formats, Other formats, Clipboard formats 이렇게 나눠져 있는 것을 알수 있다. 작업할 excel 파일을 열고 save as 해보면 어떤 포맷으로 저장되어 있는지 확인 할 수 있다.

3. JAVA HTML Parser
저의 경우 Excel 파일을 가장한 HTML 파일이더군요. 그래서 이번에는 HTML Parser가 필요합니다. jsoup 이라는 library가 있네요.
jsoup is a Java library for working with real-world HTML. It provides a very convenient API for extracting and manipulating data, using the best of DOM, CSS, and jquery-like methods.
http://jsoup.org/

댓글 없음:

댓글 쓰기