日期:2014-05-20  浏览次数:21184 次

NPOI创建批注
不知道大家有没有到,用NPOI创建单元格批注时,创建多行批注,只有最有一格创建成功,其它的批注莫名其妙的不见了,如代码:
 HSSFPatriarch patr1 = sheet.CreateDrawingPatriarch() as HSSFPatriarch;
                    HSSFComment comment1 = patr1.CreateCellComment(new HSSFClientAnchor(0, 0, 0, 0, 1, 3, 3, 7)) as HSSFComment;
                    comment1.String = new HSSFRichTextString("作者:\n0");
                    HSSFCell hssfcell1 = sheet.CreateRow(5).CreateCell(1) as HSSFCell;
                    hssfcell1.CellComment=comment1;

                    HSSFPatriarch patr2 = sheet.CreateDrawingPatriarch() as HSSFPatriarch;
                    HSSFComment comment2 = patr2.CreateCellComment(new HSSFClientAnchor(5, 0, 5, 0, 2, 3, 4,8)) as HSSFComment;

                    comment2.String = new HSSFRichTextString("\n1");
                    comment1.Author = "Wicrosoft";

                    HSSFCell Hssfcell2 = sheet.CreateRow(5).CreateCell(2) as HSSFCell;
                    Hssfcell2.CellComment = comment2;
------解决方案--------------------
好吧,没人回答。我自己回答
using (Workbook wkBook = new HSSFWorkbook())
            {
                using (Sheet sheet = wkBook.CreateSheet("Sheet"))
                {
                    #region MyRegion
                    Row row = sheet.CreateRow(5);
                    //Cell cell1 = row.CreateCell(0);
                    //cell1.SetCellValue(0);
                    //Cell cell2 = row.CreateCell(1);
                    //cell2.SetCellValue(1);
                    //Cell cell3 = row.CreateCell(2);
                    //cell3.SetCellValue(2);