private void CreateWorkbook(string resource)
        {
            Workbook workbook;

            if (string.IsNullOrEmpty(resource))
            {
                workbook = new Workbook();
                workbook.Worksheets.Add("Sheet1");
            }
            else
            {
                using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource))
                {
                    workbook = Workbook.Load(stream);
                }

                Worksheet sheet2 = workbook.Worksheets[2];
                OperatorConditionalFormat condition1 = sheet2.ConditionalFormats.AddOperatorCondition("C5:C28", Infragistics.Documents.Excel.ConditionalFormatting.FormatConditionOperator.GreaterEqual);
                condition1.SetOperand1(2500);
                condition1.CellFormat.Font.ColorInfo = new WorkbookColorInfo(Color.Red);

                OperatorConditionalFormat condition2 = sheet2.ConditionalFormats.AddOperatorCondition("C5:C28", FormatConditionOperator.Less);
                condition2.SetOperand1(2500);
                condition2.CellFormat.Font.ColorInfo = new WorkbookColorInfo(Color.Green);
            }
            this.OnNewWorkbookSelected(workbook);
        }
Example #2
0
        private void CreateNewDocument(string templateName)
        {
            var tempDocumentName = string.Format(ResourceStrings.ResourceStrings.Text_TempDocumentName, 1);

            if (DocumentStatus == IgExcelDocumentStatus.NoDocumentLoaded ||
                DocumentStatus == IgExcelDocumentStatus.ExistingNotModified ||
                DocumentStatus == IgExcelDocumentStatus.BlankNotModified ||
                DocumentStatus == IgExcelDocumentStatus.TemplateNotModified)
            {
                LoadTemplate(templateName);
                SetTitle(tempDocumentName);

                if (templateName == "ProjectBudget" && this.Workbook != null)
                {
                    Worksheet sheet = this.Workbook.Worksheets[2];

                    OperatorConditionalFormat format1 = sheet.ConditionalFormats.AddOperatorCondition("C5:C28", Infragistics.Documents.Excel.ConditionalFormatting.FormatConditionOperator.GreaterEqual);
                    format1.SetOperand1(2500);
                    format1.CellFormat.Font.ColorInfo = new WorkbookColorInfo(System.Drawing.Color.Red);

                    OperatorConditionalFormat format2 = sheet.ConditionalFormats.AddOperatorCondition("C5:C28", Infragistics.Documents.Excel.ConditionalFormatting.FormatConditionOperator.Less);
                    format2.SetOperand1(2500);
                    format2.CellFormat.Font.ColorInfo = new WorkbookColorInfo(System.Drawing.Color.Green);
                }

                this.IsBackstageOpened        = false;
                this.IsSpreadSheetVisible     = true;
                this.FileNameWithoutExtension = tempDocumentName;
            }
            else
            {
                var result = this.messageBoxService.Show(ResourceStrings.ResourceStrings.Text_ApplicationTitle, string.Format(ResourceStrings.ResourceStrings.Msg_WantToSaveChanges, tempDocumentName), MessageBoxButtons.YesNoCancel);

                if (result == InteractionResult.Yes)
                {
                    this.isNewTemplateRequested = true;
                    this.selectedTemplateName   = templateName;

                    ExecuteSaveDocument();
                }
                else if (result == InteractionResult.No)
                {
                    LoadTemplate(templateName);
                    SetTitle(tempDocumentName);

                    this.FileNameWithoutExtension = tempDocumentName;
                    this.IsBackstageOpened        = false;
                }
                else
                {
                    this.IsBackstageOpened = false;
                }
            }

            this.IsUiPartEnabled = true;
        }