Exemplo n.º 1
0
 public void CreateLink(SysConext.Rectangle rectangle, string sheetName)
 {
     NPOI.SS.UserModel.ISheet MenuSheet = excelWorkbook.GetSheet(sheetName);
     NPOI.SS.UserModel.ICellStyle hlink_style = excelWorkbook.CreateCellStyle();
     NPOI.SS.UserModel.IFont hlink_font = excelWorkbook.CreateFont();
     hlink_font.Underline = (byte)NPOI.SS.UserModel.FontUnderlineType.SINGLE;
     hlink_font.Color = NPOI.HSSF.Util.HSSFColor.BLUE.index;
     hlink_style.SetFont(hlink_font);
     NPOI.SS.UserModel.IRow newRow;
     newRow = MenuSheet.GetRow(rectangle.level);
     if (newRow == null)
         newRow = MenuSheet.CreateRow(rectangle.level);
     NPOI.SS.UserModel.ICell newcell = CreateCell(newRow, rectangle);
     NPOI.HSSF.UserModel.HSSFHyperlink link = new NPOI.HSSF.UserModel.HSSFHyperlink(NPOI.SS.UserModel.HyperlinkType.DOCUMENT);
     link.Address = ("'" + rectangle.titleName + "'!A1");
     newcell.Hyperlink = (link);
     newcell.CellStyle = (hlink_style);
 }
Exemplo n.º 2
0
 private NPOI.SS.UserModel.ICell CreateCell(NPOI.SS.UserModel.IRow newRow, SysConext.Rectangle rectangle)
 {
     NPOI.SS.UserModel.ICell newCell = newRow.GetCell(rectangle.col1);
     if (newCell == null)
         newCell = newRow.CreateCell(rectangle.col1);
     newCell.SetCellValue(rectangle.titleName);
     if (rectangle.isMegerCell)
         newsheet.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(rectangle.row1, rectangle.row2, rectangle.col1, rectangle.col2));
     return newCell;
 }
Exemplo n.º 3
0
 public void WriteCell(SysConext.Rectangle rectangle)
 {
     NPOI.SS.UserModel.IRow row = newsheet.GetRow(rectangle.row1);
     NPOI.SS.UserModel.ICell cell = row.GetCell(rectangle.col1);
     switch (rectangle.Celltype.ToLower())
     {
         case "string":
             cell.SetCellType(NPOI.SS.UserModel.CellType.STRING); cell.SetCellValue(rectangle.titleName); break;
         case "int":
         case "float":
         case "double":
             cell.SetCellType(NPOI.SS.UserModel.CellType.NUMERIC); cell.SetCellValue(Convert.ToDouble(rectangle.titleName)); break;
         case "bool":
             cell.SetCellType(NPOI.SS.UserModel.CellType.BOOLEAN); cell.SetCellValue(Convert.ToBoolean(rectangle.titleName)); break;
         case "datetime":
             cell.SetCellValue(Convert.ToDateTime(rectangle.titleName)); break;
         default:
             cell.SetCellValue(rectangle.titleName); break;
     }
 }