Exemplo n.º 1
0
        private void WriteWorkSheet_HeaderFooter_oddHeader(string tag, HeaderFooterText headerFooter, XElement headerFooterNode)
        {
            XElement oddHeaderNode = new XElement(XName.Get(tag, ExcelCommon.Schema_WorkBook_Main.NamespaceName));

            StringBuilder strRet = new StringBuilder();
            if (string.IsNullOrEmpty(headerFooter.LeftAlignedText) == false)
            {
                strRet.Append("&L");
                strRet.Append(headerFooter.LeftAlignedText);
            }

            if (string.IsNullOrEmpty(headerFooter.CenteredText) == false)
            {
                strRet.Append("&C");
                strRet.Append(headerFooter.CenteredText);
            }

            if (string.IsNullOrEmpty(headerFooter.RightAlignedText) == false)
            {
                strRet.Append("&R");
                strRet.Append(headerFooter.RightAlignedText);
            }

            oddHeaderNode.Value = strRet.ToString();

            headerFooterNode.Add(oddHeaderNode);
        }
Exemplo n.º 2
0
        private void WriteWorkSheet_HeaderFooter_AddPictures(WorkSheet sheet, HeaderFooterText headerText)
        {
            if (headerText.LeftImag != null)
                sheet._HeaderFooter.Pictures.Add(headerText.LeftImag);

            if (headerText.CenteredImag != null)
                sheet._HeaderFooter.Pictures.Add(headerText.CenteredImag);

            if (headerText.RightAlignedImag != null)
                sheet._HeaderFooter.Pictures.Add(headerText.RightAlignedImag);
        }
Exemplo n.º 3
0
        private void ReadWorkSheet_headerFooter_FooterText(ref HeaderFooterText headerText, string text)
        {
            //string text = childNode.Value;
            string code = text.Substring(0, 2);
            int startPos = 2;
            for (int pos = startPos; pos < text.Length - 2; pos++)
            {
                string newCode = text.Substring(pos, 2);
                if (newCode == "&C" || newCode == "&R")
                {
                    SetText(ref headerText, code, text.Substring(startPos, pos - startPos));
                    startPos = pos + 2;
                    pos = startPos;
                    code = newCode;
                }
            }

            SetText(ref headerText, code, text.Substring(startPos, text.Length - startPos));
        }
Exemplo n.º 4
0
 private void SetText(ref HeaderFooterText headerText, string code, string text)
 {
     switch (code)
     {
         case "&L":
             headerText.LeftAlignedText = text;
             break;
         case "&C":
             headerText.CenteredText = text;
             break;
         default:
             headerText.RightAlignedText = text;
             break;
     }
 }
Exemplo n.º 5
0
        private void ReadWorkSheet_headerFooter_Image(HeaderFooter headerFooter, ref HeaderFooterText headerFooterText, string tag)
        {
            if (headerFooter._Pictures != null)
            {
                //偶数页眉  <evenHeader> // 右 "RHEVEN"  中间 “CHEVEN", 左 "LHEVEN" 
                //首页页眉  <firstHeader> // 右 ”RHFIRST“ 中间 "CHFIRST" 左 "LHFIRST"
                //奇数页眉  <oddHeader>  // 右 “RH”  中 "CH"  左 "LH"

                //奇数页脚  <oddFooter>   //F
                //偶数页脚  <evenFooter>  //CFEVEN 
                //首页页脚  <firstFooter>   FFIRST
                string key = string.Format("{0}{1}", "R", tag);
                if (headerFooter._Pictures.ContainsKey(key))
                {
                    headerFooterText.RightAlignedImag = headerFooter._Pictures[key];
                    headerFooter._Pictures.Remove(key);
                }
                key = string.Format("{0}{1}", "C", tag);
                if (headerFooter._Pictures.ContainsKey(key))
                {
                    headerFooterText.CenteredImag = headerFooter._Pictures[key];
                    headerFooter._Pictures.Remove(key);
                }
                key = string.Format("{0}{1}", "L", tag);
                if (headerFooter._Pictures.ContainsKey(key))
                {
                    headerFooterText.LeftImag = headerFooter._Pictures[key];
                    headerFooter._Pictures.Remove(key);
                }
            }
        }