我刚刚开始使用NPOI生成xls文件,但是当我尝试SetCellValue时,我在excel上什么也没写。 我的代码是:
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"))
首次编辑
idxCell = 1,因为在此单元格之前,我已经在第一个单元格中成功插入了图像
第二次修改 我只尝试了此操作而没有合并,但是什么也没合并
newRow.CreateCell(idxCell, CellType.String).SetCellValue(New HSSFRichTextString("My text"))