示例#1
0
 /***********************************
  * INTERNAL METHODS
  ************************************/
 internal PageMargins Clone(Worksheet worksheet)
 {
     PageMargins newPageMargins = new PageMargins(worksheet,
         Left, Right, Top, Bottom, Header, Footer);
     return newPageMargins;
 }
示例#2
0
        /***********************************
         * DAL METHODS
         ************************************/
        // Read
        internal static PageMargins ReadPageMarginsFromReader(CustomOpenXmlReader reader, Worksheet worksheet)
        {
            PageMargins pageMargins = new PageMargins(worksheet);

            foreach (CustomOpenXmlAttribute attribute in reader.Attributes)
            {
                switch (attribute.LocalName)
                {
                    case "left":
                        pageMargins.Left = attribute.GetDoubleValue();
                        break;
                    case "right":
                        pageMargins.Right = attribute.GetDoubleValue();
                        break;
                    case "top":
                        pageMargins.Top = attribute.GetDoubleValue();
                        break;
                    case "bottom":
                        pageMargins.Bottom = attribute.GetDoubleValue();
                        break;
                    case "header":
                        pageMargins.Header = attribute.GetDoubleValue();
                        break;
                    case "footer":
                        pageMargins.Footer = attribute.GetDoubleValue();
                        break;
                    default:
                        throw new Exception(string.Format("PageMargins attribute {0} not coded", attribute.LocalName));
                }
            }

            return pageMargins;
        }
示例#3
0
        // Write
        internal static void WritePageMarginsToWriter(CustomOpenXmlWriter<OpenXmlPackaging.WorksheetPart> writer, PageMargins pageMargins)
        {
            writer.WriteOpenXmlElement(new OpenXmlSpreadsheet.PageMargins());

            writer.WriteAttribute("left", pageMargins.Left);
            writer.WriteAttribute("right", pageMargins.Right);
            writer.WriteAttribute("top", pageMargins.Top);
            writer.WriteAttribute("bottom", pageMargins.Bottom);
            writer.WriteAttribute("header", pageMargins.Header);
            writer.WriteAttribute("footer", pageMargins.Footer);

            writer.WriteEndElement();   // PageMargins
        }