コード例 #1
0
 public COBieAttributes(int order, COBieKeyType keyType, string referenceColumnName, COBieAttributeState state, string columnName, int maxLength, COBieAllowedType allowedType, COBieCardinality cardinality = COBieCardinality.OneToMany)
 {
     _state = state;
     _maxLength = maxLength;
     _allowedType = allowedType;
     _order = order;
     _columnName = columnName;
     _keyType = keyType;
     _referenceColumnName = referenceColumnName;
     _cardinality = cardinality;
 }
コード例 #2
0
        /// <summary>
        /// Create the cell style
        /// </summary>
        /// <param name="colourName">string</param>
        /// <param name="type">COBieAllowedType</param>
        private void CreateStyle(string colourName, COBieAllowedType type)
        {
            ICellStyle cellStyle;
            cellStyle = ExcelWorkbook.CreateCellStyle() ;

            if (IsXlsx)
            {
                ((XSSFCellStyle)cellStyle).FillForegroundXSSFColor = (XSSFColor)_colours[colourName];
            }
            else
            {
                    cellStyle.FillForegroundColor = _colours[colourName].Indexed;
            }
            
            cellStyle.FillPattern = FillPattern.SolidForeground;

            cellStyle.BorderBottom = BorderStyle.Thin;
            cellStyle.BorderLeft = BorderStyle.Thin;
            cellStyle.BorderRight = BorderStyle.Thin;
            cellStyle.BorderTop = BorderStyle.Thin;
            AppendFormat(type,cellStyle); //add format for value display

            // TODO:maybe clone from the template?
            var tuple = new Tuple<string, COBieAllowedType>(colourName, type);
            _cellStyles.Add(tuple, cellStyle);
        }
コード例 #3
0
 /// <summary>
 /// Append the required format depending on the COBieAllowedType
 /// </summary>
 /// <param name="type">COBieAllowedType</param>
 /// <param name="cellStyle">ICellStyle, style to ally formate to</param>
 private void AppendFormat(COBieAllowedType type, ICellStyle cellStyle)
 {
     string formatString = null;
     switch (type)
     {
         case COBieAllowedType.ISODate:
             formatString = "yyyy-MM-dd";
             break;
         case COBieAllowedType.ISODateTime:
             formatString = "yyyy-MM-ddThh:mm:ss";
             break;
         case COBieAllowedType.AlphaNumeric:
             break;
         case COBieAllowedType.Email:
             break;
         case COBieAllowedType.Numeric:
             break;
         case COBieAllowedType.Text:
             break;
         case COBieAllowedType.AnyType:
             break;
         default:
             break;
     }
     if (formatString != null)
     {
         IDataFormat dataFormat = ExcelWorkbook.CreateDataFormat();
         cellStyle.DataFormat = dataFormat.GetFormat(formatString);
     }
 }
コード例 #4
0
        private void CreateFormat(COBieAllowedType type, string formatString, string colourName)
        {
            HSSFCellStyle cellStyle;
            cellStyle = XlsWorkbook.CreateCellStyle() as HSSFCellStyle;
 
            HSSFDataFormat dataFormat = XlsWorkbook.CreateDataFormat() as HSSFDataFormat;
            cellStyle.DataFormat = dataFormat.GetFormat(formatString);
            
            cellStyle.FillForegroundColor = _colours[colourName].Indexed;
            cellStyle.FillPattern = FillPattern.SolidForeground;

            cellStyle.BorderBottom = BorderStyle.Thin;
            cellStyle.BorderLeft = BorderStyle.Thin;
            cellStyle.BorderRight = BorderStyle.Thin;
            cellStyle.BorderTop = BorderStyle.Thin;

            // TODO:maybe clone from the template?
            _cellStyles.Add(type, cellStyle);
        }