You need to declare a row and cell outside the sth loop as follows:
Dim dataCell As HSSFCell
Dim dataRow As HSSFRow
Then inside the loop, you assign the value and style to the cell separately as follows:
dataRow = sheetOne.CreateRow(i)
dataCell = dataRow.CreateCell(1)
dataCell.SetCellValue(i)
dataCell.CellStyle = cellStyle
dataRow = sheetOne.CreateRow(i)
dataCell = dataRow.CreateCell(2)
dataCell.SetCellValue(i)
dataCell.CellStyle = cellStyle
source
share