public static IEnumerable<OpenXmlElement> GetFormattedElement(Table table) { List<OpenXmlElement> result = new List<OpenXmlElement>(); Word.Table wordTable = new Word.Table(); wordTable.Append(GetTableProperties(table)); //Add Headings if(table.Headings != null) wordTable.Append(GetFormattedTableRow(table.Headings)); //Add Data Rows foreach (Element element in table.SubElements) { if (element.GetElementType() == ElementType.TableRow) wordTable.Append(GetFormattedTableRow((TableRow)element)); else throw new InvalidSubFeatureException(table.GetElementType().ToString(), element.GetElementType().ToString()); } result.Add(wordTable); result.Add(new Word.Paragraph()); return result; }
private static Word.TableProperties GetTableProperties(Table table) { Word.TableWidth widthProps = new Word.TableWidth(); switch (table.WidthUnits) { case ElementWidth.Absolute: widthProps.Width = (table.Width * 20).ToString(); widthProps.Type = Word.TableWidthUnitValues.Dxa; break; case ElementWidth.Percentage: widthProps.Width = (table.Width * 50).ToString(); widthProps.Type = Word.TableWidthUnitValues.Pct; break; default: break; } Word.BorderValues border; switch (table.BorderType) { case TableBorders.None: border = Word.BorderValues.None; break; case TableBorders.Single: border = Word.BorderValues.Single; break; default: border = Word.BorderValues.None; break; } Word.TableProperties tableProps = new Word.TableProperties() { TableWidth = widthProps , TableBorders = new Word.TableBorders() { LeftBorder = new Word.LeftBorder() { Val = border } , RightBorder = new Word.RightBorder() { Val = border } , TopBorder = new Word.TopBorder() { Val = border } , BottomBorder = new Word.BottomBorder() { Val = border } , InsideHorizontalBorder = new Word.InsideHorizontalBorder() { Val = border } , InsideVerticalBorder = new Word.InsideVerticalBorder() { Val = border } } }; return tableProps; }
public TableCell(Table table) : this() { elements.Add(table); }
public void AddElement(Table Table) { elements.Add(Table); }
public void AddElement(Table table) { elementList.Add(table); }