0

I've just started using NPOI to generate xls file, but when I try the SetCellValue I got nothing writed on the excel. My code is :

            CellsCombined = New CellRangeAddress(0, 4, 2, 4)
            hoja.AddMergedRegion(CellsCombined)
            HSSFRegionUtil.SetBorderBottom(BorderStyle.Thin, CellsCombined, hoja, wb)
            HSSFRegionUtil.SetBorderLeft(BorderStyle.Thin, CellsCombined, hoja, wb)
            HSSFRegionUtil.SetBorderTop(BorderStyle.Thin, CellsCombined, hoja, wb)
            HSSFRegionUtil.SetBorderRight(BorderStyle.Thin, CellsCombined, hoja, wb)

            Dim boldFontTitulo As IFont = wb.CreateFont()
            boldFontTitulo.Boldweight = FontBoldWeight.Bold
            Dim boldTitulo As ICellStyle = wb.CreateCellStyle()
            boldTitulo.SetFont(boldFontTitulo)
            boldTitulo.Alignment = HorizontalAlignment.Left

            newCell = newRow.CreateCell(idxCell)
            newCell.SetCellType(CellType.String)

            newCell.CellStyle = boldTitulo
            newCell.SetCellValue(New HSSFRichTextString("My Text Here"))

First Edit

idxCell = 1 now, because before this cell, I've successfully inserted an image at the first cell

2nd Edit I tried only this without merging but nothing

newRow.CreateCell(idxCell, CellType.String).SetCellValue(New HSSFRichTextString("My text"))

1 Answers1

0

Well, the problem is to insert a text, you have to specify the correct cell index, even if the cells are merged, not like when you want to insert an image, you only increment the cell index (illogic but it worked) for my case the index was 1, but it have to be 2, and after writing my text, to insert the next image (Red one) the index have to be 3 indexes : 0 2 3

Image Of NPOI Result