public static DocumentFormat.OpenXml.OpenXmlElement[] GetFormattedSection(MultiColumnSection section) { List<DocumentFormat.OpenXml.OpenXmlElement> formattedSection = new List<DocumentFormat.OpenXml.OpenXmlElement>(); Element[] elements = section.SubElements; foreach (var element in elements) { formattedSection.AddRange(ElementFactory.GetElement(element)); } Word.Columns cols = new Word.Columns() { ColumnCount = (Int16Value)section.NumberOfColumns }; Word.SectionProperties secProps = new Word.SectionProperties(cols); Word.ParagraphProperties paraProp = new Word.ParagraphProperties(secProps); Word.Paragraph para = new Word.Paragraph(paraProp); formattedSection.Add(para); return formattedSection.ToArray(); }
public static DocumentFormat.OpenXml.OpenXmlElement[] GetFormattedSection(Section section) { List<DocumentFormat.OpenXml.OpenXmlElement> formattedSection = new List<DocumentFormat.OpenXml.OpenXmlElement>(); Element[] elements = section.SubElements; foreach (var element in elements) { if (section.CanContain(element.GetElementType())) formattedSection.AddRange(ElementFactory.GetElement(element)); else throw new InvalidSubFeatureException( section.GetElementType().ToString(), element.GetElementType().ToString() ); } Word.Columns cols = new Word.Columns() { ColumnCount = (Int16Value)1 }; Word.SectionProperties secProps = new Word.SectionProperties(cols); Word.ParagraphProperties paraProp = new Word.ParagraphProperties(secProps); Word.Paragraph para = new Word.Paragraph(paraProp); formattedSection.Add(para); return formattedSection.ToArray(); }
private TableRow[] GetData() { List<TableRow> rows = new List<TableRow>(); TableRow tmpRow; foreach (DataRow row in data.Rows) { tmpRow = new TableRow(GetCells(row)); rows.Add(tmpRow); } return rows.ToArray(); }
private TableCell[] GetCells(DataRow row) { List<TableCell> cells = new List<TableCell>(); for (int i = 0; i < data.Columns.Count; i++) { cells.Add( row[i] as TableCell); } return cells.ToArray(); }
public static DocumentFormat.OpenXml.OpenXmlElement[] GetFormattedChapter(Chapter chapter) { if(!stylesAdded) StyleCreator.AddStylePart(); List<OpenXmlElement> result = new List<OpenXmlElement>(); //Setting up Heading style Word.ParagraphProperties paraProps = new Word.ParagraphProperties(); Word.ParagraphStyleId style = new Word.ParagraphStyleId() { Val = "Heading1" }; paraProps.Append(style); //Adding chapter title Word.Paragraph para = new Word.Paragraph(); Word.Run run = new Word.Run(); Word.Text text = new Word.Text() { Text = chapter.Title }; run.Append(text); para.Append(paraProps); para.Append(run); result.Add(para); //Add all child elements foreach (Element element in chapter.SubElements) { if (element.GetElementType() == ElementType.MultiColumnSection) { result.AddRange(MultiColumnSectionFormatter.GetFormattedSection((MultiColumnSection)element)); } else if (element.GetElementType() == ElementType.Section) result.AddRange(SectionFormatter.GetFormattedSection((Section)element)); else throw new InvalidSubFeatureException( chapter.GetElementType().ToString() , element.GetElementType().ToString()); } return result.ToArray(); }