package com.github.vmbenchmarks;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CreationHelper;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.openjdk.jmh.annotations.Benchmark;

public class GeneratePoiWorkBook {

    public static AtomicInteger counter = new AtomicInteger(1);
    
    @Benchmark
    public void generatePoiWorkBook() throws IOException {
        Workbook wb = new HSSFWorkbook();
        //Workbook wb = new XSSFWorkbook();
        CreationHelper createHelper = wb.getCreationHelper();
        Sheet sheet = wb.createSheet("new sheet");

        // Create a row and put some cells in it. Rows are 0 based.
        Row row = sheet.createRow((short) 0);
        // Create a cell and put a value in it.
        Cell cell = row.createCell(0);
        cell.setCellValue(counter.incrementAndGet());

        // Or do it on one line.
        row.createCell(1).setCellValue(1.2);
        row.createCell(2).setCellValue(
                createHelper.createRichTextString("This is a string"));
        row.createCell(3).setCellValue(true);
        wb.write(new ByteArrayOutputStream());
    }

}

@@ -139,24 +139,71 @@
 micInteger;%0A
+import java.util.concurrent.atomic.AtomicLong;%0A
 import org.a
@@ -475,90 +475,306 @@
 org.
-openjdk.jmh.annotations.Benchmark;%0A%0Apublic class GeneratePoiWorkBook %7B%0A%0A    public
+apache.poi.xssf.usermodel.XSSFWorkbook;%0Aimport org.openjdk.jmh.annotations.Benchmark;%0Aimport org.openjdk.jmh.annotations.State;%0A%0Apublic class GeneratePoiWorkBook %7B%0A%0A    static AtomicInteger xlsCellCount = new AtomicInteger(20000);%0A    static AtomicLong  xlsCount = new AtomicLong(100000L);%0A    %0A   
  sta
@@ -791,23 +791,29 @@
 Integer 
-c
+xlsxCellC
 ount
-er
  = new A
@@ -825,17 +825,81 @@
 Integer(
-1
+20000);%0A    static AtomicLong  xlsxCount = new AtomicLong(100000L
 );%0A    %0A
@@ -932,32 +932,35 @@
 void generatePoi
+XLS
 WorkBook() throw
@@ -1406,15 +1406,20 @@
 lue(
-c
+xlsCellC
 ount
-er
 .inc
@@ -1512,11 +1512,34 @@
 lue(
-1.2
+xlsCount.incrementAndGet()
 );%0A 
@@ -1631,26 +1631,903 @@
 ing(
-%22This is a string%22
+Long.toString(xlsCount.get())));%0A        row.createCell(3).setCellValue(true);%0A        wb.write(new ByteArrayOutputStream());%0A    %7D%0A     @Benchmark%0A    public void generatePoiXLSXWorkBook() throws IOException %7B%0A        Workbook wb = new XSSFWorkbook();%0A        //Workbook wb = new XSSFWorkbook();%0A        CreationHelper createHelper = wb.getCreationHelper();%0A        Sheet sheet = wb.createSheet(%22new sheet%22);%0A%0A        // Create a row and put some cells in it. Rows are 0 based.%0A        Row row = sheet.createRow((short) 0);%0A        // Create a cell and put a value in it.%0A        Cell cell = row.createCell(0);%0A        cell.setCellValue(xlsxCellCount.incrementAndGet());%0A%0A        // Or do it on one line.%0A        row.createCell(1).setCellValue(xlsxCount.incrementAndGet());%0A        row.createCell(2).setCellValue(%0A                createHelper.createRichTextString(Long.toString(xlsxCount.get())
 ));%0A
@@ -2625,11 +2625,10 @@
 ;%0A    %7D%0A
-%0A
 %7D%0A

add XLS