Apache POI to Create Excel Text Cell

Java Code Examples for

  • org.apache.poi.ss.usermodel.Cell.createCell()

The example below to create a new Excel file with one worksheet and a text cell using Apache POI library.

package simplesolution.dev;

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;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

public class RowCreateCellExample {

    public static void main(String... args) {
        Workbook workbook = new XSSFWorkbook();
        Sheet sheet = workbook.createSheet("Simple Solution");
        Row row = sheet.createRow(0);

        Cell cell = row.createCell(0);
        cell.setCellValue("Text in a Cell");

        String fileName = "D:\\Data\\sample.xlsx";
        try(OutputStream outputStream = new FileOutputStream(fileName)) {
        } catch (IOException ex) {

The output Excel file as below: Apache POI to Create Excel Text Cell

Happy Coding 😊

Writing Excel File Using Apache POI Library in Java

Apache POI Create new Excel sheet

Apache POI to Create Excel Date Time Cell in m/d/yy h:mm:ss Format

Apache POI Update Excel File Content