Example #1
0
        /// <summary>
        /// Get the spreadsheet's theme settings.
        /// </summary>
        /// <returns></returns>
        public SLThemeSettings GetThemeSettings()
        {
            SLThemeSettings ts = new SLThemeSettings();
            ts.ThemeName = SimpleTheme.ThemeName;
            ts.MajorLatinFont = SimpleTheme.MajorLatinFont;
            ts.MinorLatinFont = SimpleTheme.MinorLatinFont;

            ts.Dark1Color = SimpleTheme.listThemeColors[(int)SLThemeColorIndexValues.Dark1Color];
            ts.Light1Color = SimpleTheme.listThemeColors[(int)SLThemeColorIndexValues.Light1Color];
            ts.Dark2Color = SimpleTheme.listThemeColors[(int)SLThemeColorIndexValues.Dark2Color];
            ts.Light2Color = SimpleTheme.listThemeColors[(int)SLThemeColorIndexValues.Light2Color];
            ts.Accent1Color = SimpleTheme.listThemeColors[(int)SLThemeColorIndexValues.Accent1Color];
            ts.Accent2Color = SimpleTheme.listThemeColors[(int)SLThemeColorIndexValues.Accent2Color];
            ts.Accent3Color = SimpleTheme.listThemeColors[(int)SLThemeColorIndexValues.Accent3Color];
            ts.Accent4Color = SimpleTheme.listThemeColors[(int)SLThemeColorIndexValues.Accent4Color];
            ts.Accent5Color = SimpleTheme.listThemeColors[(int)SLThemeColorIndexValues.Accent5Color];
            ts.Accent6Color = SimpleTheme.listThemeColors[(int)SLThemeColorIndexValues.Accent6Color];
            ts.Hyperlink = SimpleTheme.listThemeColors[(int)SLThemeColorIndexValues.Hyperlink];
            ts.FollowedHyperlinkColor = SimpleTheme.listThemeColors[(int)SLThemeColorIndexValues.FollowedHyperlinkColor];

            return ts;
        }
        internal SLSimpleTheme(WorkbookPart wbp, SLThemeSettings Settings)
        {
            LoadIndexedColors(wbp);
            InitialiseThemeColors();
            InternalThemeType = SLThemeTypeValues.Office;

            bool bHasTheme = (wbp.ThemePart != null) ? true : false;
            if (bHasTheme)
            {
                // load in default values in case the theme file has missing values
                LoadBuiltinTheme(SLThemeTypeValues.Office);
                LoadTheme(wbp);
            }
            else
            {
                LoadBuiltinTheme(SLThemeTypeValues.Office);

                this.sThemeName = Settings.ThemeName;
                this.sMajorLatinFont = Settings.MajorLatinFont;
                this.sMinorLatinFont = Settings.MinorLatinFont;

                listThemeColors[(int)SLThemeColorIndexValues.Dark1Color] = Settings.Dark1Color;
                listThemeColors[(int)SLThemeColorIndexValues.Light1Color] = Settings.Light1Color;
                listThemeColors[(int)SLThemeColorIndexValues.Dark2Color] = Settings.Dark2Color;
                listThemeColors[(int)SLThemeColorIndexValues.Light2Color] = Settings.Light2Color;
                listThemeColors[(int)SLThemeColorIndexValues.Accent1Color] = Settings.Accent1Color;
                listThemeColors[(int)SLThemeColorIndexValues.Accent2Color] = Settings.Accent2Color;
                listThemeColors[(int)SLThemeColorIndexValues.Accent3Color] = Settings.Accent3Color;
                listThemeColors[(int)SLThemeColorIndexValues.Accent4Color] = Settings.Accent4Color;
                listThemeColors[(int)SLThemeColorIndexValues.Accent5Color] = Settings.Accent5Color;
                listThemeColors[(int)SLThemeColorIndexValues.Accent6Color] = Settings.Accent6Color;
                listThemeColors[(int)SLThemeColorIndexValues.Hyperlink] = Settings.Hyperlink;
                listThemeColors[(int)SLThemeColorIndexValues.FollowedHyperlinkColor] = Settings.FollowedHyperlinkColor;

                for (int i = 0; i < listThemeColors.Count; ++i)
                {
                    listThemeColorsHex[i] = string.Format("{0}{1}{2}", listThemeColors[i].R.ToString("x2"), listThemeColors[i].G.ToString("x2"), listThemeColors[i].B.ToString("x2"));
                }
            }

            CalculateRowColumnInfo();
        }
Example #3
0
 private void InitialiseStylesheetWhatNots(SLThemeSettings ThemeSettings)
 {
     SimpleTheme = new SLSimpleTheme(wbp, ThemeSettings);
     this.LoadStylesheet();
 }
Example #4
0
        /// <summary>
        /// Create a new spreadsheet with a custom theme.
        /// </summary>
        /// <param name="ThemeSettings">Custom theme settings.</param>
        public SLDocument(SLThemeSettings ThemeSettings)
        {
            memstream = new MemoryStream();
            xl = SpreadsheetDocument.Create(memstream, SpreadsheetDocumentType.Workbook);
            wbp = xl.AddWorkbookPart();
            IsNewSpreadsheet = true;
            slwb = new SLWorkbook();

            this.DocumentProperties = new SLDocumentProperties();
            this.DocumentProperties.Created = DateTime.UtcNow.ToString(SLConstants.W3CDTF);

            InitialiseAutoFitCache();

            LoadBuiltInNumberingFormats();
            InitialiseStylesheetWhatNots(ThemeSettings);
            LoadSharedStringTable();

            InitialiseNewSpreadsheet();
        }