poi excel 쓰기

1905 단어 Excel
Poi-3.6의jar 가방을 사용합니다.

package com.demo;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;



public class Test
{
	public static void main(String[] args)
	{
		
		try
		{
			Workbook wb = new HSSFWorkbook();
			FileOutputStream fileOut = new FileOutputStream(" .xls");
			//wb.write(fileOut);
			//fileOut.close();
			
			Sheet sheet1 = wb.createSheet("shit1");
			Sheet sheet2 = wb.createSheet("shit2");
			
			/*Row row1 = sheet1.createRow(0);
			Row row2 = sheet1.createRow(3);
			Cell cell1 = row1.createCell(0);
			Cell cell2 = row1.createCell(2);
			cell1.setCellValue("cell1 ");
			cell2.setCellValue("cell2 ");*/
			
			
			Row row = null;
			for(int i=0; i<5; i++)
			{
				row = sheet1.createRow(i);
				row.createCell(0).setCellValue(" ");
				row.createCell(1).setCellValue(" ");
				row.createCell(2).setCellValue(" ");
				row.createCell(3).setCellValue(" ");
			}
			// , row 。
			
			
			wb.write(fileOut);
			fileOut.close();
			
			
		}
		catch (FileNotFoundException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		catch (IOException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		
		
	}
}

좋은 웹페이지 즐겨찾기