//下記のURLでPOIのJARファイルをダウンロードする。 https://www.apache.org/dyn/closer.lua/poi/release/bin/poi-bin-3.17-20170915.tar.gz
import java.io.; import org.apache.poi.ss.usermodel.;
public class UpdateExcel { public static void main(String[] args) throws Exception { // Excel file File f = new File("C:\Book1.xlsx"); InputStream is = new FileInputStream(f); Workbook wb = WorkbookFactory.create(is); is.close();
// Sheet 1 Sheet s = wb.getSheetAt(0);
//第一行目 Row r0 = s.getRow(0); // A1 Cell A1 = r0.getCell(0); A1.setCellValue("W"); // A2 Cell A2 = r0.getCell(1); A2.setCellValue("K"); // A3 Cell A3 = r0.getCell(2); A3.setCellValue("O");
OutputStream os = new FileOutputStream(f);
wb.write(os);
}
}
Recommended Posts