internal int DirectSaveToSharedStringTable(string Data)
        {
            int    index = 0;
            string sHash;

            if (SLTool.ToPreserveSpace(Data))
            {
                sHash = string.Format("<x:t xml:space=\"preserve\">{0}</x:t>", Data);
            }
            else
            {
                sHash = string.Format("<x:t>{0}</x:t>", Data);
            }

            if (dictSharedStringHash.ContainsKey(sHash))
            {
                index = dictSharedStringHash[sHash];
            }
            else
            {
                index = listSharedString.Count;
                listSharedString.Add(sHash);
                dictSharedStringHash[sHash] = index;
            }

            return(index);
        }
Exemple #2
0
 /// <summary>
 /// Set the text. If text formatting is needed, use one of the AppendText() functions.
 /// </summary>
 /// <param name="Text">The text.</param>
 public void SetText(string Text)
 {
     if (Text == null || Text.Length == 0)
     {
         this.istrReal.Text = null;
     }
     else
     {
         this.istrReal.Text      = new Text();
         this.istrReal.Text.Text = Text;
         if (SLTool.ToPreserveSpace(Text))
         {
             this.istrReal.Text.Space = SpaceProcessingModeValues.Preserve;
         }
     }
 }
        internal TotalsRowFormula ToTotalsRowFormula()
        {
            TotalsRowFormula trf = new TotalsRowFormula();

            if (this.Array)
            {
                trf.Array = this.Array;
            }

            if (SLTool.ToPreserveSpace(this.Text))
            {
                trf.Space = SpaceProcessingModeValues.Preserve;
            }
            trf.Text = this.Text;

            return(trf);
        }
Exemple #4
0
        internal CalculatedColumnFormula ToCalculatedColumnFormula()
        {
            CalculatedColumnFormula ccf = new CalculatedColumnFormula();

            if (this.Array)
            {
                ccf.Array = this.Array;
            }

            if (SLTool.ToPreserveSpace(this.Text))
            {
                ccf.Space = SpaceProcessingModeValues.Preserve;
            }
            ccf.Text = this.Text;

            return(ccf);
        }
        internal Run ToRun()
        {
            Run r = new Run();

            r.RunProperties = new RunProperties();

            if (this.Font.FontName != null)
            {
                r.RunProperties.Append(new RunFont()
                {
                    Val = this.Font.FontName
                });
            }

            if (this.Font.CharacterSet != null)
            {
                r.RunProperties.Append(new RunPropertyCharSet()
                {
                    Val = this.Font.CharacterSet.Value
                });
            }

            if (this.Font.FontFamily != null)
            {
                r.RunProperties.Append(new FontFamily()
                {
                    Val = this.Font.FontFamily.Value
                });
            }

            if (this.Font.Bold != null && this.Font.Bold.Value)
            {
                r.RunProperties.Append(new Bold());
            }

            if (this.Font.Italic != null && this.Font.Italic.Value)
            {
                r.RunProperties.Append(new Italic());
            }

            if (this.Font.Strike != null && this.Font.Strike.Value)
            {
                r.RunProperties.Append(new Strike());
            }

            if (this.Font.Outline != null && this.Font.Outline.Value)
            {
                r.RunProperties.Append(new Outline());
            }

            if (this.Font.Shadow != null && this.Font.Shadow.Value)
            {
                r.RunProperties.Append(new Shadow());
            }

            if (this.Font.Condense != null && this.Font.Condense.Value)
            {
                r.RunProperties.Append(new Condense());
            }

            if (this.Font.Extend != null && this.Font.Extend.Value)
            {
                r.RunProperties.Append(new Extend());
            }

            if (this.Font.HasFontColor)
            {
                r.RunProperties.Append(this.Font.clrFontColor.ToSpreadsheetColor());
            }

            if (this.Font.FontSize != null)
            {
                r.RunProperties.Append(new FontSize()
                {
                    Val = this.Font.FontSize.Value
                });
            }

            if (this.Font.HasUnderline)
            {
                r.RunProperties.Append(new Underline()
                {
                    Val = this.Font.Underline
                });
            }

            if (this.Font.HasVerticalAlignment)
            {
                r.RunProperties.Append(new VerticalTextAlignment()
                {
                    Val = this.Font.VerticalAlignment
                });
            }

            if (this.Font.HasFontScheme)
            {
                r.RunProperties.Append(new FontScheme()
                {
                    Val = this.Font.FontScheme
                });
            }

            r.Text = new Text(this.Text);
            if (SLTool.ToPreserveSpace(this.Text))
            {
                r.Text.Space = SpaceProcessingModeValues.Preserve;
            }

            return(r);
        }
Exemple #6
0
        /// <summary>
        /// Append given text with a given font style.
        /// </summary>
        /// <param name="Text">The text.</param>
        /// <param name="TextFont">The font style.</param>
        public void AppendText(string Text, SLFont TextFont)
        {
            Run           run      = new Run();
            RunProperties runprops = new RunProperties();

            if (TextFont.FontName != null)
            {
                runprops.Append(new RunFont()
                {
                    Val = TextFont.FontName
                });
            }

            if (TextFont.CharacterSet != null)
            {
                runprops.Append(new RunPropertyCharSet()
                {
                    Val = TextFont.CharacterSet.Value
                });
            }

            if (TextFont.FontFamily != null)
            {
                runprops.Append(new FontFamily()
                {
                    Val = TextFont.FontFamily.Value
                });
            }

            if (TextFont.Bold != null)
            {
                runprops.Append(new Bold()
                {
                    Val = TextFont.Bold.Value
                });
            }

            if (TextFont.Italic != null)
            {
                runprops.Append(new Italic()
                {
                    Val = TextFont.Italic.Value
                });
            }

            if (TextFont.Strike != null)
            {
                runprops.Append(new Strike()
                {
                    Val = TextFont.Strike.Value
                });
            }

            if (TextFont.Outline != null)
            {
                runprops.Append(new Outline()
                {
                    Val = TextFont.Outline.Value
                });
            }

            if (TextFont.Shadow != null)
            {
                runprops.Append(new Shadow()
                {
                    Val = TextFont.Shadow.Value
                });
            }

            if (TextFont.Condense != null)
            {
                runprops.Append(new Condense()
                {
                    Val = TextFont.Condense.Value
                });
            }

            if (TextFont.Extend != null)
            {
                runprops.Append(new Extend()
                {
                    Val = TextFont.Extend.Value
                });
            }

            if (TextFont.HasFontColor)
            {
                runprops.Append(TextFont.clrFontColor.ToSpreadsheetColor());
            }

            if (TextFont.FontSize != null)
            {
                runprops.Append(new FontSize()
                {
                    Val = TextFont.FontSize.Value
                });
            }

            if (TextFont.HasUnderline)
            {
                runprops.Append(new Underline()
                {
                    Val = TextFont.Underline
                });
            }

            if (TextFont.HasVerticalAlignment)
            {
                runprops.Append(new VerticalTextAlignment()
                {
                    Val = TextFont.VerticalAlignment
                });
            }

            if (TextFont.HasFontScheme)
            {
                runprops.Append(new FontScheme()
                {
                    Val = TextFont.FontScheme
                });
            }

            if (runprops.ChildElements.Count > 0)
            {
                run.Append(runprops);
            }

            run.Text      = new Text();
            run.Text.Text = Text;
            if (SLTool.ToPreserveSpace(Text))
            {
                run.Text.Space = SpaceProcessingModeValues.Preserve;
            }

            bool           bFound = false;
            OpenXmlElement oxe    = istrReal.FirstChild;

            foreach (var child in this.istrReal.ChildElements)
            {
                if (child is Text || child is Run)
                {
                    oxe    = child;
                    bFound = true;
                }
            }

            if (bFound)
            {
                istrReal.InsertAfter(run, oxe);
            }
            else
            {
                istrReal.PrependChild(run);
            }
        }