I'm using VB and NPOI to write DATE data to an excel ROW.
I'm trying to use the following code to set the dataformat of the cell to "mm-dd-yy", but I keep getting an index out of range error when setting the cell.cellstyle.
There are a number of C examples of working code, but I'm trying this from VB.
Dim CELLfont as HSSFFont = XLworkbook.CreateFont
CELLfont.FontName = "Arial"
CELLfont.IsBold = True
Dim CELLstyle As HSSFCellStyle = XLworkbook.CreateCellStyle
With CELLstyle
.BorderRight = BorderStyle.Double
.SetFont(CELLfont)
.DataFormat = XLworkbook.CreateDataFormat().GetFormat( "mm-dd-yy" )
End With
For C As Integer = 0 to DTforEXCELdata.Columns.Count - 1
XLrow = XLsheet.CreateRow(XLrowCOUNTER)
XLrow.CreateCell(C)
XLrow.Cells(C).CellStyle = CELLstyle '**Error index out of range is here**
XLrow.Cells(C).SetCellValue(DATEvalue)
Next