コード例 #1
0
ファイル: CellRange.cs プロジェクト: crossleyjuan/BAExcel
 public static CellRange CreateCellRange(CellPos start, CellPos end)
 {
     return new CellRange
     {
         StartRange = start,
         EndRange = end
     };
 }
コード例 #2
0
ファイル: SheetWrapper.cs プロジェクト: crossleyjuan/BAExcel
        public void ApplyStyle(CellPos pos, string name)
        {
            ICellStyle style = _parent.GetStyle(name);

             ICell cell = GetCell(pos, false);
             if (cell != null)
             {
                 cell.CellStyle = style;
             }
        }
コード例 #3
0
ファイル: SheetWrapper.cs プロジェクト: crossleyjuan/BAExcel
 public string GetText(CellPos pos)
 {
     ICell cell = GetCell(pos, false);
     if (cell != null)
     {
         return cell.StringCellValue;
     }
     else
     {
         return null;
     }
 }
コード例 #4
0
ファイル: SheetWrapper.cs プロジェクト: crossleyjuan/BAExcel
        public void SetText(CellPos pos, string text)
        {
            List<TextPosition> positions = new List<TextPosition>();

            while (text.IndexOf("<b>") > -1)
            {
                int start = text.IndexOf("<b>");

                text = text.Substring(0, start) + text.Substring(start + 3);
                int end = text.IndexOf("</b>");
                text = text.Substring(0, end) + text.Substring(end + 4);
                positions.Add(new TextPosition { start = start, end = end });
            }
            HSSFRichTextString richtext = new HSSFRichTextString(text);
            IFont font1 = _parent.Internal.CreateFont();
            font1.Boldweight = (short)FontBoldWeight.Bold;
            foreach (TextPosition position in positions)
            {
                richtext.ApplyFont(position.start, position.end, font1);
            }

            ICell cell = GetCell(pos, true);
            cell.SetCellValue(richtext);
        }
コード例 #5
0
ファイル: SheetWrapper.cs プロジェクト: crossleyjuan/BAExcel
 private ICell GetCell(CellPos pos, bool create)
 {
     IRow row = _sheet.GetRow(pos.Row);
     if (row == null)
     {
         if (create == true)
         {
             row = _sheet.CreateRow(pos.Row);
         }
         else
         {
             return null;
         }
     }
     ICell cell = row.GetCell(pos.Col);
     if (cell == null)
     {
         if (create == true)
         {
             cell = row.CreateCell(pos.Col);
         }
         else
         {
             return null;
         }
     }
     return cell;
 }