/// <summary> /// Sets the sheet footer from model. /// </summary> /// <param name="reference">Sheet footer properties.</param> /// <param name="section">Footer section model information.</param> /// <returns> /// An <see cref="ExcelHeaderFooter"/> reference containing the sheet footer section. /// </returns> private static ExcelHeaderFooter SetSheetFooterSection(this ExcelHeaderFooter reference, XlsxDocumentHeaderFooterSection section) { SentinelHelper.ArgumentNull(reference, nameof(reference)); SentinelHelper.ArgumentNull(section, nameof(section)); if (string.IsNullOrEmpty(section.Text)) { return(reference); } var footer = section.Type == KnownHeaderFooterSectionType.Odd ? reference.OddFooter : reference.EvenFooter; var parsedText = OfficeOpenXmlHelper.GetHeaderFooterParsedText(section.Text); switch (section.Alignment) { case KnownHeaderFooterAlignment.Right: footer.RightAlignedText = parsedText; break; case KnownHeaderFooterAlignment.Left: footer.LeftAlignedText = parsedText; break; default: case KnownHeaderFooterAlignment.Center: footer.CenteredText = parsedText; break; } return(reference); }
/// <summary> /// Updates the sheet footer from model. /// </summary> /// <param name="reference">The sheet footer properties.</param> /// <param name="footer">Footer model information.</param> /// <returns> /// An <see cref="ExcelHeaderFooter"/> reference containing the sheet footer. /// </returns> public static ExcelHeaderFooter SetSheetFooter(this ExcelHeaderFooter reference, XlsxDocumentHeaderFooter footer) { SentinelHelper.ArgumentNull(reference, nameof(reference)); SentinelHelper.ArgumentNull(footer, nameof(footer)); bool hasSections = footer.Sections.Any(); if (!hasSections) { return(reference); } var sections = footer.Sections; foreach (var section in sections) { SetSheetFooterSection(reference, section); } return(reference); }
public EPPlusHeaderFooter(ExcelHeaderFooter excelHeaderFooter) { _excelHeaderFooter = excelHeaderFooter; _excelHeaderFooter.differentOddEven = false; _excelHeaderFooter.differentFirst = false; }