예제 #1
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);
        }
예제 #2
0
        private void CreateFormat(COBieAllowedType type, string formatString, string colourName)
        {
            var cellStyle  = XlsWorkbook.CreateCellStyle() as HSSFCellStyle;
            var dataFormat = XlsWorkbook.CreateDataFormat() as HSSFDataFormat;

            if (cellStyle == null || dataFormat == null)
            {
                Log.LogWarning("Error producing Excel cell style or format in workbook.");
                return;
            }

            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);
        }