java
java use to excel modify
Java use to Excel Modify
import java.io.FileInputStream;
import java.io.FileOutputStream;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
public class excelWrite {
public static void main(String[] args) throws Exception {
FileInputStream fis = new FileInputStream("C://test/22222.xls");
POIFSFileSystem fs = new POIFSFileSystem(fis);
HSSFWorkbook wb = new HSSFWorkbook(fs);
Sheet sheet = wb.getSheetAt(0);
System.out.println(sheet.getSheetName());
Row row = sheet.getRow(3);
Cell cell = row.getCell((short)5);
cell.setCellType(Cell.CELL_TYPE_STRING);
cell.setCellValue("홍길동");
System.out.println(" ==================");
System.out.println(cell.getStringCellValue());
System.out.println(" ==================");
cell = row.getCell((short)10);
cell.setCellType(Cell.CELL_TYPE_STRING);
cell.setCellValue("555555");
row = sheet.getRow(5);
cell = row.getCell((short)5);
cell.setCellType(Cell.CELL_TYPE_STRING);
cell.setCellValue("www.google.com");
FileOutputStream fileout = new FileOutputStream("C://test/22222Save.xls");
wb.write(fileout);
fileout.close();
}
}
댓글 쓰기
0 댓글