** anyframe 설치

-. anyframe-x.x.0.zip 파일 다운로드

-. anyframe-x.x.0.zip 압축 해제

-. ANYFRAME_HOME 을 시스템 환경 변수 설정
ex) D:\JAVA\anyframe\anyframe-5.1.0

** eclipse anyframe plug-in 설치
1. anyframe-x.x.0.zip 을 이용한 설치 (잘 안됨 maven을 추천)
-. D:\JAVA\anyframe\anyframe-5.1.0\ide\eclipse-plugins 에 위치한
org.anyframe.common.eclipse.core-4.0.2.jar
org.anyframe.ide.eclipse.core_2.1.0.v20111021.jar

jar 파일을 eclipse plugin 폴더에 복사

D:\JAVA\eclipse\eclipse-jee-indigo-win32\plugins 에 복사

1. maven 을 이용한 network 설치
-. http://dev.anyframejava.org/docs/anyframe/5.1.0/reference/html/ch08.html#installation_eclipseide_maven

** anyframe 프로젝트 생성
1. eclipse 에서 생성 (잘 안됨 ant 명령어로 생성을 추천)
-. FILE > NEW > OTHER > ANYFRAME > PROJECT 로 생성

2. ant 명령어로 생성
-. 커맨드창 실행
-. ANYFRAME_HOME\bin 폴더로 이동
-. ANYFRAME_HOME 환경변수를 설정했다면 ANYFRAME_HOME\bin\env 실행.
-. ANYFRAME_HOME 을 설정 안했다면 아래 명령어 실행 후 env 실행
set ANYFRAME_HOME=D:\JAVA\anyframe\anyframe-5.1.0

-. DB 실행
(내장된 hsqldb 을 실행 D:\JAVA\anyframe\anyframe-5.1.0\ide\db\scripts\hsqldb\start.cmd 실행)
(oracle 일 경우 D:\JAVA\anyframe\anyframe-5.1.0\ide\db\scripts\oracle 스크립트를 실행하여 예제 테이블을 생성)
(예제 DB 스키마가 필요없을 경우 그냥 넘김)
-. anyframe create-project 명령 실행
http://dev.anyframejava.org/docs/anyframe/5.1.0/reference/html/ch10.html#commands_ant_commands_list
-. 프로젝트 생성 후 eclipse 에서 프로젝트를 우클릭하여 ANYFRAME_TOOL > ANYFRAME_IDE 를 실행
-. 프로젝트에 필요한 plugin을 설치한다.

-. 해당 프로젝트에 META-INF/project.mf 파일에 설정된 셋팅을 확인 또는 변경한다.


NumberFormat nf = NumberFormat.getNumberInstance();
nf.setMinimumFractionDigits(2); nf.setMaximumFractionDigits(2);
nf.format(doubleValue);

파라미터 같은 변수를 &P_VAL 로 하면 실행시 파라미터 값을 입력하는 창이 나온다.

tracert 192.168.0.1

192.168.0.1 까지 가는 경로를 보여준다.

ping 192.168.0.1
Iterator roof

Sheet sheet = wb.getSheetAt(0);
for (Iterator<Row> rit = sheet.rowIterator(); rit.hasNext(); ) {
    Row row = rit.next();
    for (Iterator<Cell> cit = row.cellIterator(); cit.hasNext(); ) {
    Cell cell = cit.next();
    // Do something here
    }
}

-. Quick Ref.
http://poi.apache.org/spreadsheet/quick-guide.html

-. HOW TO
http://poi.apache.org/spreadsheet/how-to.html


Iterate over rows and cells

Sometimes, you'd like to just iterate over all the rows in a sheet, or all the cells in a row. This is possible with a simple for loop.

Luckily, this is very easy. Row defines a CellIterator inner class to handle iterating over the cells (get one with a call to row.cellIterator()), and Sheet provides a rowIterator() method to give an iterator over all the rows.

Alternately, Sheet and Row both implement java.lang.Iterable, so using Java 1.5 you can simply take advantage of the built in "foreach" support - see below.

	Sheet sheet = wb.getSheetAt(0);
	for (Iterator<Row> rit = sheet.rowIterator(); rit.hasNext(); ) {
		Row row = rit.next();
		for (Iterator<Cell> cit = row.cellIterator(); cit.hasNext(); ) {
			Cell cell = cit.next();
			// Do something here
		}
	}
				

Iterate over rows and cells using Java 1.5 foreach loops

Sometimes, you'd like to just iterate over all the rows in a sheet, or all the cells in a row. If you are using Java 5 or later, then this is especially handy, as it'll allow the new foreach loop support to work.

Luckily, this is very easy. Both Sheet and Row implement java.lang.Iterable to allow foreach loops. For Row this allows access to the CellIterator inner class to handle iterating over the cells, and for Sheet gives the rowIterator() to iterator over all the rows.

	Sheet sheet = wb.getSheetAt(0);
	for (Row row : sheet) {
		for (Cell cell : row) {
			// Do something here
		}
	}


Getting the cell contents

To get the contents of a cell, you first need to know what kind of cell it is (asking a string cell for its numeric contents will get you a NumberFormatException for example). So, you will want to switch on the cell's type, and then call the appropriate getter for that cell.

In the code below, we loop over every cell in one sheet, print out the cell's reference (eg A3), and then the cell's contents.

// import org.apache.poi.ss.usermodel.*;

Sheet sheet1 = wb.getSheetAt(0);
for (Row row : sheet1) {
	for (Cell cell : row) {
		CellReference cellRef = new CellReference(row.getRowNum(), cell.getCellNum());
		System.out.print(cellRef.formatAsString());
		System.out.print(" - ");
		
		switch(cell.getCellType()) {
      case Cell.CELL_TYPE_STRING:
        System.out.println(cell.getRichStringCellValue().getString());
        break;
      case Cell.CELL_TYPE_NUMERIC:
        if(DateUtil.isCellDateFormatted(cell)) {
          System.out.println(cell.getDateCellValue());
        } else {
          System.out.println(cell.getNumericCellValue());
        }
        break;
      case Cell.CELL_TYPE_BOOLEAN:
        System.out.println(cell.getBooleanCellValue());
        break;
      case Cell.CELL_TYPE_FORMULA:
        System.out.println(cell.getCellFormula());
        break;
      default:
        System.out.println();
		}
	}
}
 

+ Recent posts