jxl excel 파일 읽기 만들기

1332 단어 Excel

package test;

import java.io.File;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;

public class JExcelTest {
	public static void main(String[] args) {
		// excel
		try {
			WritableWorkbook book = Workbook.createWorkbook(new File("test.xls"));
			WritableSheet sheet = book.createSheet(" ", 0);
			Label label = new Label(0, 0, "test");
			sheet.addCell(label);

			jxl.write.Number number = new jxl.write.Number(1, 0, 123.2);
			sheet.addCell(number);

			book.write();
			book.close();
		} catch (Exception e) {
			e.printStackTrace();
		}

		// excel
		try {
			Workbook book = Workbook.getWorkbook(new File("test.xls"));
			Sheet sheet=book.getSheet(0);
			Cell cell1=sheet.getCell(1,0);
			String result=cell1.getContents();
			System.out.println(result);
			book.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

프로그래머예요, 디자이너?미션 중국으로 오세요.

좋은 웹페이지 즐겨찾기