Example #1
0
        internal void FromConditionalFormatting(X14.ConditionalFormatting cf)
        {
            this.SetAllNull();

            if (cf.Pivot != null)
            {
                this.Pivot = cf.Pivot.Value;
            }

            using (OpenXmlReader oxr = OpenXmlReader.Create(cf))
            {
                while (oxr.Read())
                {
                    SLConditionalFormattingRule2010 cfr;
                    if (oxr.ElementType == typeof(X14.ConditionalFormattingRule))
                    {
                        cfr = new SLConditionalFormattingRule2010();
                        cfr.FromConditionalFormattingRule((X14.ConditionalFormattingRule)oxr.LoadCurrentElement());
                        this.Rules.Add(cfr);
                    }
                    else if (oxr.ElementType == typeof(Excel.ReferenceSequence))
                    {
                        Excel.ReferenceSequence refseq = (Excel.ReferenceSequence)oxr.LoadCurrentElement();
                        this.ReferenceSequence = SLTool.TranslateRefSeqToCellPointRange(refseq);
                    }
                }
            }
        }
Example #2
0
        static void GenerateWorksheetPartContent(WorksheetPart worksheetPart, DataTable dataTable)
        {
            var worksheet = new Worksheet();
            var sheetData = new SheetData();

            ExportDataTable(sheetData, dataTable);
            worksheet.Append(sheetData);

            if (dataTable.TableName != "Дата")
            {
                var worksheetExtensionList = new WorksheetExtensionList();
                var worksheetExtension     = new WorksheetExtension {
                    Uri = WorksheetExtensionUri
                };
                var dataValidations = new X14.DataValidations {
                    Count = (UInt32Value)1U
                };
                var dataValidation = new X14.DataValidation {
                    Type = DataValidationValues.List, AllowBlank = true, ShowInputMessage = true, ShowErrorMessage = true
                };
                var dataValidationForumla1 = new X14.DataValidationForumla1();
                var formula = new Excel.Formula {
                    Text = "Дата!$B$2:$B$4"
                };

                dataValidationForumla1.Append(formula);
                var referenceSequence = new Excel.ReferenceSequence {
                    Text = "F2:F4"
                };

                dataValidation.Append(dataValidationForumla1);
                dataValidation.Append(referenceSequence);
                dataValidations.Append(dataValidation);
                worksheetExtension.Append(dataValidations);
                worksheetExtensionList.Append(worksheetExtension);

                worksheet.Append(worksheetExtensionList);
            }

            worksheetPart.Worksheet = worksheet;
        }