예제 #1
0
        public CODService()
        {
            Workbook = new HSSFWorkbook();

            BoldFont                    = Workbook.CreateFont();
            BoldFont.IsBold             = true;
            BoldFont.FontName           = "Calibri";
            BoldFont.FontHeightInPoints = 11;

            DefaultFont                    = Workbook.CreateFont();
            DefaultFont.FontName           = "Calibri";
            DefaultFont.FontHeightInPoints = 11;

            HeadStyle = Workbook.CreateCellStyle();
            HeadStyle.SetFont(BoldFont);

            GreenStyle = Workbook.CreateCellStyle();
            GreenStyle.SetFont(DefaultFont);
            GreenStyle.FillForegroundColor = HSSFColor.LightGreen.Index;
            GreenStyle.FillPattern         = FillPattern.BigSpots;
            GreenStyle.FillBackgroundColor = HSSFColor.LightGreen.Index;

            DefaultStyle = Workbook.CreateCellStyle();
            DefaultStyle.SetFont(DefaultFont);

            PresentationService = new PresentationService();
            JobService          = new JobService();
        }
예제 #2
0
        protected void FillPageSheet(ISheet sheet, CODModel model, Database db)
        {
            BuildRow(sheet, HeadStyle, GetPageValues());

            sheet.CreateFreezePane(0, 1, 0, 1);

            long line       = 0;
            var  totalLines = model.Pages.Count;

            foreach (KeyValuePair <Guid, Item> itm in model.Pages)
            {
                line++;

                var baseField = (DelimitedField)itm.Value.Fields[FieldIDs.BaseTemplate];
                var baseList  = baseField?.Items.Where(c => !c.Equals("{1930BBEB-7805-471A-A3BE-4858AC7CF696}"))
                                .Select(a => itm.Value.Database.GetItem(a))
                                .Where(b => b != null)
                                .Select(c => c.Name);
                var baseValue = baseList.Any() ? string.Join(", ", baseList) : "";

                var device          = (DeviceItem)itm.Value.Database.GetItem(DeviceId);
                var textInfo        = new CultureInfo("en-US", false).TextInfo;
                var standardValues  = db.Templates[itm.Value.ID].StandardValues;
                var placeholders    = PresentationService.GetPlaceholders(standardValues, DeviceId.ToString());
                var placeholderKeys = new List <string>();
                if (placeholders.Any())
                {
                    placeholderKeys = placeholders.Select(a => textInfo.ToTitleCase(a.Key.Replace("-", " "))).ToList();
                }
                var rendValue = string.Join(", ", placeholderKeys);

                BuildRow(sheet, GreenStyle, GetPageTemplateValues(itm.Value.Name, "Page", baseValue, rendValue));

                EnumerateTemplateFields(sheet, db, itm.Value, "");

                JobService.SetJobMessage($"Processed page item {line} of {totalLines}");
            }
        }