【发布时间】:2019-03-21 20:20:15
【问题描述】:
我刚刚开始使用 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"))
【问题讨论】: