internal void FromTableStyle(TableStyle ts) { this.SetAllNull(); this.TableStyleInnerXml = ts.InnerXml; // this is a required field, so it can't be null, but just in case... if (ts.Name != null) this.Name = ts.Name.Value; else this.Name = string.Empty; if (ts.Pivot != null) { this.Pivot = ts.Pivot.Value; } if (ts.Table != null) { this.Table = ts.Table.Value; } if (ts.Count != null) { this.Count = ts.Count.Value; } }
public SigaDataGridSystem(string controlName) { columns = new SortedList(); rows = new SortedList(); rowIndex = 0; columnIndex = 0; TotalPages = 0; TotalRecords = 0; ReturnStatus = true; Style = new TableStyle(); ControlName = controlName; }
private static TableProperties GenerateTableProperties() { TableProperties tableProperties1 = new TableProperties(); TableStyle tableStyle1 = new TableStyle() { Val = "TableGrid" }; TableWidth tableWidth1 = new TableWidth() { Width = "0", Type = TableWidthUnitValues.Auto }; TableLook tableLook1 = new TableLook() { Val = "04A0" }; tableProperties1.Append(tableStyle1); tableProperties1.Append(tableWidth1); tableProperties1.Append(tableLook1); return tableProperties1; }
internal TableStyle ToTableStyle() { TableStyle ts = new TableStyle(); ts.InnerXml = SLTool.RemoveNamespaceDeclaration(this.TableStyleInnerXml); ts.Name = this.Name; if (this.Pivot != null) ts.Pivot = this.Pivot.Value; if (this.Table != null) ts.Table = this.Table.Value; if (this.Count != null) ts.Count = this.Count.Value; return ts; }
private static TableProperties GenerateTableProperties() { var tableProperties1 = new TableProperties(); var tableStyle1 = new TableStyle { Val = "TableGrid" }; var tableWidth1 = new TableWidth { Width = "4900", Type = TableWidthUnitValues.Pct }; var tableLook1 = new TableLook { Val = "04A0" }; var tableJustification = new TableJustification { Val = TableRowAlignmentValues.Center }; tableProperties1.Append(tableStyle1); tableProperties1.Append(tableWidth1); tableProperties1.Append(tableLook1); tableProperties1.Append(tableJustification); return tableProperties1; }
internal void FromHash(string Hash) { TableStyle ts = new TableStyle(); string[] saElementAttribute = Hash.Split(new string[] { SLConstants.XmlTableStyleElementAttributeSeparator }, StringSplitOptions.None); if (saElementAttribute.Length >= 2) { ts.InnerXml = saElementAttribute[0]; string[] sa = saElementAttribute[1].Split(new string[] { SLConstants.XmlTableStyleAttributeSeparator }, StringSplitOptions.None); if (sa.Length >= 4) { ts.Name = sa[0]; if (!sa[1].Equals("null")) ts.Pivot = bool.Parse(sa[1]); if (!sa[2].Equals("null")) ts.Table = bool.Parse(sa[2]); if (!sa[3].Equals("null")) ts.Count = uint.Parse(sa[3]); } } this.FromTableStyle(ts); }
public override IEnumerable<OpenXmlElement> ToOpenXmlElements(DocumentFormat.OpenXml.Packaging.MainDocumentPart mainDocumentPart) { Table result = new Table(); var tableProperties = new TableProperties(); var tableStyle = new TableStyle() { Val = "GrilledutableauSimpleTable" }; var tableWidth = UnitHelper.Convert(Width).To<TableWidth>(); var tableIndentation = new TableIndentation() { Width = 534, Type = TableWidthUnitValues.Dxa }; var tableLook = new TableLook() { Val = "04A0" }; tableProperties.Append(tableStyle); tableProperties.Append(tableWidth); tableProperties.Append(tableIndentation); tableProperties.Append(tableLook); result.Append(tableProperties); ForEachChild(x => { Debug.Assert(x is TableRowFormattedElement); result.Append(x.ToOpenXmlElements(mainDocumentPart)); }); return new List<OpenXmlElement> { result }; }
public async Task <string> GetContentByTableStyleAsync(string content, string separator, Site site, TableStyle style, string formatString, NameValueCollection attributes, string innerHtml, bool isStlEntity) { var parsedContent = content; var inputType = style.InputType; if (inputType == InputType.Date) { var dateTime = TranslateUtils.ToDateTime(content); if (dateTime != Constants.SqlMinValue) { if (string.IsNullOrEmpty(formatString)) { formatString = DateUtils.FormatStringDateOnly; } parsedContent = DateUtils.Format(dateTime, formatString); } else { parsedContent = string.Empty; } } else if (inputType == InputType.DateTime) { var dateTime = TranslateUtils.ToDateTime(content); if (dateTime != Constants.SqlMinValue) { if (string.IsNullOrEmpty(formatString)) { formatString = DateUtils.FormatStringDateTime; } parsedContent = DateUtils.Format(dateTime, formatString); } else { parsedContent = string.Empty; } } else if (inputType == InputType.CheckBox || inputType == InputType.Radio || inputType == InputType.SelectMultiple || inputType == InputType.SelectOne)//选择类型 { var selectedTexts = new List <string>(); var selectedValues = ListUtils.GetStringList(content); var styleItems = style.Items; if (styleItems != null) { foreach (var itemInfo in styleItems) { if (selectedValues.Contains(itemInfo.Value)) { selectedTexts.Add(isStlEntity ? itemInfo.Value : itemInfo.Label); } } } parsedContent = separator == null?ListUtils.ToString(selectedTexts) : ListUtils.ToString(selectedTexts, separator); } //else if (style.InputType == InputType.TextArea) //{ // parsedContent = StringUtils.ReplaceNewlineToBR(parsedContent); //} else if (inputType == InputType.TextEditor) { parsedContent = await _pathManager.DecodeTextEditorAsync(site, parsedContent, true); } else if (inputType == InputType.Image) { parsedContent = await GetImageOrFlashHtmlAsync(site, parsedContent, attributes, isStlEntity); } else if (inputType == InputType.Video) { parsedContent = await GetVideoHtmlAsync(site, parsedContent, attributes, isStlEntity); } else if (inputType == InputType.File) { parsedContent = GetFileHtmlWithoutCount(site, parsedContent, attributes, innerHtml, isStlEntity, false, false); } return(parsedContent); }
public FramedTablePrinter(IConsole console, TableStyle printStyle) : base(console, printStyle) { this._printStyle = printStyle; }
public async Task ImportTableStylesAsync(Site site, string guid) { if (!DirectoryUtils.IsDirectoryExists(_directoryPath)) { return; } var styleDirectoryPaths = DirectoryUtils.GetDirectoryPaths(_directoryPath); var styles = new List <TableStyle>(); foreach (var styleDirectoryPath in styleDirectoryPaths) { var tableName = PathUtils.GetDirectoryName(styleDirectoryPath, false); if (tableName == "siteserver_PublishmentSystem") { tableName = _databaseManager.SiteRepository.TableName; } var attributeNamePaths = DirectoryUtils.GetDirectoryPaths(styleDirectoryPath); foreach (var attributeNamePath in attributeNamePaths) { var attributeName = PathUtils.GetDirectoryName(attributeNamePath, false); var filePaths = DirectoryUtils.GetFilePaths(attributeNamePath); foreach (var filePath in filePaths) { var feed = AtomFeed.Load(FileUtils.GetFileStreamReadOnly(filePath)); var taxis = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyle.Taxis))); var displayName = AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyle.DisplayName)); var helpText = AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyle.HelpText)); var list = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(feed.AdditionalElements, new List <string> { nameof(TableStyle.List), "VisibleInList" })); var inputType = TranslateUtils.ToEnum(AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyle.InputType)), InputType.Text); var defaultValue = AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyle.DefaultValue)); var isHorizontal = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyle.Horizontal))); var itemValues = AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyle.ItemValues)); var ruleValues = AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyle.RuleValues)); var orderString = AtomUtility.GetDcElementContent(feed.AdditionalElements, "OrderString"); var relatedIdentity = !string.IsNullOrEmpty(orderString) ? await _databaseManager.ChannelRepository.ImportGetIdAsync(site.Id, orderString) : site.Id; if (relatedIdentity <= 0 || await _databaseManager.TableStyleRepository.IsExistsAsync(relatedIdentity, tableName, attributeName)) { continue; } var style = new TableStyle { Id = 0, RelatedIdentity = relatedIdentity, TableName = tableName, AttributeName = attributeName, Taxis = taxis, DisplayName = displayName, HelpText = helpText, List = list, InputType = inputType, DefaultValue = defaultValue, Horizontal = isHorizontal, ItemValues = itemValues, RuleValues = ruleValues }; style.Items = TranslateUtils.JsonDeserialize <List <InputStyleItem> >(style.ItemValues); style.Rules = TranslateUtils.JsonDeserialize <List <InputStyleRule> >(style.RuleValues); var json = AtomUtility.GetDcElementContent(feed.AdditionalElements, "ExtendValues"); if (!string.IsNullOrEmpty(json)) { var dict = ListUtils.ToDictionary(json); foreach (var o in dict) { style.Set(o.Key, o.Value); } } styles.Add(style); } } } foreach (var style in styles) { _caching.SetProcess(guid, $"导入表字段: {style.AttributeName}"); await _databaseManager.TableStyleRepository.InsertAsync(_databaseManager.TableStyleRepository.GetRelatedIdentities(style.RelatedIdentity), style); } }
//public System.Drawing.Image BuildImage(byte[] img) //{ // try // { // using (MemoryStream ms = new MemoryStream(img)) // return System.Drawing.Image.FromStream(ms); // } // catch { return null; } // //return null; //} public void PerformReplace(Dictionary <string, object> elements) { // creating stream //XmlNode convertationNode = xmlDocument.CreateElement("ConvertationNode"); List <Placeholder> placeholderElements = TextDoc.GetPlaceholders(); foreach (var pair in elements) { foreach (Placeholder node in placeholderElements) { if (pair.Key.ToLower() != node.Value.ToLower()) { continue; } if (pair.Value == null) { node.Owner.Replace(node, new TextElement(TextDoc, "íåò äàííûõ")); } else if (node.Type == PlaceholdeType.Image) { if (pair.Value == null || pair.Value == DBNull.Value) { continue; } //var img = BuildImage((byte[])pair.Value); //if (img == null) // continue; Frame frame = textDoc.GetFrame((byte[])pair.Value, 100, //(img.Width / ((System.Drawing.Bitmap)img).PixelWidth) * 2.54D, 100, 7); // (img.Height / ((System.Drawing.Bitmap)img).PixelHeight) * 2.54D, 7); Service.Replace(node, frame); //img.Dispose(); } else if (node.Type == PlaceholdeType.Text) { if (pair.Value == null || pair.Value == DBNull.Value) { continue; } if (pair.Value is string) { textDoc.InsertText(pair.Value.ToString(), node, true); } else { //Paragraph parentParagraph = (Paragraph)Service.GetParent(node, typeof(Paragraph)); var values = new List <object>(); foreach (var dr in pair.Value as List <Dictionary <string, object> > ) { foreach (var dc in dr) { if (dc.Value.GetType() == typeof(byte[])) { //var img = BuildImage((byte[])dc.Value); //if (img != null) //{ Frame frame = textDoc.GetFrame((byte[])dc.Value, 100, 100, 7); //img.Dispose(); values.Add(frame); //} } else { string str = dc.Value.ToString(); if (str.Length != 0) { if (values.Count == 0 || values[values.Count - 1] is BaseItem) { values.Add(dc.ToString() + " "); } else { values[values.Count - 1] = values[values.Count - 1].ToString() + str + " "; } } } } values.Add("\n"); } textDoc.InsertRange(values, node, true); //node.Owner.Remove(node); } } else if (node.Type == PlaceholdeType.Table) { var query = pair.Value as QResult; Table parentTable = Service.GetParent(node, typeof(Table)) as Table; Row parentRow = Service.GetParent(node, typeof(Row)) as Row; if (parentTable == null) { TableStyle tableStyle = new TableStyle(TextDoc); tableStyle.TableProperty.Align = "center"; parentTable = new Table(TextDoc) { Style = tableStyle }; Column column = new Column(TextDoc); ColumnStyle columnStyle = new ColumnStyle(TextDoc); column.Style = columnStyle; column.RepeatedCount = (uint)query.Values.Count; parentRow = new Row(TextDoc); CellStyle cellStyle = new CellStyle(TextDoc); cellStyle.ColumnProperty.BorderLeft = "0.004cm solid #000000"; Cell cell = new Cell(TextDoc) { Style = cellStyle }; for (int i = 0; i < query.Values.Count; i++) { parentRow.Add((Cell)cell.Clone()); } parentTable.Add(column); parentTable.Add(parentRow); Paragraph pparagraph = Service.GetParent(node, typeof(Paragraph)) as Paragraph; pparagraph.Owner.Replace(pparagraph, parentTable); } Row prevRow = parentRow; foreach (var dr in query.Values) { Row newRow = (Row)parentRow.Clone(); List <Cell> list = newRow.GetCells(); int i = -1; foreach (var item in dr) { i++; if (i < list.Count) { if (item == null) { continue; } list[i].FirstParagraph.Clear(); if (item is byte[]) { try { //var img = BuildImage((byte[])item); //if (img != null) //{ Frame frame = textDoc.GetFrame((byte[])item, 100, //(img.Width / ((System.Drawing.Bitmap)img).PixelWidth) * 2.54D, 100, 7); //(img.Height / ((System.Drawing.Bitmap)img).PixelHeight) * 2.54D, 7); list[i].FirstParagraph.Add(frame); //img.Dispose(); //} } catch (Exception ex) { list[i].FirstParagraph.Add(ex.Message); } } //else if (item is System.Drawing.Image) //{ // var img = (System.Drawing.Image)item; // Frame frame = textDoc.GetFrame(null,//TODO // (img.Width / ((System.Drawing.Bitmap)img).PixelWidth) * 2.54D, // (img.Height / ((System.Drawing.Bitmap)img).PixelHeight) * 2.54D, 7); // list[i].FirstParagraph.Add(frame); //} else { list[i].FirstParagraph.Add(item.ToString()); } } } parentTable.InsertAfter(prevRow, newRow); prevRow = newRow; } parentTable.Remove(parentRow); } } } }
public override ITextFormatter BeginTable(TableStyle style) { m_stream.Write("\n"); return(this); }
private Table CreateFilledTable() { //枠線有りテーブルを生成する(幅はページの幅) Table table = new Table(); TableProperties tableProperties = new TableProperties(); TableStyle tableStyle = new TableStyle() { Val = "TableGrid" }; TableWidth tableWidth = new TableWidth() { Width = "5000", Type = TableWidthUnitValues.Pct }; TableLook tableLook = new TableLook() { Val = "04A0", FirstRow = true, LastRow = false, FirstColumn = true, LastColumn = false, NoHorizontalBand = false, NoVerticalBand = true }; tableProperties.Append(tableStyle); tableProperties.Append(tableWidth); tableProperties.Append(tableLook); table.Append(tableProperties); return table; }
public void GridLines_Invalid() { TableStyle ts = new TableStyle(); ts.GridLines = (GridLines)Int32.MinValue; }
public void HorizontalAlign_Invalid() { TableStyle ts = new TableStyle(); ts.HorizontalAlign = (HorizontalAlign)Int32.MinValue; }
public void BackImageUrl_Null() { TableStyle ts = new TableStyle(); ts.BackImageUrl = null; }
public void CellSpacing_Invalid() { TableStyle ts = new TableStyle(); ts.CellSpacing = Int32.MinValue; }
IEnumerable <OpenXmlCompositeElement> Paragraph2Paragraphs(MarkdownParagraph md) { if (md.IsHeading) { var mdh = md as MarkdownParagraph.Heading; var level = mdh.Item1; var spans = mdh.Item2; var sr = sections[new SectionRef(mdh, filename).Url]; var props = new ParagraphProperties(new ParagraphStyleId() { Val = $"Heading{level}" }); var p = new Paragraph { ParagraphProperties = props }; maxBookmarkId.Value += 1; p.AppendChild(new BookmarkStart { Name = sr.BookmarkName, Id = maxBookmarkId.Value.ToString() }); p.Append(Spans2Elements(spans)); p.AppendChild(new BookmarkEnd { Id = maxBookmarkId.Value.ToString() }); yield return(p); Console.WriteLine(new string(' ', level * 4 - 4) + sr.Number + " " + sr.Title); yield break; } else if (md.IsParagraph) { var mdp = md as MarkdownParagraph.Paragraph; var spans = mdp.Item; yield return(new Paragraph(Spans2Elements(spans))); yield break; } else if (md.IsListBlock) { var mdl = md as MarkdownParagraph.ListBlock; var flat = FlattenList(mdl); // Let's figure out what kind of list it is - ordered or unordered? nested? var format0 = new[] { "1", "1", "1", "1" }; foreach (var item in flat) { format0[item.Level] = (item.IsBulletOrdered ? "1" : "o"); } var format = string.Join("", format0); var numberingPart = wdoc.MainDocumentPart.NumberingDefinitionsPart ?? wdoc.MainDocumentPart.AddNewPart <NumberingDefinitionsPart>("NumberingDefinitionsPart001"); if (numberingPart.Numbering == null) { numberingPart.Numbering = new Numbering(); } Func <int, bool, Level> createLevel; createLevel = (level, isOrdered) => { var numformat = NumberFormatValues.Bullet; var levelText = new[] { "·", "o", "·", "o" }[level]; if (isOrdered && level == 0) { numformat = NumberFormatValues.Decimal; levelText = "%1."; } if (isOrdered && level == 1) { numformat = NumberFormatValues.LowerLetter; levelText = "%2."; } if (isOrdered && level == 2) { numformat = NumberFormatValues.LowerRoman; levelText = "%3."; } if (isOrdered && level == 3) { numformat = NumberFormatValues.LowerRoman; levelText = "%4."; } var r = new Level { LevelIndex = level }; r.Append(new StartNumberingValue { Val = 1 }); r.Append(new NumberingFormat { Val = numformat }); r.Append(new LevelText { Val = levelText }); r.Append(new ParagraphProperties(new Indentation { Left = (540 + 360 * level).ToString(), Hanging = "360" })); if (levelText == "·") { r.Append(new NumberingSymbolRunProperties(new RunFonts { Hint = FontTypeHintValues.Default, Ascii = "Symbol", HighAnsi = "Symbol", EastAsia = "Times new Roman", ComplexScript = "Times new Roman" })); } if (levelText == "o") { r.Append(new NumberingSymbolRunProperties(new RunFonts { Hint = FontTypeHintValues.Default, Ascii = "Courier New", HighAnsi = "Courier New", ComplexScript = "Courier New" })); } return(r); }; var level0 = createLevel(0, format[0] == '1'); var level1 = createLevel(1, format[1] == '1'); var level2 = createLevel(2, format[2] == '1'); var level3 = createLevel(3, format[3] == '1'); var abstracts = numberingPart.Numbering.OfType <AbstractNum>().Select(an => an.AbstractNumberId.Value).ToList(); var aid = (abstracts.Count == 0 ? 1 : abstracts.Max() + 1); var aabstract = new AbstractNum(new MultiLevelType() { Val = MultiLevelValues.Multilevel }, level0, level1, level2, level3) { AbstractNumberId = aid }; numberingPart.Numbering.InsertAt(aabstract, 0); var instances = numberingPart.Numbering.OfType <NumberingInstance>().Select(ni => ni.NumberID.Value); var nid = (instances.Count() == 0 ? 1 : instances.Max() + 1); var numInstance = new NumberingInstance(new AbstractNumId { Val = aid }) { NumberID = nid }; numberingPart.Numbering.AppendChild(numInstance); // We'll also figure out the indentation(for the benefit of those paragraphs that should be // indendent with the list but aren't numbered). I'm not sure what the indent comes from. // in the docx, each AbstractNum that I created has an indent for each of its levels, // defaulted at 900, 1260, 1620, ... but I can't see where in the above code that's created? Func <int, string> calcIndent = level => (540 + level * 360).ToString(); foreach (var item in flat) { var content = item.Paragraph; if (content.IsParagraph || content.IsSpan) { var spans = (content.IsParagraph ? (content as MarkdownParagraph.Paragraph).Item : (content as MarkdownParagraph.Span).Item); if (item.HasBullet) { yield return new Paragraph(Spans2Elements(spans)) { ParagraphProperties = new ParagraphProperties(new NumberingProperties(new ParagraphStyleId { Val = "ListParagraph" }, new NumberingLevelReference { Val = item.Level }, new NumberingId { Val = nid })) } } ; else { yield return new Paragraph(Spans2Elements(spans)) { ParagraphProperties = new ParagraphProperties(new Indentation { Left = calcIndent(item.Level) }) } }; } else if (content.IsQuotedBlock || content.IsCodeBlock) { foreach (var p in Paragraph2Paragraphs(content)) { var props = p.GetFirstChild <ParagraphProperties>(); if (props == null) { props = new ParagraphProperties(); p.InsertAt(props, 0); } var indent = props?.GetFirstChild <Indentation>(); if (indent == null) { indent = new Indentation(); props.Append(indent); } indent.Left = calcIndent(item.Level); yield return(p); } } else if (content.IsTableBlock) { foreach (var p in Paragraph2Paragraphs(content)) { var table = p as Table; if (table == null) { yield return(p); continue; } var tprops = table.GetFirstChild <TableProperties>(); var tindent = tprops?.GetFirstChild <TableIndentation>(); if (tindent == null) { throw new Exception("Ooops! Table is missing indentation"); } tindent.Width = int.Parse(calcIndent(item.Level)); yield return(table); } } else { throw new Exception("Unexpected item in list"); } } } else if (md.IsCodeBlock) { var mdc = md as MarkdownParagraph.CodeBlock; var code = mdc.Item1; var lang = mdc.Item2; code = BugWorkaroundDecode(code); var runs = new List <Run>(); var onFirstLine = true; IEnumerable <ColorizedLine> lines; if (lang == "csharp" || lang == "c#" || lang == "cs") { lines = Colorize.CSharp(code); } else if (lang == "vb" || lang == "vbnet" || lang == "vb.net") { lines = Colorize.VB(code); } else if (lang == "" || lang == "xml") { lines = Colorize.PlainText(code); } else if (lang == "antlr") { lines = Antlr.ColorizeAntlr(code); } else { throw new NotSupportedException($"unrecognized language {lang}"); } foreach (var line in lines) { if (onFirstLine) { onFirstLine = false; } else { runs.Add(new Run(new Break())); } foreach (var word in line.Words) { var run = new Run(); var props = new RunProperties(); if (word.Red != 0 || word.Green != 0 || word.Blue != 0) { props.Append(new Color { Val = $"{word.Red:X2}{word.Green:X2}{word.Blue:X2}" }); } if (word.IsItalic) { props.Append(new Italic()); } if (props.HasChildren) { run.Append(props); } run.Append(new Text(word.Text) { Space = SpaceProcessingModeValues.Preserve }); runs.Add(run); } } var style = new ParagraphStyleId { Val = (lang == "antlr" ? "Grammar" : "Code") }; yield return(new Paragraph(runs) { ParagraphProperties = new ParagraphProperties(style) }); } else if (md.IsQuotedBlock) { var mdq = md as MarkdownParagraph.QuotedBlock; var quoteds = mdq.Item; var kind = ""; foreach (var quoted0 in quoteds) { var quoted = quoted0; if (quoted.IsParagraph) { var p = quoted as MarkdownParagraph.Paragraph; var spans = p.Item; if (spans.Any() && spans.First().IsStrong) { var strong = (spans.First() as MarkdownSpan.Strong).Item; if (strong.Any() && strong.First().IsLiteral) { var literal = mdunescape(strong.First() as MarkdownSpan.Literal); if (literal == "Note") { kind = "AlertText"; } else if (literal == "Annotation") { kind = "Annotation"; yield return(new Paragraph(Span2Elements(spans.Head)) { ParagraphProperties = new ParagraphProperties(new ParagraphStyleId { Val = kind }) }); if (spans.Tail.Any() && spans.Tail.First().IsLiteral) { quoted = MarkdownParagraph.NewParagraph(new Microsoft.FSharp.Collections.FSharpList <MarkdownSpan>(MarkdownSpan.NewLiteral(mdunescape(spans.Tail.First() as MarkdownSpan.Literal).TrimStart()), spans.Tail.Tail)); } else { quoted = MarkdownParagraph.NewParagraph(spans.Tail); } } } } // foreach (var qp in Paragraph2Paragraphs(quoted)) { var qpp = qp as Paragraph; if (qpp != null) { var props = new ParagraphProperties(new ParagraphStyleId() { Val = kind }); qpp.ParagraphProperties = props; } yield return(qp); } } else if (quoted.IsCodeBlock) { var mdc = quoted as MarkdownParagraph.CodeBlock; var code = mdc.Item1; var lang = mdc.Item2; var ignoredAfterLang = mdc.Item3; var lines = code.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None).ToList(); if (string.IsNullOrWhiteSpace(lines.Last())) { lines.RemoveAt(lines.Count - 1); } var run = new Run() { RunProperties = new RunProperties(new RunStyle { Val = "CodeEmbedded" }) }; foreach (var line in lines) { if (run.ChildElements.Count() > 1) { run.Append(new Break()); } run.Append(new Text(" " + line) { Space = SpaceProcessingModeValues.Preserve }); } yield return(new Paragraph(run) { ParagraphProperties = new ParagraphProperties(new ParagraphStyleId { Val = kind }) }); } else if (quoted.IsListBlock) { if (!(quoted as MarkdownParagraph.ListBlock).Item1.IsOrdered) { throw new NotImplementedException("unordered list inside annotation"); } var count = 1; foreach (var qp in Paragraph2Paragraphs(quoted)) { var qpp = qp as Paragraph; if (qpp == null) { yield return(qp); continue; } qp.InsertAt(new Run(new Text($"{count}. ") { Space = SpaceProcessingModeValues.Preserve }), 0); count += 1; var props = new ParagraphProperties(new ParagraphStyleId() { Val = kind }); qpp.ParagraphProperties = props; yield return(qp); } } } } else if (md.IsTableBlock) { var mdt = md as MarkdownParagraph.TableBlock; var header = mdt.Item1.Option(); var align = mdt.Item2; var rows = mdt.Item3; var table = new Table(); var tstyle = new TableStyle { Val = "TableGrid" }; var tindent = new TableIndentation { Width = 360, Type = TableWidthUnitValues.Dxa }; var tborders = new TableBorders(); tborders.TopBorder = new TopBorder { Val = BorderValues.Single }; tborders.BottomBorder = new BottomBorder { Val = BorderValues.Single }; tborders.LeftBorder = new LeftBorder { Val = BorderValues.Single }; tborders.RightBorder = new RightBorder { Val = BorderValues.Single }; tborders.InsideHorizontalBorder = new InsideHorizontalBorder { Val = BorderValues.Single }; tborders.InsideVerticalBorder = new InsideVerticalBorder { Val = BorderValues.Single }; var tcellmar = new TableCellMarginDefault(); tcellmar.Append(); table.Append(new TableProperties(tstyle, tindent, tborders)); var ncols = align.Length; for (int irow = -1; irow < rows.Length; irow++) { if (irow == -1 && header == null) { continue; } var mdrow = (irow == -1 ? header : rows[irow]); var row = new TableRow(); for (int icol = 0; icol < Math.Min(ncols, mdrow.Length); icol++) { var mdcell = mdrow[icol]; var cell = new TableCell(); var pars = Paragraphs2Paragraphs(mdcell).ToList(); for (int ip = 0; ip < pars.Count; ip++) { var p = pars[ip] as Paragraph; if (p == null) { cell.Append(pars[ip]); continue; } var props = new ParagraphProperties(new ParagraphStyleId { Val = "TableCellNormal" }); if (align[icol].IsAlignCenter) { props.Append(new Justification { Val = JustificationValues.Center }); } if (align[icol].IsAlignRight) { props.Append(new Justification { Val = JustificationValues.Right }); } p.InsertAt(props, 0); cell.Append(pars[ip]); } if (pars.Count == 0) { cell.Append(new Paragraph(new ParagraphProperties(new SpacingBetweenLines { After = "0" }), new Run(new Text("")))); } row.Append(cell); } table.Append(row); } yield return(new Paragraph(new Run(new Text(""))) { ParagraphProperties = new ParagraphProperties(new ParagraphStyleId { Val = "TableLineBefore" }) }); yield return(table); yield return(new Paragraph(new Run(new Text(""))) { ParagraphProperties = new ParagraphProperties(new ParagraphStyleId { Val = "TableLineAfter" }) }); } else { yield return(new Paragraph(new Run(new Text($"[{md.GetType().Name}]")))); } }
public void MakeReport(/*string client, string analyst, int type*/) { using (WordprocessingDocument wordDocument = WordprocessingDocument.Open(reportFile, true)) { var mainPart = wordDocument.MainDocumentPart.Document; Table testtable = new Table(); TableProperties vishProps = new TableProperties(); //****------ TABLE BORDERS TableBorders vishBorders = new TableBorders(); TopBorder top = new TopBorder() { Val = BorderValues.Single, Color = "auto" }; LeftBorder left = new LeftBorder() { Val = BorderValues.Single, Color = "auto" }; RightBorder right = new RightBorder() { Val = BorderValues.Single, Color = "auto" }; BottomBorder bottom = new BottomBorder() { Val = BorderValues.Single, Color = "auto" }; InsideHorizontalBorder horizontal = new InsideHorizontalBorder() { Val = BorderValues.Single, Color = "auto", }; InsideVerticalBorder vertical = new InsideVerticalBorder() { Val = BorderValues.Single, Color = "auto" }; vishBorders.Append(top); vishBorders.Append(left); vishBorders.Append(right); vishBorders.Append(bottom); vishBorders.Append(horizontal); vishBorders.Append(vertical); //****------ TABLE STYLE StyleRunProperties stylerunprops = new StyleRunProperties(); TablePositionProperties tableposprops = new TablePositionProperties() { VerticalAnchor = VerticalAnchorValues.Margin, HorizontalAnchor = HorizontalAnchorValues.Margin }; RunFonts headResRunFonts = new RunFonts() { Ascii = "Arial" }; FontSize fontSize = new FontSize() { Val = "9" }; stylerunprops.Append(headResRunFonts, fontSize); TableStyle tableStyle = new TableStyle() { Val = "TableGrid" }; TableWidth tableWidth = new TableWidth() { Width = "10920", Type = TableWidthUnitValues.Dxa }; TableLook tableLook = new TableLook() { Val = "04A0", FirstRow = true, LastRow = false, FirstColumn = true, LastColumn = false, NoHorizontalBand = false, NoVerticalBand = true }; TableIndentation tableIndentation = new TableIndentation() { Width = -10, Type = TableWidthUnitValues.Dxa }; vishProps.Append(vishBorders, stylerunprops, tableWidth, tableposprops, tableStyle, tableLook, tableIndentation); testtable.Append(Columns(), vishProps); int[] widthIndex = new int[4] { 1780, 6230, 1590, 1320 }; int rows = perfectArray.GetUpperBound(0) + 1; int h = 0; for (int i = 0; i < rows; i++) { testtable.Append(HeaderRow()); var datarow = new TableRow(); var result = new TableCell(); var name = new TableCell(); var phone = new TableCell(); var ext = new TableCell(); var par1 = new Paragraph(new Run(new Text(String.Empty))); var par2 = new Paragraph(new Run(new Text(perfectArray[i, 0]))); var par3 = new Paragraph(new Run(new Text(perfectArray[i, 1]))); var par4 = new Paragraph(new Run(new Text(perfectArray[i, 2]))); result.Append(par1); name.Append(par2); phone.Append(par3); ext.Append(par4); datarow.Append(result, name, phone, ext); testtable.Append(datarow); testtable.Append(DatesRow()); testtable.Append(DescriptionRow()); } foreach (SdtBlock item in wordDocument.MainDocumentPart.Document.Body.Descendants <SdtBlock>().Where(e => e.Descendants <SdtAlias>().FirstOrDefault().Val == "PhoneTable")) { item.InsertAfterSelf(testtable); } using (WordprocessingDocument newDocument = WordprocessingDocument.Create(saveFile, WordprocessingDocumentType.Document, true)) { var maindoc = newDocument.MainDocumentPart; foreach (var parts in wordDocument.MainDocumentPart.Document.Descendants()) { maindoc.Document.Append(parts); } newDocument.MainDocumentPart.Document.Save(); } } }
public Table AppendInvoiceTableInfo(List <string> tableData, Table table, bool header) { TableRow tr = new TableRow(); PreviousTablePropertyExceptions ptpex = new PreviousTablePropertyExceptions(); TableCellMarginDefault tcm = new TableCellMarginDefault(); tcm.TopMargin = new TopMargin() { Width = "0", Type = TableWidthUnitValues.Dxa }; tcm.BottomMargin = new BottomMargin() { Width = "0", Type = TableWidthUnitValues.Dxa }; ptpex.Append(tcm); tr.Append(ptpex); TableCell tc; TableCellProperties tcp = new TableCellProperties(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center }); tcp.TableCellMargin = new TableCellMargin(new RightMargin() { Type = TableWidthUnitValues.Pct, Width = "50" }); tcp.TableCellMargin.LeftMargin = new LeftMargin() { Type = TableWidthUnitValues.Pct, Width = "50" }; tcp.TableCellMargin.TopMargin = new TopMargin() { Type = TableWidthUnitValues.Pct, Width = "1" }; ParagraphProperties ppp = new ParagraphProperties(new Justification() { Val = JustificationValues.Center }); ppp.Append(new KeepLines()); ppp.Append(new KeepNext()); SpacingBetweenLines sp = new SpacingBetweenLines(); sp.After = "0"; ppp.Append(sp); if (!header) { RunProperties rp = new RunProperties(new Bold() { Val = false }); Shading shading = new Shading(); rp.Bold.Val = false; rp.RunFonts = new RunFonts() { Ascii = "Calibri" }; rp.FontSize = new FontSize() { Val = new StringValue("22") }; //shading = new Shading() { Val = ShadingPatternValues.Clear, Color = "auto", Fill = "e3e6e7" }; shading = new Shading() { Val = ShadingPatternValues.Clear, Color = "auto" }; tcp.Shading = shading; for (int i = 0; i < tableData.Count; i++) { tc = new TableCell(); //TableStyle tableStyle = new TableStyle() { Val = "TableGrid" }; // Make the table width 100% of the page width. TableWidth tableWidth = new TableWidth() { Width = "50000", Type = TableWidthUnitValues.Auto }; tcp.Append(tableWidth); tc.Append((TableCellProperties)tcp.Clone()); tc.Append((ParagraphProperties)ppp.Clone()); Run r = new Run(); r.PrependChild <RunProperties>((RunProperties)rp.Clone()); r.Append(new Text(tableData[i].ToString())); tc.Append(new Paragraph(r)); tr.Append(tc); } } else { RunProperties rp = new RunProperties(new Bold() { Val = true }, new TabChar()); rp.Bold.Val = true; rp.RunFonts = new RunFonts() { Ascii = "Arial" }; rp.FontSize = new FontSize() { Val = new StringValue("20") }; //Color color = new Color() { Val = "365F91", ThemeColor = ThemeColorValues.Accent1, ThemeShade = "BF" }; Shading shading = new Shading() { Val = ShadingPatternValues.Clear, Color = "auto", Fill = "a7c6d7" }; //ppp.Shading = shading; tcp.TableCellMargin.TopMargin.Width = "200"; tcp.Shading = shading; for (int i = 0; i < tableData.Count; i++) { tc = new TableCell(); TableStyle tableStyle = new TableStyle() { Val = "TableGrid" }; // Make the table width 100% of the page width. TableWidth tableWidth = new TableWidth() { Width = "50000", Type = TableWidthUnitValues.Auto }; tcp.Append(tableStyle, tableWidth); tc.Append((TableCellProperties)tcp.Clone()); tc.Append((ParagraphProperties)ppp.Clone()); Run r = new Run(); r.PrependChild <RunProperties>((RunProperties)rp.Clone()); r.Append(new Text(tableData[i].ToString())); tc.Append(new Paragraph(r)); tr.Append(tc); } } table.Append(tr); return(table); }
private static Table GenerateEquipmentTable(IEnumerable <HetEquipment> equipmentList) { try { // create an empty table Table table = new Table(); TableProperties tableProperties1 = new TableProperties(); TableStyle tableStyle1 = new TableStyle() { Val = "TableGrid" }; TableWidth tableWidth1 = new TableWidth() { Width = "0", Type = TableWidthUnitValues.Auto }; TableLook tableLook1 = new TableLook() { Val = "04A0", FirstRow = true, LastRow = false, FirstColumn = true, LastColumn = false, NoHorizontalBand = false, NoVerticalBand = true }; tableProperties1.AppendChild(tableStyle1); tableProperties1.AppendChild(tableWidth1); tableProperties1.AppendChild(tableLook1); table.AppendChild(tableProperties1); // setup headers TableRow tableRow1 = new TableRow(); TableRowProperties rowProperties = new TableRowProperties(); rowProperties.AppendChild(new TableRowHeight() { Val = 200, HeightType = HeightRuleValues.AtLeast }); rowProperties.AppendChild(new TableHeader() { Val = OnOffOnlyValues.On }); tableRow1.AppendChild(rowProperties); // add columns tableRow1.AppendChild(SetupHeaderCell("Still own/ Re-register?", "1200", true)); tableRow1.AppendChild(SetupHeaderCell("Local Area", "1000", true)); tableRow1.AppendChild(SetupHeaderCell("Equipment Id", "1200", true)); tableRow1.AppendChild(SetupHeaderCell("Equipment Type", "1600")); tableRow1.AppendChild(SetupHeaderCell("Year/Make/Model/Serial Number/Size", "2400")); tableRow1.AppendChild(SetupHeaderCell("Attachments", "1200")); tableRow1.AppendChild(SetupHeaderCell("Owner Comments (sold, retired, etc.)", "2600", true)); table.AppendChild(tableRow1); // add rows for each equipment record foreach (HetEquipment equipment in equipmentList) { TableRow tableRowEquipment = new TableRow(); TableRowProperties equipmentRowProperties = new TableRowProperties(); equipmentRowProperties.AppendChild(new TableRowHeight() { Val = 200, HeightType = HeightRuleValues.AtLeast }); tableRowEquipment.AppendChild(equipmentRowProperties); // add equipment data tableRowEquipment.AppendChild(SetupCell("Yes No", true)); tableRowEquipment.AppendChild(SetupCell(equipment.LocalArea.Name, true)); tableRowEquipment.AppendChild(SetupCell(equipment.EquipmentCode, true)); tableRowEquipment.AppendChild(SetupCell(equipment.DistrictEquipmentType.DistrictEquipmentName)); string temp = $"{equipment.Year}/{equipment.Make}/{equipment.Model}/{equipment.SerialNumber}/{equipment.Size}"; tableRowEquipment.AppendChild(SetupCell(temp)); // attachments list temp = ""; int row = 1; foreach (HetEquipmentAttachment attachment in equipment.HetEquipmentAttachment) { temp = row == 1 ? $"{attachment.Description}" : $"{temp} / {attachment.Description}"; row++; } tableRowEquipment.AppendChild(SetupCell(temp)); // last column (blank) tableRowEquipment.AppendChild(SetupCell("")); table.AppendChild(tableRowEquipment); } return(table); } catch (Exception e) { Console.WriteLine(e); throw; } }
String CreateHeader(DataTable dt, IDictionary <Int32, Int32> columnLengths, TableStyle style) => new StringBuilder() .AppendLine(CreateLineRow(columnLengths, style.TopLeftCorner, style.TopMiddleCorner, style.TopRightCorner, style.HeaderTopHorizontal)) .AppendLine(CreateDataRow(columnLengths, style.HeaderLeftVertical, style.HeaderMiddleVertical, style.HeaderRightVertical, dt.Columns.Cast <DataColumn>().Select(dc => dc.ColumnName).ToArray())) .Append(CreateLineRow(columnLengths, style.MiddleLeftCorner, style.CenterCorner, style.MiddleRightCorner, style.HeaderBottomHorizontal)) .ToString();
void GenerateTableFormDB() { using (WordprocessingDocument myDoc = WordprocessingDocument.Open(docName, true)) { MainDocumentPart mainPart = myDoc.MainDocumentPart; Document doc = mainPart.Document; //Create new table with predefined table style Table table = new Table(); TableProperties tblPr = new TableProperties(); TableStyle tblStyle = new TableStyle() { Val = "MyTableStyle" }; tblPr.AppendChild(tblStyle); table.AppendChild(tblPr); string[] headerContent = new string[] { "Code", "Name", "Scientific Name" }; //Create header row TableRow header = CreateRow(headerContent); table.AppendChild(header); //Connect to database BirdTrackDataContext db = new BirdTrackDataContext(); var btoQuery = from b in db.btos select b; //For every product in my database create a new row in my table foreach (var item in btoQuery) { // price += Math.Round(item.ListPrice, 2); string[] content = new[] { item.bto_code, item.species_name, item.scientific_name}; TableRow tr = CreateRow(content); table.AppendChild(tr); } doc.Body.AppendChild(table); doc.Save(); } }
static Table NewTable(int columnCt) { // Create a table. Table tbl = new Table(); // Set the style and width for the table. TableProperties tableProp = new TableProperties(); TableStyle tableStyle = new TableStyle() { Val = "TableGrid" }; // Make the table width 100% of the page width. TableWidth tableWidth = new TableWidth() { Width = "5000", Type = TableWidthUnitValues.Pct }; // Apply tableProp.Append(tableStyle, tableWidth); tbl.AppendChild(tableProp); // Add columns to the table. TableGrid tg = new TableGrid(); for (int i = 0; i < columnCt; i++) { tg.AppendChild(new GridColumn()); } tbl.AppendChild(tg); //body.AppendChild(tbl); return tbl; }
internal void ApplyTableProperties(Table table, DocxNode node) { TableProperties tableProp = new TableProperties(); TableStyle tableStyle = new TableStyle() { Val = DocxTableProperties.tableGridName }; tableProp.Append(tableStyle); DocxTableStyle style = new DocxTableStyle(); style.Process(tableProp, this, node); table.AppendChild(tableProp); int count = GetTdCount(node); rowSpanInfo = new Dictionary<int, int>(); if (count > 0) { TableGrid tg = new TableGrid(); for (int i = 0; i < count; i++) { rowSpanInfo.Add(i, 0); tg.AppendChild(new GridColumn()); } table.AppendChild(tg); } }
/// <summary> /// Gets the table style as HTML. /// </summary> /// <param name="tableStyle">The table style.</param> /// <returns></returns> public string GetTableStyleAsHtml(TableStyle tableStyle) { string style = ""; try { if (tableStyle != null) { if (tableStyle.TableProperties != null) { if (tableStyle.TableProperties.Width != null) { string width = tableStyle.TableProperties.Width; if (width.EndsWith("cm")) { width = width.Replace("cm", ""); } else if (width.EndsWith("in")) { width = width.Replace("in", ""); } try { double wd = Convert.ToDouble(width, System.Globalization.NumberFormatInfo.InvariantInfo); string wdPx = ""; if (tableStyle.TableProperties.Width.EndsWith("cm")) { wdPx = SizeConverter.CmToPixelAsString(wd); } else if (tableStyle.TableProperties.Width.EndsWith("in")) { wdPx = SizeConverter.InchToPixelAsString(wd); } if (wdPx.Length > 0) { style = "width=\"" + wdPx.Replace("px", "") + "\" "; } } catch (Exception ex) { if (this.OnWarning != null) { AODLWarning warning = new AODLWarning("Exception while trying to build a table width width.: " + tableStyle.TableProperties.Width, ex); //warning.InMethod = AODLException.GetExceptionSourceInfo(new StackFrame(1, true)); //warning.OriginalException = ex; OnWarning(warning); } } } if (tableStyle.TableProperties.Align != null) { if (tableStyle.TableProperties.Align != "margin") { if (tableStyle.TableProperties.Align == "center") { style += "align=\"center\" "; } else if (tableStyle.TableProperties.Align == "right") { style += "align=\"center\" "; //Because display prob by some browser } } } } } } catch (Exception ex) { throw new AODLException("Exception while trying to build a HTML style string from a TableStyle.", ex); } return(style); }
private TableStyle GetDefaultUserTableStyle(string tableName, string attributeName) { var style = new TableStyle { Id = 0, RelatedIdentity = 0, TableName = tableName, AttributeName = attributeName, Taxis = 0, DisplayName = string.Empty, HelpText = string.Empty, List = false, InputType = InputType.Text, DefaultValue = string.Empty, Horizontal = true }; if (StringUtils.EqualsIgnoreCase(attributeName, nameof(User.DisplayName))) { style.AttributeName = nameof(User.DisplayName); style.DisplayName = "姓名"; style.RuleValues = TranslateUtils.JsonSerialize(new List <InputStyleRule> { new InputStyleRule { Type = ValidateType.Required, Message = ValidateType.Required.GetDisplayName() } }); style.Taxis = 1; } else if (StringUtils.EqualsIgnoreCase(attributeName, nameof(User.Mobile))) { style.AttributeName = nameof(User.Mobile); style.DisplayName = "手机号"; style.HelpText = "可用于登录、找回密码等功能"; style.InputType = InputType.Number; style.RuleValues = TranslateUtils.JsonSerialize(new List <InputStyleRule> { new InputStyleRule { Type = ValidateType.Mobile, Message = ValidateType.Mobile.GetDisplayName() } }); style.Taxis = 2; } else if (StringUtils.EqualsIgnoreCase(attributeName, nameof(User.Email))) { style.AttributeName = nameof(User.Email); style.DisplayName = "邮箱"; style.HelpText = "可用于登录、找回密码等功能"; style.RuleValues = TranslateUtils.JsonSerialize(new List <InputStyleRule> { new InputStyleRule { Type = ValidateType.Email, Message = ValidateType.Email.GetDisplayName() } }); style.Taxis = 3; } style.Items = TranslateUtils.JsonDeserialize <List <InputStyleItem> >(style.ItemValues); style.Rules = TranslateUtils.JsonDeserialize <List <InputStyleRule> >(style.RuleValues); return(style); }
// private static void ddd() // { // var img = new BitmapImage(new Uri("", UriKind.RelativeOrAbsolute)); // var widthPx = img.PixelWidth; // var heightPx = img.PixelHeight; // var horzRezDpi = img.DpiX; // var vertRezDpi = img.DpiY; // const int emusPerInch = 914400; // const int emusPerCm = 360000; // var widthEmus = (long) (widthPx/horzRezDpi*emusPerInch); // var heightEmus = (long) (heightPx/vertRezDpi*emusPerInch); // var maxWidthEmus = (long) (maxWidthCm*emusPerCm); // if (widthEmus > maxWidthEmus) // { // var ratio = (heightEmus*1.0m)/widthEmus; // widthEmus = maxWidthEmus; // heightEmus = (long) (widthEmus*ratio); // } // } // public void ResizeImage(string OriginalFile, string NewFile, int NewWidth, int MaxHeight, bool OnlyResizeIfWider) //{ // System.Drawing.Image FullsizeImage = System.Drawing.Image.FromFile(OriginalFile); // // // Prevent using images internal thumbnail // FullsizeImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone); // FullsizeImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone); // // if (OnlyResizeIfWider) // { // if (FullsizeImage.Width <= NewWidth) // { // NewWidth = FullsizeImage.Width; // } // } // // int NewHeight = FullsizeImage.Height * NewWidth / FullsizeImage.Width; // if (NewHeight > MaxHeight) // { // // Resize with height instead // NewWidth = FullsizeImage.Width * MaxHeight / FullsizeImage.Height; // NewHeight = MaxHeight; // } // // System.Drawing.Image NewImage = FullsizeImage.GetThumbnailImage(NewWidth, NewHeight, null, IntPtr.Zero); // // // Clear handle to original file so that we can overwrite it if necessary // FullsizeImage.Dispose(); // // // Save resized picture // NewImage.Save(NewFile); //} // // Creates an Paragraph instance and adds its children. public TableRow GenerateTableRow(IndividualInfo ii, string iid) { TableRow tableRow1 = new TableRow() { RsidTableRowAddition = "00FB1F22", RsidTableRowProperties = "00442AD3" }; TableRowProperties tableRowProperties1 = new TableRowProperties(); CantSplit cantSplit1 = new CantSplit(); tableRowProperties1.Append(cantSplit1); TableCell tableCell1 = new TableCell(); TableCellProperties tableCellProperties1 = new TableCellProperties(); TableCellWidth tableCellWidth1 = new TableCellWidth() { Width = "4788", Type = TableWidthUnitValues.Dxa }; tableCellProperties1.Append(tableCellWidth1); Paragraph paragraph1 = new Paragraph() { RsidParagraphAddition = "00FB1F22", RsidParagraphProperties = "00F06304", RsidRunAdditionDefault = "00FB1F22" }; Run run1 = new Run(); Break break1 = new Break(); run1.Append(break1); Run run2 = new Run(); RunProperties runProperties1 = new RunProperties(); NoProof noProof1 = new NoProof(); runProperties1.Append(noProof1); Text text1 = new Text(); text1.Text = ii.FirstName; run2.Append(runProperties1); run2.Append(text1); Run run3 = new Run(); Text text2 = new Text() { Space = SpaceProcessingModeValues.Preserve }; text2.Text = " "; run3.Append(text2); Run run4 = new Run(); RunProperties runProperties2 = new RunProperties(); NoProof noProof2 = new NoProof(); runProperties2.Append(noProof2); Text text3 = new Text(); text3.Text = ii.LastName; run4.Append(runProperties2); run4.Append(text3); paragraph1.Append(run1); paragraph1.Append(run2); paragraph1.Append(run3); paragraph1.Append(run4); Paragraph paragraph2 = new Paragraph() { RsidParagraphAddition = "00FB1F22", RsidParagraphProperties = "00731A43", RsidRunAdditionDefault = "00FB1F22" }; Run run5 = new Run(); RunProperties runProperties3 = new RunProperties(); NoProof noProof3 = new NoProof(); runProperties3.Append(noProof3); Text text4 = new Text(); text4.Text = ii.Address; run5.Append(runProperties3); run5.Append(text4); paragraph2.Append(run5); Paragraph paragraph2a = null; if (ii.Address2.HasValue()) { paragraph2a = new Paragraph() { RsidParagraphAddition = "00FB1F22", RsidParagraphProperties = "00731A43", RsidRunAdditionDefault = "00FB1F22" }; Run r = new Run(); RunProperties rp = new RunProperties(); NoProof np = new NoProof(); rp.Append(np); Text tt = new Text(); tt.Text = ii.Address; r.Append(rp); r.Append(tt); paragraph2a.Append(r); } Paragraph paragraph3 = new Paragraph() { RsidParagraphAddition = "00FB1F22", RsidParagraphProperties = "00731A43", RsidRunAdditionDefault = "00FB1F22" }; Run run6 = new Run(); RunProperties runProperties4 = new RunProperties(); NoProof noProof4 = new NoProof(); runProperties4.Append(noProof4); Text text5 = new Text(); text5.Text = ii.CityStateZip; run6.Append(runProperties4); run6.Append(text5); paragraph3.Append(run6); Paragraph paragraph4 = new Paragraph() { RsidParagraphAddition = "00FB1F22", RsidParagraphProperties = "00F06304", RsidRunAdditionDefault = "00FB1F22" }; Table table1 = new Table(); TableProperties tableProperties1 = new TableProperties(); TableStyle tableStyle1 = new TableStyle() { Val = "TableGrid" }; TableWidth tableWidth1 = new TableWidth() { Width = "0", Type = TableWidthUnitValues.Auto }; TableBorders tableBorders1 = new TableBorders(); TopBorder topBorder1 = new TopBorder() { Val = BorderValues.None, Color = "auto", Size = (UInt32Value)0U, Space = (UInt32Value)0U }; LeftBorder leftBorder1 = new LeftBorder() { Val = BorderValues.None, Color = "auto", Size = (UInt32Value)0U, Space = (UInt32Value)0U }; BottomBorder bottomBorder1 = new BottomBorder() { Val = BorderValues.None, Color = "auto", Size = (UInt32Value)0U, Space = (UInt32Value)0U }; RightBorder rightBorder1 = new RightBorder() { Val = BorderValues.None, Color = "auto", Size = (UInt32Value)0U, Space = (UInt32Value)0U }; InsideHorizontalBorder insideHorizontalBorder1 = new InsideHorizontalBorder() { Val = BorderValues.None, Color = "auto", Size = (UInt32Value)0U, Space = (UInt32Value)0U }; InsideVerticalBorder insideVerticalBorder1 = new InsideVerticalBorder() { Val = BorderValues.None, Color = "auto", Size = (UInt32Value)0U, Space = (UInt32Value)0U }; tableBorders1.Append(topBorder1); tableBorders1.Append(leftBorder1); tableBorders1.Append(bottomBorder1); tableBorders1.Append(rightBorder1); tableBorders1.Append(insideHorizontalBorder1); tableBorders1.Append(insideVerticalBorder1); TableLook tableLook1 = new TableLook() { Val = "04A0", FirstRow = true, LastRow = false, FirstColumn = true, LastColumn = false, NoHorizontalBand = false, NoVerticalBand = true }; tableProperties1.Append(tableStyle1); tableProperties1.Append(tableWidth1); tableProperties1.Append(tableBorders1); tableProperties1.Append(tableLook1); TableGrid tableGrid1 = new TableGrid(); GridColumn gridColumn1 = new GridColumn() { Width = "1435" }; GridColumn gridColumn2 = new GridColumn() { Width = "3122" }; tableGrid1.Append(gridColumn1); tableGrid1.Append(gridColumn2); TableRow tableRow2 = new TableRow() { RsidTableRowAddition = "00FB1F22", RsidTableRowProperties = "00731A43" }; TableCell tableCell2 = new TableCell(); TableCellProperties tableCellProperties2 = new TableCellProperties(); TableCellWidth tableCellWidth2 = new TableCellWidth() { Width = "1435", Type = TableWidthUnitValues.Dxa }; tableCellProperties2.Append(tableCellWidth2); Paragraph paragraph5 = new Paragraph() { RsidParagraphAddition = "00FB1F22", RsidParagraphProperties = "00F06304", RsidRunAdditionDefault = "00FB1F22" }; Run run11 = new Run(); Text text10 = new Text(); text10.Text = "Email"; run11.Append(text10); paragraph5.Append(run11); tableCell2.Append(tableCellProperties2); tableCell2.Append(paragraph5); TableCell tableCell3 = new TableCell(); TableCellProperties tableCellProperties3 = new TableCellProperties(); TableCellWidth tableCellWidth3 = new TableCellWidth() { Width = "3122", Type = TableWidthUnitValues.Dxa }; tableCellProperties3.Append(tableCellWidth3); Paragraph paragraph6 = new Paragraph() { RsidParagraphAddition = "00FB1F22", RsidParagraphProperties = "00485B24", RsidRunAdditionDefault = "00FB1F22" }; paragraph6.Append(new Run(new Text(ii.Email))); tableCell3.Append(tableCellProperties3); tableCell3.Append(paragraph6); tableRow2.Append(tableCell2); tableRow2.Append(tableCell3); TableRow tableRow3 = new TableRow() { RsidTableRowAddition = "00FB1F22", RsidTableRowProperties = "00731A43" }; TableCell tableCell4 = new TableCell(); TableCellProperties tableCellProperties4 = new TableCellProperties(); TableCellWidth tableCellWidth4 = new TableCellWidth() { Width = "1435", Type = TableWidthUnitValues.Dxa }; tableCellProperties4.Append(tableCellWidth4); Paragraph paragraph7 = new Paragraph() { RsidParagraphAddition = "00FB1F22", RsidParagraphProperties = "00F06304", RsidRunAdditionDefault = "00FB1F22" }; Run run12 = new Run(); Text text11 = new Text(); text11.Text = "Home Phone"; run12.Append(text11); paragraph7.Append(run12); tableCell4.Append(tableCellProperties4); tableCell4.Append(paragraph7); TableCell tableCell5 = new TableCell(); TableCellProperties tableCellProperties5 = new TableCellProperties(); TableCellWidth tableCellWidth5 = new TableCellWidth() { Width = "3122", Type = TableWidthUnitValues.Dxa }; tableCellProperties5.Append(tableCellWidth5); Paragraph paragraph8 = new Paragraph() { RsidParagraphAddition = "00FB1F22", RsidParagraphProperties = "00485B24", RsidRunAdditionDefault = "00FB1F22" }; Run run13 = new Run(); RunProperties runProperties7 = new RunProperties(); NoProof noProof7 = new NoProof(); runProperties7.Append(noProof7); Text text12 = new Text(); text12.Text = ii.HomePhone.FmtFone(); run13.Append(runProperties7); run13.Append(text12); Run run14 = new Run(); Text text13 = new Text() { Space = SpaceProcessingModeValues.Preserve }; text13.Text = " "; run14.Append(text13); paragraph8.Append(run13); paragraph8.Append(run14); tableCell5.Append(tableCellProperties5); tableCell5.Append(paragraph8); tableRow3.Append(tableCell4); tableRow3.Append(tableCell5); TableRow tableRow4 = new TableRow() { RsidTableRowAddition = "00FB1F22", RsidTableRowProperties = "00731A43" }; TableCell tableCell6 = new TableCell(); TableCellProperties tableCellProperties6 = new TableCellProperties(); TableCellWidth tableCellWidth6 = new TableCellWidth() { Width = "1435", Type = TableWidthUnitValues.Dxa }; tableCellProperties6.Append(tableCellWidth6); Paragraph paragraph9 = new Paragraph() { RsidParagraphAddition = "00FB1F22", RsidParagraphProperties = "00F06304", RsidRunAdditionDefault = "00FB1F22" }; Run run15 = new Run(); Text text14 = new Text(); text14.Text = "Cell Phone"; run15.Append(text14); paragraph9.Append(run15); tableCell6.Append(tableCellProperties6); tableCell6.Append(paragraph9); TableCell tableCell7 = new TableCell(); TableCellProperties tableCellProperties7 = new TableCellProperties(); TableCellWidth tableCellWidth7 = new TableCellWidth() { Width = "3122", Type = TableWidthUnitValues.Dxa }; tableCellProperties7.Append(tableCellWidth7); Paragraph paragraph10 = new Paragraph() { RsidParagraphAddition = "00FB1F22", RsidParagraphProperties = "00F06304", RsidRunAdditionDefault = "00FB1F22" }; Run run16 = new Run(); RunProperties runProperties8 = new RunProperties(); NoProof noProof8 = new NoProof(); runProperties8.Append(noProof8); Text text15 = new Text(); text15.Text = ii.CellPhone.FmtFone(); run16.Append(runProperties8); run16.Append(text15); paragraph10.Append(run16); tableCell7.Append(tableCellProperties7); tableCell7.Append(paragraph10); tableRow4.Append(tableCell6); tableRow4.Append(tableCell7); TableRow tableRow5 = new TableRow() { RsidTableRowAddition = "00FB1F22", RsidTableRowProperties = "00731A43" }; TableCell tableCell8 = new TableCell(); TableCellProperties tableCellProperties8 = new TableCellProperties(); TableCellWidth tableCellWidth8 = new TableCellWidth() { Width = "1435", Type = TableWidthUnitValues.Dxa }; tableCellProperties8.Append(tableCellWidth8); Paragraph paragraph11 = new Paragraph() { RsidParagraphAddition = "00FB1F22", RsidParagraphProperties = "00F06304", RsidRunAdditionDefault = "00FB1F22" }; Run run17 = new Run(); Text text16 = new Text(); text16.Text = "Work Phone"; run17.Append(text16); paragraph11.Append(run17); tableCell8.Append(tableCellProperties8); tableCell8.Append(paragraph11); TableCell tableCell9 = new TableCell(); TableCellProperties tableCellProperties9 = new TableCellProperties(); TableCellWidth tableCellWidth9 = new TableCellWidth() { Width = "3122", Type = TableWidthUnitValues.Dxa }; tableCellProperties9.Append(tableCellWidth9); Paragraph paragraph12 = new Paragraph() { RsidParagraphAddition = "00FB1F22", RsidParagraphProperties = "00F06304", RsidRunAdditionDefault = "00FB1F22" }; Run run18 = new Run(); RunProperties runProperties9 = new RunProperties(); NoProof noProof9 = new NoProof(); runProperties9.Append(noProof9); Text text17 = new Text(); text17.Text = ii.WorkPhone.FmtFone(); run18.Append(runProperties9); run18.Append(text17); paragraph12.Append(run18); tableCell9.Append(tableCellProperties9); tableCell9.Append(paragraph12); tableRow5.Append(tableCell8); tableRow5.Append(tableCell9); TableRow tableRow6 = new TableRow() { RsidTableRowAddition = "00FB1F22", RsidTableRowProperties = "00731A43" }; TableCell tableCell10 = new TableCell(); TableCellProperties tableCellProperties10 = new TableCellProperties(); TableCellWidth tableCellWidth10 = new TableCellWidth() { Width = "1435", Type = TableWidthUnitValues.Dxa }; tableCellProperties10.Append(tableCellWidth10); Paragraph paragraph13 = new Paragraph() { RsidParagraphAddition = "00FB1F22", RsidParagraphProperties = "00F06304", RsidRunAdditionDefault = "00FB1F22" }; Run run19 = new Run(); Text text18 = new Text(); text18.Text = "Birthday"; run19.Append(text18); paragraph13.Append(run19); tableCell10.Append(tableCellProperties10); tableCell10.Append(paragraph13); TableCell tableCell11 = new TableCell(); TableCellProperties tableCellProperties11 = new TableCellProperties(); TableCellWidth tableCellWidth11 = new TableCellWidth() { Width = "3122", Type = TableWidthUnitValues.Dxa }; tableCellProperties11.Append(tableCellWidth11); Paragraph paragraph14 = new Paragraph() { RsidParagraphAddition = "00FB1F22", RsidParagraphProperties = "00BC57A3", RsidRunAdditionDefault = "00FB1F22" }; Run run20 = new Run(); RunProperties runProperties10 = new RunProperties(); NoProof noProof10 = new NoProof(); runProperties10.Append(noProof10); Text text19 = new Text(); text19.Text = ii.BirthDay; run20.Append(runProperties10); run20.Append(text19); paragraph14.Append(run20); tableCell11.Append(tableCellProperties11); tableCell11.Append(paragraph14); tableRow6.Append(tableCell10); tableRow6.Append(tableCell11); TableRow tableRow7 = new TableRow() { RsidTableRowAddition = "00FB1F22", RsidTableRowProperties = "00731A43" }; TableCell tableCell12 = new TableCell(); TableCellProperties tableCellProperties12 = new TableCellProperties(); TableCellWidth tableCellWidth12 = new TableCellWidth() { Width = "1435", Type = TableWidthUnitValues.Dxa }; tableCellProperties12.Append(tableCellWidth12); Paragraph paragraph15 = new Paragraph() { RsidParagraphAddition = "00FB1F22", RsidParagraphProperties = "006D0F9D", RsidRunAdditionDefault = "00FB1F22" }; Run run21 = new Run(); Text text20 = new Text(); text20.Text = "Anniversary"; run21.Append(text20); paragraph15.Append(run21); tableCell12.Append(tableCellProperties12); tableCell12.Append(paragraph15); TableCell tableCell13 = new TableCell(); TableCellProperties tableCellProperties13 = new TableCellProperties(); TableCellWidth tableCellWidth13 = new TableCellWidth() { Width = "3122", Type = TableWidthUnitValues.Dxa }; tableCellProperties13.Append(tableCellWidth13); Paragraph paragraph16 = new Paragraph() { RsidParagraphAddition = "00FB1F22", RsidParagraphProperties = "00F06304", RsidRunAdditionDefault = "00FB1F22" }; paragraph16.Append(new Run(new Text(ii.Anniversary))); tableCell13.Append(tableCellProperties13); tableCell13.Append(paragraph16); tableRow7.Append(tableCell12); tableRow7.Append(tableCell13); TableRow tableRow8 = new TableRow() { RsidTableRowAddition = "00FB1F22", RsidTableRowProperties = "00731A43" }; TableCell tableCell14 = new TableCell(); TableCellProperties tableCellProperties14 = new TableCellProperties(); TableCellWidth tableCellWidth14 = new TableCellWidth() { Width = "1435", Type = TableWidthUnitValues.Dxa }; tableCellProperties14.Append(tableCellWidth14); Paragraph paragraph17 = new Paragraph() { RsidParagraphAddition = "00FB1F22", RsidParagraphProperties = "00F06304", RsidRunAdditionDefault = "00FB1F22" }; Run run22 = new Run(); Text text21 = new Text(); text21.Text = "Spouse"; run22.Append(text21); paragraph17.Append(run22); tableCell14.Append(tableCellProperties14); tableCell14.Append(paragraph17); TableCell tableCell15 = new TableCell(); TableCellProperties tableCellProperties15 = new TableCellProperties(); TableCellWidth tableCellWidth15 = new TableCellWidth() { Width = "3122", Type = TableWidthUnitValues.Dxa }; tableCellProperties15.Append(tableCellWidth15); Paragraph paragraph18 = new Paragraph() { RsidParagraphAddition = "00FB1F22", RsidParagraphProperties = "00F06304", RsidRunAdditionDefault = "00FB1F22" }; ParagraphProperties paragraphProperties1 = new ParagraphProperties(); ParagraphMarkRunProperties paragraphMarkRunProperties1 = new ParagraphMarkRunProperties(); NoProof noProof11 = new NoProof(); paragraphMarkRunProperties1.Append(noProof11); paragraphProperties1.Append(paragraphMarkRunProperties1); Run run23 = new Run(); RunProperties runProperties11 = new RunProperties(); NoProof noProof12 = new NoProof(); runProperties11.Append(noProof12); Text text22 = new Text(); text22.Text = ii.Spouse; run23.Append(runProperties11); run23.Append(text22); paragraph18.Append(paragraphProperties1); paragraph18.Append(run23); tableCell15.Append(tableCellProperties15); tableCell15.Append(paragraph18); tableRow8.Append(tableCell14); tableRow8.Append(tableCell15); table1.Append(tableProperties1); table1.Append(tableGrid1); table1.Append(tableRow2); table1.Append(tableRow3); table1.Append(tableRow4); table1.Append(tableRow5); table1.Append(tableRow6); table1.Append(tableRow7); table1.Append(tableRow8); Paragraph paragraph19 = new Paragraph() { RsidParagraphAddition = "00FB1F22", RsidParagraphProperties = "00485B24", RsidRunAdditionDefault = "00FB1F22" }; tableCell1.Append(tableCellProperties1); tableCell1.Append(paragraph1); tableCell1.Append(paragraph2); if (paragraph2a != null) { tableCell1.Append(paragraph2a); } tableCell1.Append(paragraph3); tableCell1.Append(paragraph4); tableCell1.Append(table1); tableCell1.Append(paragraph19); TableCell tableCell16 = new TableCell(); TableCellProperties tableCellProperties16 = new TableCellProperties(); TableCellWidth tableCellWidth16 = new TableCellWidth() { Width = "4788", Type = TableWidthUnitValues.Dxa }; TableCellVerticalAlignment tableCellVerticalAlignment1 = new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center }; tableCellProperties16.Append(tableCellWidth16); tableCellProperties16.Append(tableCellVerticalAlignment1); tableCell16.Append(tableCellProperties16); Paragraph paragraph20 = new Paragraph() { RsidParagraphAddition = "00FB1F22", RsidParagraphProperties = "00960953", RsidRunAdditionDefault = "00FB1F22" }; ParagraphProperties paragraphProperties2 = new ParagraphProperties(); Justification justification1 = new Justification() { Val = JustificationValues.Center }; paragraphProperties2.Append(justification1); paragraph20.Append(paragraphProperties2); if (iid.HasValue()) { Run run24 = new Run(); RunProperties runProperties12 = new RunProperties(); NoProof noProof13 = new NoProof(); runProperties12.Append(noProof13); Drawing drawing1 = new Drawing(); Wp.Inline inline1 = new Wp.Inline() { DistanceFromTop = (UInt32Value)0U, DistanceFromBottom = (UInt32Value)0U, DistanceFromLeft = (UInt32Value)0U, DistanceFromRight = (UInt32Value)0U }; Wp.Extent extent1 = new Wp.Extent() { Cx = 1428750L, Cy = 1905000L }; Wp.EffectExtent effectExtent1 = new Wp.EffectExtent() { LeftEdge = 0L, TopEdge = 0L, RightEdge = 0L, BottomEdge = 0L }; Wp.DocProperties docProperties1 = new Wp.DocProperties() { Id = (UInt32Value)1U, Name = "Picture 1", Description = "D:\\Pictures\\ttt.jpg" }; Wp.NonVisualGraphicFrameDrawingProperties nonVisualGraphicFrameDrawingProperties1 = new Wp.NonVisualGraphicFrameDrawingProperties(); A.GraphicFrameLocks graphicFrameLocks1 = new A.GraphicFrameLocks() { NoChangeAspect = true }; graphicFrameLocks1.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main"); nonVisualGraphicFrameDrawingProperties1.Append(graphicFrameLocks1); A.Graphic graphic1 = new A.Graphic(); graphic1.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main"); A.GraphicData graphicData1 = new A.GraphicData() { Uri = "http://schemas.openxmlformats.org/drawingml/2006/picture" }; Pic.Picture picture1 = new Pic.Picture(); picture1.AddNamespaceDeclaration("pic", "http://schemas.openxmlformats.org/drawingml/2006/picture"); Pic.NonVisualPictureProperties nonVisualPictureProperties1 = new Pic.NonVisualPictureProperties(); Pic.NonVisualDrawingProperties nonVisualDrawingProperties1 = new Pic.NonVisualDrawingProperties() { Id = (UInt32Value)0U, Name = "Picture 459", Description = "D:\\Pictures\\ttt.jpg" }; Pic.NonVisualPictureDrawingProperties nonVisualPictureDrawingProperties1 = new Pic.NonVisualPictureDrawingProperties(); A.PictureLocks pictureLocks1 = new A.PictureLocks() { NoChangeAspect = false, NoChangeArrowheads = true }; nonVisualPictureDrawingProperties1.Append(pictureLocks1); nonVisualPictureProperties1.Append(nonVisualDrawingProperties1); nonVisualPictureProperties1.Append(nonVisualPictureDrawingProperties1); Pic.BlipFill blipFill1 = new Pic.BlipFill(); A.Blip blip1 = new A.Blip() { Embed = iid }; A.BlipExtensionList blipExtensionList1 = new A.BlipExtensionList(); A.BlipExtension blipExtension1 = new A.BlipExtension() { Uri = "{28A0092B-C50C-407E-A947-70E740481C1C}" }; A14.UseLocalDpi useLocalDpi1 = new A14.UseLocalDpi() { Val = false }; useLocalDpi1.AddNamespaceDeclaration("a14", "http://schemas.microsoft.com/office/drawing/2010/main"); blipExtension1.Append(useLocalDpi1); blipExtensionList1.Append(blipExtension1); blip1.Append(blipExtensionList1); A.SourceRectangle sourceRectangle1 = new A.SourceRectangle(); A.Stretch stretch1 = new A.Stretch(); A.FillRectangle fillRectangle1 = new A.FillRectangle(); stretch1.Append(fillRectangle1); blipFill1.Append(blip1); blipFill1.Append(sourceRectangle1); blipFill1.Append(stretch1); Pic.ShapeProperties shapeProperties1 = new Pic.ShapeProperties() { BlackWhiteMode = A.BlackWhiteModeValues.Auto }; A.Transform2D transform2D1 = new A.Transform2D(); A.Offset offset1 = new A.Offset() { X = 0L, Y = 0L }; A.Extents extents1 = new A.Extents() { Cx = 1428750L, Cy = 1905000L }; transform2D1.Append(offset1); transform2D1.Append(extents1); A.PresetGeometry presetGeometry1 = new A.PresetGeometry() { Preset = A.ShapeTypeValues.Rectangle }; A.AdjustValueList adjustValueList1 = new A.AdjustValueList(); presetGeometry1.Append(adjustValueList1); A.NoFill noFill1 = new A.NoFill(); A.Outline outline1 = new A.Outline(); A.NoFill noFill2 = new A.NoFill(); outline1.Append(noFill2); shapeProperties1.Append(transform2D1); shapeProperties1.Append(presetGeometry1); shapeProperties1.Append(noFill1); shapeProperties1.Append(outline1); picture1.Append(nonVisualPictureProperties1); picture1.Append(blipFill1); picture1.Append(shapeProperties1); graphicData1.Append(picture1); graphic1.Append(graphicData1); inline1.Append(extent1); inline1.Append(effectExtent1); inline1.Append(docProperties1); inline1.Append(nonVisualGraphicFrameDrawingProperties1); inline1.Append(graphic1); drawing1.Append(inline1); run24.Append(runProperties12); run24.Append(drawing1); paragraph20.Append(run24); } tableCell16.Append(paragraph20); BookmarkStart bookmarkStart1 = new BookmarkStart() { Name = "_GoBack", Id = "0" }; BookmarkEnd bookmarkEnd1 = new BookmarkEnd() { Id = "0" }; tableRow1.Append(tableRowProperties1); tableRow1.Append(tableCell1); tableRow1.Append(tableCell16); tableRow1.Append(bookmarkStart1); tableRow1.Append(bookmarkEnd1); return(tableRow1); }
public void SendEmail() { DataTable zamok = Zamowienia_DoWyslaniaOK().Result; foreach (DataRow r in zamok.Rows) { #region Pobieranie danych i tworzenie ciała maila. rec1.CreateNewDocument(); rec1.LoadDocument("Zamowienie_OK.docx"); string Status_Zam = ""; string Producent; string PH_Producent; string Numer_Zam; string FileDate; string ZamDate; string Uwagi; string Rodzaj_zam; string XL_Akronim; string Prod_Akronim; string Prod_Adres; if (bool.TryParse(r["Zpn_Alert"].ToString(), out bool al)) { if (al) { Status_Zam = "Błędy mapowania towarów. Obsługa CallCenter"; } else { Status_Zam = "OK. Wysłane do Mobiusa."; } } else { Status_Zam = "OK. Wysłane do Mobiusa."; } if (r["Zpn_Producent"].ToString().Length > 1) { Producent = r["Zpn_Producent"].ToString(); } else { Producent = "BŁĄD"; } if (r["Zpn_NAZWISKO"].ToString().Length > 1) { PH_Producent = r["Zpn_NAZWISKO"].ToString() + " " + r["Zpn_IMIE"].ToString(); } else { PH_Producent = "BŁĄD"; } if (r["Zpn_NR_ZAM"].ToString().Length > 1) { Numer_Zam = r["Zpn_NR_ZAM"].ToString(); } else { Numer_Zam = "BŁĄD"; } if (DateTime.TryParse(r["Zpn_DataPliku"].ToString(), out DateTime Data_Otrz)) { FileDate = Data_Otrz.ToShortDateString() + " " + Data_Otrz.ToShortTimeString(); } else { FileDate = "BŁĄD"; } if (DateTime.TryParse(r["Zpn_DATA_ZAM"].ToString(), out DateTime Data_Zam)) { ZamDate = Data_Zam.ToShortDateString() + " " + Data_Zam.ToShortTimeString(); } else { ZamDate = "BŁĄD"; } if (r["Zpn_UWAGI"].ToString().Length > 1) { Uwagi = r["Zpn_UWAGI"].ToString(); } else { Uwagi = "BŁĄD"; } if (r["Zpn_TYP_ZAM"].ToString().Length > 1) { if (r["Zpn_TYP_ZAM"].ToString() == "ZG") { Rodzaj_zam = "Gratisowe"; } else { Rodzaj_zam = "Standard"; } } else { Rodzaj_zam = "BŁĄD"; } if (r["Knt_Akronim"].ToString().Length > 1) { XL_Akronim = r["Knt_Akronim"].ToString(); } else { XL_Akronim = "BŁĄD"; } if (r["Zpn_NAZWA"].ToString().Length > 1) { Prod_Akronim = r["Zpn_NAZWA"].ToString(); } else { Prod_Akronim = "BŁĄD"; } if ((r["Zpn_MIASTO"].ToString() + r["Zpn_ULICA"].ToString()).Length > 1) { Prod_Adres = r["Zpn_MIASTO"].ToString() + ", " + r["Zpn_ULICA"].ToString(); } else { Prod_Adres = "BŁĄD"; } if (Int32.TryParse(r["Zpn_Id"].ToString(), out int Zpn_id)) { } else { Zpn_id = 0; } rec1.Document.ReplaceAll("<@Status_Zam>", Status_Zam, SearchOptions.None); rec1.Document.ReplaceAll("<@Producent>", Producent, SearchOptions.None); rec1.Document.ReplaceAll("<@PH_Producent>", PH_Producent, SearchOptions.None); rec1.Document.ReplaceAll("<@Numer_Zam>", Numer_Zam, SearchOptions.None); rec1.Document.ReplaceAll("<@Data_Otrz>", FileDate, SearchOptions.None); rec1.Document.ReplaceAll("<@Data_Zam>", ZamDate, SearchOptions.None); rec1.Document.ReplaceAll("<@Uwagi>", Uwagi, SearchOptions.None); rec1.Document.ReplaceAll("<@Rodzaj_Zam>", Rodzaj_zam, SearchOptions.None); rec1.Document.ReplaceAll("<@Knt_XLAkr>", XL_Akronim, SearchOptions.None); rec1.Document.ReplaceAll("<@Knt_ZamProd>", Prod_Akronim, SearchOptions.None); rec1.Document.ReplaceAll("<@Knt_Adres>", Prod_Adres, SearchOptions.None); DocumentRange[] wyniki = rec1.Document.FindAll("<@TABELA>", SearchOptions.None); if (wyniki.Length > 0) { // Paragraph par = rec1.Document.Paragraphs.Get(wyniki[0].Start); DocumentPosition pos = wyniki[0].Start; SubDocument doc = pos.BeginUpdateDocument(); // Add the table rec1.Document.Tables.Create(pos, 1, 9, AutoFitBehaviorType.AutoFitToContents); // Format the table Table tbl = rec1.Document.Tables[0]; pos.EndUpdateDocument(doc); try { tbl.BeginUpdate(); CharacterProperties cp_Tbl = doc.BeginUpdateCharacters(tbl.Range); cp_Tbl.FontSize = 10; cp_Tbl.FontName = "Calibri"; doc.EndUpdateCharacters(cp_Tbl); //tbl.BeginUpdate(); // Insert header caption and format the columns tbl.Rows[0].HeightType = HeightType.Exact; tbl.Rows[0].Height = 80f; doc.InsertSingleLineText(tbl[0, 0].Range.Start, "Lp."); doc.InsertSingleLineText(tbl[0, 1].Range.Start, "Alert"); doc.InsertSingleLineText(tbl[0, 2].Range.Start, "Kod"); doc.InsertSingleLineText(tbl[0, 3].Range.Start, "Towar"); doc.InsertSingleLineText(tbl[0, 4].Range.Start, "il. szt."); doc.InsertSingleLineText(tbl[0, 5].Range.Start, "Ilość"); doc.InsertSingleLineText(tbl[0, 6].Range.Start, "JM"); doc.InsertSingleLineText(tbl[0, 7].Range.Start, "Cena"); doc.InsertSingleLineText(tbl[0, 8].Range.Start, "Gratis"); tbl[0, 0].PreferredWidthType = WidthType.Fixed; tbl[0, 0].PreferredWidth = DevExpress.Office.Utils.Units.InchesToDocumentsF(0.2f); tbl[0, 0].VerticalAlignment = TableCellVerticalAlignment.Center; tbl[0, 1].PreferredWidthType = WidthType.Fixed; tbl[0, 1].PreferredWidth = DevExpress.Office.Utils.Units.InchesToDocumentsF(0.4f); tbl[0, 1].VerticalAlignment = TableCellVerticalAlignment.Center; tbl[0, 2].PreferredWidthType = WidthType.Fixed; tbl[0, 2].PreferredWidth = DevExpress.Office.Utils.Units.InchesToDocumentsF(0.8f); tbl[0, 2].VerticalAlignment = TableCellVerticalAlignment.Center; tbl[0, 3].PreferredWidthType = WidthType.Fixed; tbl[0, 3].PreferredWidth = DevExpress.Office.Utils.Units.InchesToDocumentsF(2.6f); tbl[0, 3].VerticalAlignment = TableCellVerticalAlignment.Center; tbl[0, 4].PreferredWidthType = WidthType.Fixed; tbl[0, 4].PreferredWidth = DevExpress.Office.Utils.Units.InchesToDocumentsF(0.5f); tbl[0, 4].VerticalAlignment = TableCellVerticalAlignment.Center; tbl[0, 5].PreferredWidthType = WidthType.Fixed; tbl[0, 5].PreferredWidth = DevExpress.Office.Utils.Units.InchesToDocumentsF(0.6f); tbl[0, 5].VerticalAlignment = TableCellVerticalAlignment.Center; tbl[0, 6].PreferredWidthType = WidthType.Fixed; tbl[0, 6].PreferredWidth = DevExpress.Office.Utils.Units.InchesToDocumentsF(0.3f); tbl[0, 6].VerticalAlignment = TableCellVerticalAlignment.Center; tbl[0, 7].PreferredWidthType = WidthType.Fixed; tbl[0, 7].PreferredWidth = DevExpress.Office.Utils.Units.InchesToDocumentsF(0.6f); tbl[0, 7].VerticalAlignment = TableCellVerticalAlignment.Center; tbl[0, 8].PreferredWidthType = WidthType.Fixed; tbl[0, 8].PreferredWidth = DevExpress.Office.Utils.Units.InchesToDocumentsF(0.4f); tbl[0, 8].VerticalAlignment = TableCellVerticalAlignment.Center; /* * //Apply formatting to the "Active Customers" cell * CharacterProperties properties = rec1.Document.BeginUpdateCharacters(tbl[0, 1].ContentRange); * properties.FontName = "Segoe UI"; * properties.FontSize = 16; * document.EndUpdateCharacters(properties); * ParagraphProperties alignment = document.BeginUpdateParagraphs(table[0, 1].ContentRange); * alignment.Alignment = ParagraphAlignment.Center; * document.EndUpdateParagraphs(alignment); * table[0, 1].VerticalAlignment = TableCellVerticalAlignment.Center; */ int wiersz = 0; DataTable dt_poz = ZamowieniaPozycje_DoWyslaniaOK(Zpn_id).Result; foreach (DataRow r_poz in dt_poz.Rows) { wiersz++; tbl.Rows.InsertAfter(wiersz - 1); tbl.Rows[wiersz].HeightType = HeightType.Auto; if (bool.TryParse(r_poz["Alert"].ToString(), out bool ale)) { if (ale) { doc.Images.Insert(tbl[wiersz, 1].Range.Start, DocumentImageSource.FromFile("alert.png")); } } else { ale = false; } doc.InsertSingleLineText(tbl[wiersz, 0].Range.Start, r_poz["Poz"].ToString()); doc.InsertSingleLineText(tbl[wiersz, 2].Range.Start, r_poz["Kod"].ToString()); doc.InsertSingleLineText(tbl[wiersz, 3].Range.Start, r_poz["Towar_MAG"].ToString()); doc.InsertSingleLineText(tbl[wiersz, 4].Range.Start, r_poz["Ilosc_szt"].ToString()); doc.InsertSingleLineText(tbl[wiersz, 5].Range.Start, r_poz["Ilosc_JM"].ToString()); doc.InsertSingleLineText(tbl[wiersz, 6].Range.Start, r_poz["JM"].ToString().ToUpper()); doc.InsertSingleLineText(tbl[wiersz, 7].Range.Start, r_poz["Cena_Netto"].ToString()); if (bool.TryParse(r_poz["Gratis"].ToString(), out bool gratt)) { } else { gratt = false; } if (bool.TryParse(r_poz["Promocja"].ToString(), out bool dol)) { } else { ale = false; } if (gratt || dol || r["Zpn_TYP_ZAM"].ToString() == "ZG") { doc.Images.Insert(tbl[wiersz, 8].Range.Start, DocumentImageSource.FromFile("gift.png")); } } //Apply formatting to the header cells CharacterProperties headerRowProperties = rec1.Document.BeginUpdateCharacters(tbl.Rows[0].Range); headerRowProperties.FontName = "Calibri"; headerRowProperties.FontSize = 10; headerRowProperties.Bold = true; //headerRowProperties.ForeColor = Color.FromArgb(212, 236, 183); rec1.Document.EndUpdateCharacters(headerRowProperties); ParagraphProperties headerRowParagraphProperties = rec1.Document.BeginUpdateParagraphs(tbl.Rows[0].Range); headerRowParagraphProperties.Alignment = ParagraphAlignment.Center; float f = 0.4f; headerRowParagraphProperties.LeftIndent = f; headerRowParagraphProperties.SpacingBefore = 2; headerRowParagraphProperties.SpacingAfter = 2; rec1.Document.EndUpdateParagraphs(headerRowParagraphProperties); //Apply formatting to Row cells if (tbl.Rows.Count > 1) { DocumentRange targetRange = rec1.Document.CreateRange(tbl[1, 0].Range.Start, tbl[tbl.Rows.Count - 1, 8].Range.End.ToInt()); ParagraphProperties RowParagraphProperties = rec1.Document.BeginUpdateParagraphs(targetRange); RowParagraphProperties.LeftIndent = DevExpress.Office.Utils.Units.InchesToDocumentsF(0.1f);; RowParagraphProperties.SpacingBefore = 8; RowParagraphProperties.SpacingAfter = 8; rec1.Document.EndUpdateParagraphs(RowParagraphProperties); CharacterProperties infoProperties = rec1.Document.BeginUpdateCharacters(targetRange); infoProperties.FontSize = 10; infoProperties.FontName = "Calibri"; rec1.Document.EndUpdateCharacters(infoProperties); } //Apply formatting to Number cells for (int i = 1; i < tbl.Rows.Count; i++) { ParagraphProperties RrParagraphProperties = rec1.Document.BeginUpdateParagraphs(tbl[i, 4].Range); RrParagraphProperties.Alignment = ParagraphAlignment.Right; rec1.Document.EndUpdateParagraphs(RrParagraphProperties); RrParagraphProperties = rec1.Document.BeginUpdateParagraphs(tbl[i, 5].Range); RrParagraphProperties.Alignment = ParagraphAlignment.Right; rec1.Document.EndUpdateParagraphs(RrParagraphProperties); RrParagraphProperties = rec1.Document.BeginUpdateParagraphs(tbl[i, 7].Range); RrParagraphProperties.Alignment = ParagraphAlignment.Right; rec1.Document.EndUpdateParagraphs(RrParagraphProperties); RrParagraphProperties = rec1.Document.BeginUpdateParagraphs(tbl[i, 0].Range); RrParagraphProperties.Alignment = ParagraphAlignment.Right; rec1.Document.EndUpdateParagraphs(RrParagraphProperties); } } finally { tbl.EndUpdate(); doc.BeginUpdate(); TableStyle tStyleMain = rec1.Document.TableStyles.CreateNew(); //Specify style options tStyleMain.TableBorders.InsideHorizontalBorder.LineStyle = TableBorderLineStyle.Single; tStyleMain.TableBorders.InsideHorizontalBorder.LineColor = Color.White; tStyleMain.TableBorders.InsideVerticalBorder.LineStyle = TableBorderLineStyle.Single; tStyleMain.TableBorders.InsideVerticalBorder.LineColor = Color.White; tStyleMain.CellBackgroundColor = Color.FromArgb(227, 238, 220); tStyleMain.Name = "MyTableStyle"; //Add the style to the document collection rec1.Document.TableStyles.Add(tStyleMain); //Create conditional styles (styles for specific table elements) TableConditionalStyle myNewStyleForOddRows = tStyleMain.ConditionalStyleProperties.CreateConditionalStyle(ConditionalTableStyleFormattingTypes.OddRowBanding); myNewStyleForOddRows.CellBackgroundColor = Color.FromArgb(196, 220, 182); TableConditionalStyle myNewStyleForBottomRightCell = tStyleMain.ConditionalStyleProperties.CreateConditionalStyle(ConditionalTableStyleFormattingTypes.BottomRightCell); myNewStyleForBottomRightCell.CellBackgroundColor = Color.FromArgb(188, 214, 201); doc.EndUpdate(); doc.BeginUpdate(); // Apply a previously defined style to the table tbl.Style = tStyleMain; doc.EndUpdate(); rec1.Document.ReplaceAll("<@TABELA>", "", SearchOptions.None); } } #endregion #region Wysyłanie Maila i update statusów if (r["prc_email"].ToString().Length > 0) { string Temat = "Nowe zamówienie producenckie."; try { MailMessage mailMessage = new MailMessage("*****@*****.**", r["prc_email"].ToString()); mailMessage.Subject = Temat; RichEditMailMessageExporter exporter = new RichEditMailMessageExporter(rec1, mailMessage); exporter.Export(); SmtpClient mailSender = new SmtpClient(); mailSender.Port = 587; mailSender.Host = "mag-ol.home.pl"; mailSender.Timeout = 10000; mailSender.DeliveryMethod = SmtpDeliveryMethod.Network; mailSender.UseDefaultCredentials = false; mailSender.Credentials = new NetworkCredential("*****@*****.**", "!Raporty123"); mailSender.EnableSsl = true; mailMessage.From = new MailAddress("*****@*****.**"); //specify your login/password to log on to the SMTP server, if required //mailSender.Credentials = new NetworkCredential("login", "password"); mailSender.Send(mailMessage); int.TryParse(r["Zpn_ID"].ToString(), out int id); if (id > 0) { SQL.UpdateDocumentMailStatus(id); } } catch (Exception exc) { MessageBox.Show(exc.Message); } } #endregion } }
private void RenderTableLayout(TableLayout table, Page page) { // Draw the table content first, before the borders, so that if any // row or cell has a background color then that color won't overwrite // the border. We don't do header rows in PDF because the // generator has already taken care of them and explicitly repeated rows // as necessary. foreach (TableRowLayout row in table.SubLayouts) { Render(row, page); } // Draw the table's borders TableStyle style = (TableStyle)table.Style; Border border = style.Border; if (border.Thickness > 0) { // Build a single path covering all borders, including the inner // cell borders List <List <Position> > lines = new List <List <Position> >(); // Draw the external border if ((border.Parts & BorderPart.Left) != BorderPart.None) { List <Position> line = new List <Position>(); lines.Add(line); line.Add(new Position(table.Bounds.Left, table.Bounds.Top)); line.Add(new Position(table.Bounds.Left, table.Bounds.Bottom)); } if ((border.Parts & BorderPart.Bottom) != BorderPart.None) { List <Position> line = new List <Position>(); lines.Add(line); line.Add(new Position(table.Bounds.Left, table.Bounds.Bottom)); line.Add(new Position(table.Bounds.Right, table.Bounds.Bottom)); } if ((border.Parts & BorderPart.Right) != BorderPart.None) { List <Position> line = new List <Position>(); lines.Add(line); line.Add(new Position(table.Bounds.Right, table.Bounds.Bottom)); line.Add(new Position(table.Bounds.Right, table.Bounds.Top)); } if ((border.Parts & BorderPart.Top) != BorderPart.None) { List <Position> line = new List <Position>(); lines.Add(line); line.Add(new Position(table.Bounds.Right, table.Bounds.Top)); line.Add(new Position(table.Bounds.Left, table.Bounds.Top)); } // If the border style includes inner horizontal then draw // a top border on all rows except the first if ((border.Parts & BorderPart.InnerHorizontal) != BorderPart.None) { bool firstRow = true; foreach (TableRowLayout row in table.SubLayouts) { if (firstRow) { firstRow = false; continue; } List <Position> line = new List <Position>(); lines.Add(line); line.Add(new Position(table.Bounds.Left, row.Bounds.Top)); line.Add(new Position(table.Bounds.Right, row.Bounds.Top)); } } // If the border style includes inner vertical then on every row - // including the first - draw a left border on every cell except the // first. We can't draw full column borders because a cell may span // more than one column, so we do a bit of fancy footwork. if ((border.Parts & BorderPart.InnerVertical) != BorderPart.None) { // Build a matrix representing the row/column grid, and then fill // it with bools indicating whether whether each cell of the grid // needs a left border. Where a table cell spans more than one // grid cell, the first spanned grid cell will have "true" and // the remaning grid cells in the span will have "false". bool[,] grid = new bool[table.NumSubLayouts, table.ColumnCount]; int rowIndex = 0; foreach (TableRowLayout row in table.SubLayouts) { int colIndex = 0; foreach (TableCellLayout cell in row.SubLayouts) { grid[rowIndex, colIndex] = true; colIndex += cell.ColumnSpan; } ++rowIndex; } // Plot the top-left corners of all grid cells. (Grid cells, not // table cells.) We'll also want the the bottom-left corners of // the cells on the bottom row. Position[,] points = new Position[table.NumSubLayouts + 1, table.ColumnCount]; rowIndex = 0; int firstLeft = table.Bounds.Left; int x = 0; int y = 0; foreach (TableRowLayout row in table.SubLayouts) { x = firstLeft; y = row.Bounds.Top; for (int colIndex = 0; colIndex < table.ColumnCount; ++colIndex) { points[rowIndex, colIndex] = new Position(x, y); x += table.ColumnWidths[colIndex]; } ++rowIndex; } // Add the bottom of the last row. In fact we want the bottom of the // table, because if the table has bottom padding then the bottom of // the last row will be higher than the bottom of the table. x = firstLeft; y = table.Bounds.Bottom; rowIndex = table.NumSubLayouts; for (int colIndex = 0; colIndex < table.ColumnCount; ++colIndex) { points[rowIndex, colIndex] = new Position(x, y); x += table.ColumnWidths[colIndex]; } // Correct the top row's points to allow for any top padding on // the table, which would have put the top of the first row lower // than the top of the table x = firstLeft; y = table.Bounds.Top; rowIndex = 0; for (int colIndex = 0; colIndex < table.ColumnCount; ++colIndex) { points[rowIndex, colIndex] = new Position(x, y); x += table.ColumnWidths[colIndex]; } // Draw the left-hand borders, skipping the first column because // that's been covered by the table's own external border. For // each column move down the rows: start at points[row,col] and // set a destination of points[row+1,col]. If the flag at the // corresponding grid[row,col] is set then we want a border there // so draw a line from the start to the destination, otherwise just // move to the destination without drawing. for (int colIndex = 1; colIndex < table.ColumnCount; ++colIndex) { for (rowIndex = 0; rowIndex < table.NumSubLayouts; ++rowIndex) { Position start = points[rowIndex, colIndex]; Position end = points[rowIndex + 1, colIndex]; bool flag = grid[rowIndex, colIndex]; if (flag) { List <Position> line = new List <Position>(); lines.Add(line); line.Add(start); line.Add(end); } start = end; } } } Demon.PDF.Color color = Convert.Color(border.Color); foreach (List <Position> line in lines) { page.AddPath(line, border.Thickness, color, null); } //TODO: draw all lines in a single PDF path? } }
public static async Task SingleImportTableStyleAsync(IDatabaseManager databaseManager, string tableName, string styleDirectoryPath, List <int> relatedIdentities) { if (!DirectoryUtils.IsDirectoryExists(styleDirectoryPath)) { return; } var relatedIdentity = relatedIdentities[0]; var filePaths = DirectoryUtils.GetFilePaths(styleDirectoryPath); foreach (var filePath in filePaths) { var feed = AtomFeed.Load(FileUtils.GetFileStreamReadOnly(filePath)); var attributeName = AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyle.AttributeName)); var taxis = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyle.Taxis))); var displayName = AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyle.DisplayName)); var helpText = AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyle.HelpText)); var list = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(feed.AdditionalElements, new List <string> { nameof(TableStyle.List), "VisibleInList" })); var inputType = TranslateUtils.ToEnum(AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyle.InputType)), InputType.Text); var defaultValue = AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyle.DefaultValue)); var isHorizontal = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableStyle.Horizontal))); var style = new TableStyle { Id = 0, RelatedIdentity = relatedIdentity, TableName = tableName, AttributeName = attributeName, Taxis = taxis, DisplayName = displayName, HelpText = helpText, List = list, InputType = inputType, DefaultValue = defaultValue, Horizontal = isHorizontal }; var json = AtomUtility.GetDcElementContent(feed.AdditionalElements, "ExtendValues"); if (!string.IsNullOrEmpty(json)) { var dict = ListUtils.ToDictionary(json); foreach (var o in dict) { style.Set(o.Key, o.Value); } } if (await databaseManager.TableStyleRepository.IsExistsAsync(relatedIdentity, tableName, attributeName)) { await databaseManager.TableStyleRepository.DeleteAsync(tableName, relatedIdentity, attributeName); } await databaseManager.TableStyleRepository.InsertAsync(relatedIdentities, style); } }
public Table(TableStyle tableStyle = null) : this(null, tableStyle) { }
private static async Task <AtomFeed> ExportTableStyleAsync(IDatabaseManager databaseManager, int siteId, TableStyle tableStyle) { var feed = AtomUtility.GetEmptyFeed(); AtomUtility.AddDcElement(feed.AdditionalElements, new List <string> { nameof(TableStyle.Id), "TableStyleID" }, tableStyle.Id.ToString()); AtomUtility.AddDcElement(feed.AdditionalElements, nameof(TableStyle.RelatedIdentity), tableStyle.RelatedIdentity.ToString()); AtomUtility.AddDcElement(feed.AdditionalElements, nameof(TableStyle.TableName), tableStyle.TableName); AtomUtility.AddDcElement(feed.AdditionalElements, nameof(TableStyle.AttributeName), tableStyle.AttributeName); AtomUtility.AddDcElement(feed.AdditionalElements, nameof(TableStyle.Taxis), tableStyle.Taxis.ToString()); AtomUtility.AddDcElement(feed.AdditionalElements, nameof(TableStyle.DisplayName), tableStyle.DisplayName); AtomUtility.AddDcElement(feed.AdditionalElements, nameof(TableStyle.HelpText), tableStyle.HelpText); AtomUtility.AddDcElement(feed.AdditionalElements, nameof(TableStyle.List), tableStyle.List.ToString()); AtomUtility.AddDcElement(feed.AdditionalElements, nameof(TableStyle.InputType), tableStyle.InputType.GetValue()); AtomUtility.AddDcElement(feed.AdditionalElements, nameof(TableStyle.DefaultValue), tableStyle.DefaultValue); AtomUtility.AddDcElement(feed.AdditionalElements, nameof(TableStyle.Horizontal), tableStyle.Horizontal.ToString()); AtomUtility.AddDcElement(feed.AdditionalElements, nameof(TableStyle.ItemValues), tableStyle.ItemValues); AtomUtility.AddDcElement(feed.AdditionalElements, nameof(TableStyle.RuleValues), tableStyle.RuleValues); //保存此栏目样式在系统中的排序号 var orderString = string.Empty; if (siteId > 0 && tableStyle.RelatedIdentity != 0) { orderString = await databaseManager.ChannelRepository.ImportGetOrderStringInSiteAsync(siteId, tableStyle.RelatedIdentity); } AtomUtility.AddDcElement(feed.AdditionalElements, "OrderString", orderString); return(feed); }
// Creates an Table instance and adds its children. public Table GenerateTable() { Table table1 = new Table(); TableProperties tableProperties1 = new TableProperties(); TableStyle tableStyle1 = new TableStyle() { Val = "TableGrid" }; TableWidth tableWidth1 = new TableWidth() { Width = "0", Type = TableWidthUnitValues.Auto }; TableLook tableLook1 = new TableLook() { Val = "04A0", FirstRow = true, LastRow = false, FirstColumn = true, LastColumn = false, NoHorizontalBand = false, NoVerticalBand = true }; tableProperties1.Append(tableStyle1); tableProperties1.Append(tableWidth1); tableProperties1.Append(tableLook1); TableGrid tableGrid1 = new TableGrid(); GridColumn gridColumn1 = new GridColumn() { Width = "2394" }; GridColumn gridColumn2 = new GridColumn() { Width = "2394" }; GridColumn gridColumn3 = new GridColumn() { Width = "2394" }; GridColumn gridColumn4 = new GridColumn() { Width = "2394" }; tableGrid1.Append(gridColumn1); tableGrid1.Append(gridColumn2); tableGrid1.Append(gridColumn3); tableGrid1.Append(gridColumn4); TableRow tableRow1 = new TableRow() { RsidTableRowAddition = "00607D74", RsidTableRowProperties = "0055020F", ParagraphId = "2D079EFF", TextId = "77777777" }; TableCell tableCell1 = new TableCell(); TableCellProperties tableCellProperties1 = new TableCellProperties(); TableCellWidth tableCellWidth1 = new TableCellWidth() { Width = "2394", Type = TableWidthUnitValues.Dxa }; Shading shading1 = new Shading() { Val = ShadingPatternValues.Clear, Color = "auto", Fill = "1F497D", ThemeFill = ThemeColorValues.Text2 }; tableCellProperties1.Append(tableCellWidth1); tableCellProperties1.Append(shading1); Paragraph paragraph1 = new Paragraph() { RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "6ED85602", TextId = "77777777" }; tableCell1.Append(tableCellProperties1); tableCell1.Append(paragraph1); TableCell tableCell2 = new TableCell(); TableCellProperties tableCellProperties2 = new TableCellProperties(); TableCellWidth tableCellWidth2 = new TableCellWidth() { Width = "2394", Type = TableWidthUnitValues.Dxa }; Shading shading2 = new Shading() { Val = ShadingPatternValues.Clear, Color = "auto", Fill = "1F497D", ThemeFill = ThemeColorValues.Text2 }; tableCellProperties2.Append(tableCellWidth2); tableCellProperties2.Append(shading2); Paragraph paragraph2 = new Paragraph() { RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "7C687A4B", TextId = "77777777" }; tableCell2.Append(tableCellProperties2); tableCell2.Append(paragraph2); TableCell tableCell3 = new TableCell(); TableCellProperties tableCellProperties3 = new TableCellProperties(); TableCellWidth tableCellWidth3 = new TableCellWidth() { Width = "2394", Type = TableWidthUnitValues.Dxa }; Shading shading3 = new Shading() { Val = ShadingPatternValues.Clear, Color = "auto", Fill = "1F497D", ThemeFill = ThemeColorValues.Text2 }; tableCellProperties3.Append(tableCellWidth3); tableCellProperties3.Append(shading3); Paragraph paragraph3 = new Paragraph() { RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "4F287AEB", TextId = "77777777" }; tableCell3.Append(tableCellProperties3); tableCell3.Append(paragraph3); TableCell tableCell4 = new TableCell(); TableCellProperties tableCellProperties4 = new TableCellProperties(); TableCellWidth tableCellWidth4 = new TableCellWidth() { Width = "2394", Type = TableWidthUnitValues.Dxa }; Shading shading4 = new Shading() { Val = ShadingPatternValues.Clear, Color = "auto", Fill = "1F497D", ThemeFill = ThemeColorValues.Text2 }; tableCellProperties4.Append(tableCellWidth4); tableCellProperties4.Append(shading4); Paragraph paragraph4 = new Paragraph() { RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "5F0063F5", TextId = "77777777" }; tableCell4.Append(tableCellProperties4); tableCell4.Append(paragraph4); tableRow1.Append(tableCell1); tableRow1.Append(tableCell2); tableRow1.Append(tableCell3); tableRow1.Append(tableCell4); TableRow tableRow2 = new TableRow() { RsidTableRowAddition = "00607D74", RsidTableRowProperties = "00607D74", ParagraphId = "2558F9F0", TextId = "77777777" }; TableCell tableCell5 = new TableCell(); TableCellProperties tableCellProperties5 = new TableCellProperties(); TableCellWidth tableCellWidth5 = new TableCellWidth() { Width = "2394", Type = TableWidthUnitValues.Dxa }; tableCellProperties5.Append(tableCellWidth5); Paragraph paragraph5 = new Paragraph() { RsidParagraphMarkRevision = "0055020F", RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "186B732E", TextId = "77777777" }; ParagraphProperties paragraphProperties1 = new ParagraphProperties(); ParagraphMarkRunProperties paragraphMarkRunProperties1 = new ParagraphMarkRunProperties(); Bold bold1 = new Bold(); paragraphMarkRunProperties1.Append(bold1); paragraphProperties1.Append(paragraphMarkRunProperties1); paragraph5.Append(paragraphProperties1); tableCell5.Append(tableCellProperties5); tableCell5.Append(paragraph5); TableCell tableCell6 = new TableCell(); TableCellProperties tableCellProperties6 = new TableCellProperties(); TableCellWidth tableCellWidth6 = new TableCellWidth() { Width = "2394", Type = TableWidthUnitValues.Dxa }; tableCellProperties6.Append(tableCellWidth6); Paragraph paragraph6 = new Paragraph() { RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "6D2E7DAE", TextId = "77777777" }; tableCell6.Append(tableCellProperties6); tableCell6.Append(paragraph6); TableCell tableCell7 = new TableCell(); TableCellProperties tableCellProperties7 = new TableCellProperties(); TableCellWidth tableCellWidth7 = new TableCellWidth() { Width = "2394", Type = TableWidthUnitValues.Dxa }; tableCellProperties7.Append(tableCellWidth7); Paragraph paragraph7 = new Paragraph() { RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "2B98717A", TextId = "77777777" }; tableCell7.Append(tableCellProperties7); tableCell7.Append(paragraph7); TableCell tableCell8 = new TableCell(); TableCellProperties tableCellProperties8 = new TableCellProperties(); TableCellWidth tableCellWidth8 = new TableCellWidth() { Width = "2394", Type = TableWidthUnitValues.Dxa }; tableCellProperties8.Append(tableCellWidth8); Paragraph paragraph8 = new Paragraph() { RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "12461324", TextId = "77777777" }; tableCell8.Append(tableCellProperties8); tableCell8.Append(paragraph8); tableRow2.Append(tableCell5); tableRow2.Append(tableCell6); tableRow2.Append(tableCell7); tableRow2.Append(tableCell8); TableRow tableRow3 = new TableRow() { RsidTableRowAddition = "00607D74", RsidTableRowProperties = "00607D74", ParagraphId = "56FE196D", TextId = "77777777" }; TableCell tableCell9 = new TableCell(); TableCellProperties tableCellProperties9 = new TableCellProperties(); TableCellWidth tableCellWidth9 = new TableCellWidth() { Width = "2394", Type = TableWidthUnitValues.Dxa }; tableCellProperties9.Append(tableCellWidth9); Paragraph paragraph9 = new Paragraph() { RsidParagraphMarkRevision = "0055020F", RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "617925F5", TextId = "77777777" }; ParagraphProperties paragraphProperties2 = new ParagraphProperties(); ParagraphMarkRunProperties paragraphMarkRunProperties2 = new ParagraphMarkRunProperties(); Color color1 = new Color() { Val = "FF0000" }; paragraphMarkRunProperties2.Append(color1); paragraphProperties2.Append(paragraphMarkRunProperties2); BookmarkStart bookmarkStart1 = new BookmarkStart() { Name = "_GoBack", Id = "0" }; BookmarkEnd bookmarkEnd1 = new BookmarkEnd() { Id = "0" }; paragraph9.Append(paragraphProperties2); paragraph9.Append(bookmarkStart1); paragraph9.Append(bookmarkEnd1); tableCell9.Append(tableCellProperties9); tableCell9.Append(paragraph9); TableCell tableCell10 = new TableCell(); TableCellProperties tableCellProperties10 = new TableCellProperties(); TableCellWidth tableCellWidth10 = new TableCellWidth() { Width = "2394", Type = TableWidthUnitValues.Dxa }; tableCellProperties10.Append(tableCellWidth10); Paragraph paragraph10 = new Paragraph() { RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "7FB20390", TextId = "77777777" }; tableCell10.Append(tableCellProperties10); tableCell10.Append(paragraph10); TableCell tableCell11 = new TableCell(); TableCellProperties tableCellProperties11 = new TableCellProperties(); TableCellWidth tableCellWidth11 = new TableCellWidth() { Width = "2394", Type = TableWidthUnitValues.Dxa }; tableCellProperties11.Append(tableCellWidth11); Paragraph paragraph11 = new Paragraph() { RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "6B3FAA2A", TextId = "77777777" }; tableCell11.Append(tableCellProperties11); tableCell11.Append(paragraph11); TableCell tableCell12 = new TableCell(); TableCellProperties tableCellProperties12 = new TableCellProperties(); TableCellWidth tableCellWidth12 = new TableCellWidth() { Width = "2394", Type = TableWidthUnitValues.Dxa }; tableCellProperties12.Append(tableCellWidth12); Paragraph paragraph12 = new Paragraph() { RsidParagraphAddition = "00607D74", RsidRunAdditionDefault = "00607D74", ParagraphId = "046FFB08", TextId = "77777777" }; tableCell12.Append(tableCellProperties12); tableCell12.Append(paragraph12); tableRow3.Append(tableCell9); tableRow3.Append(tableCell10); tableRow3.Append(tableCell11); tableRow3.Append(tableCell12); table1.Append(tableProperties1); table1.Append(tableGrid1); table1.Append(tableRow1); table1.Append(tableRow2); table1.Append(tableRow3); return(table1); }
public async Task <string> GetContentByTableStyleAsync(Content content, string separator, Site site, TableStyle style, string formatString, int no, NameValueCollection attributes, string innerHtml, bool isStlEntity) { var obj = content.Get(style.AttributeName); if (obj == null) { return(string.Empty); } var parsedContent = string.Empty; var inputType = style.InputType; if (inputType == InputType.Date) { var dateTime = TranslateUtils.ToDateTime(obj.ToString()); if (dateTime != Constants.SqlMinValue) { if (string.IsNullOrEmpty(formatString)) { formatString = DateUtils.FormatStringDateOnly; } parsedContent = DateUtils.Format(dateTime, formatString); } } else if (inputType == InputType.DateTime) { var dateTime = TranslateUtils.ToDateTime(obj.ToString()); if (dateTime != Constants.SqlMinValue) { if (string.IsNullOrEmpty(formatString)) { formatString = DateUtils.FormatStringDateTime; } parsedContent = DateUtils.Format(dateTime, formatString); } } else if (inputType == InputType.CheckBox || inputType == InputType.Radio || inputType == InputType.SelectMultiple || inputType == InputType.SelectOne)//选择类型 { var selectedTexts = new List <string>(); var selectedValues = ListUtils.ToList(obj); var styleItems = style.Items; if (styleItems != null) { foreach (var itemInfo in styleItems) { if (selectedValues.Contains(itemInfo.Value)) { selectedTexts.Add(isStlEntity ? itemInfo.Value : itemInfo.Label); } } } parsedContent = separator == null?ListUtils.ToString(selectedTexts) : ListUtils.ToString(selectedTexts, separator); } else if (inputType == InputType.TextEditor) { parsedContent = await _pathManager.DecodeTextEditorAsync(site, obj.ToString(), true); } else if (inputType == InputType.Image) { if (no <= 1) { parsedContent = await GetImageOrFlashHtmlAsync(site, obj.ToString(), attributes, isStlEntity); } else { var extendName = ColumnsManager.GetExtendName(style.AttributeName, no - 1); var extend = content.Get <string>(extendName); parsedContent = await GetImageOrFlashHtmlAsync(site, extend, attributes, isStlEntity); } } else if (inputType == InputType.Video) { if (no <= 1) { parsedContent = await GetVideoHtmlAsync(site, obj.ToString(), attributes, isStlEntity); } else { var extendName = ColumnsManager.GetExtendName(style.AttributeName, no - 1); var extend = content.Get <string>(extendName); parsedContent = await GetVideoHtmlAsync(site, extend, attributes, isStlEntity); } } else if (inputType == InputType.File) { if (no <= 1) { parsedContent = GetFileHtmlWithoutCount(site, obj.ToString(), attributes, innerHtml, isStlEntity, false, false); } else { var extendName = ColumnsManager.GetExtendName(style.AttributeName, no - 1); var extend = content.Get <string>(extendName); parsedContent = GetFileHtmlWithoutCount(site, extend, attributes, innerHtml, isStlEntity, false, false); } } else { parsedContent = obj.ToString(); } return(parsedContent); }
public void TableBorder() { using (MemoryStream mem = new MemoryStream()) { WordDocument doc = new WordDocument(mem); doc.Process(new HtmlParser("<table border='1'><tr><td>test</td></tr></table>")); Assert.IsNotNull(doc.Document.Body); Assert.AreEqual(1, doc.Document.Body.ChildElements.Count); Word.Table table = doc.Document.Body.ChildElements[0] as Word.Table; Assert.IsNotNull(table); Assert.AreEqual(3, table.ChildElements.Count); TableProperties tableProperties = table.ChildElements[0] as TableProperties; Assert.IsNotNull(tableProperties); TableStyle tableStyle = tableProperties.ChildElements[0] as TableStyle; Assert.IsNotNull(tableStyle); Assert.AreEqual("TableGrid", tableStyle.Val.Value); TableBorders tableBorders = tableProperties.ChildElements[1] as TableBorders; Assert.IsNotNull(tableBorders); Assert.AreEqual(4, tableBorders.ChildElements.Count); TopBorder topBorder = tableBorders.ChildElements[0] as TopBorder; Assert.IsNotNull(topBorder); TestUtility.TestBorder <TopBorder>(topBorder, BorderValues.Single, "auto", 4U); LeftBorder leftBorder = tableBorders.ChildElements[1] as LeftBorder; Assert.IsNotNull(leftBorder); TestUtility.TestBorder <LeftBorder>(leftBorder, BorderValues.Single, "auto", 4U); BottomBorder bottomBorder = tableBorders.ChildElements[2] as BottomBorder; Assert.IsNotNull(bottomBorder); TestUtility.TestBorder <BottomBorder>(bottomBorder, BorderValues.Single, "auto", 4U); RightBorder rightBorder = tableBorders.ChildElements[3] as RightBorder; Assert.IsNotNull(rightBorder); TestUtility.TestBorder <RightBorder>(rightBorder, BorderValues.Single, "auto", 4U); TableRow row = table.ChildElements[2] as TableRow; Assert.IsNotNull(row); Assert.AreEqual(1, row.ChildElements.Count); TableCell cell = row.ChildElements[0] as TableCell; Assert.IsNotNull(cell); Assert.AreEqual(2, cell.ChildElements.Count); TableCellProperties cellProperties = cell.ChildElements[0] as TableCellProperties; Assert.IsNotNull(cellProperties); Assert.AreEqual(1, cellProperties.ChildElements.Count); TableCellBorders cellBorders = cellProperties.ChildElements[0] as TableCellBorders; Assert.IsNotNull(cellBorders); Assert.AreEqual(4, cellBorders.ChildElements.Count); topBorder = cellBorders.ChildElements[0] as TopBorder; Assert.IsNotNull(topBorder); TestUtility.TestBorder <TopBorder>(topBorder, BorderValues.Single, "auto", 4U); leftBorder = cellBorders.ChildElements[1] as LeftBorder; Assert.IsNotNull(leftBorder); TestUtility.TestBorder <LeftBorder>(leftBorder, BorderValues.Single, "auto", 4U); bottomBorder = cellBorders.ChildElements[2] as BottomBorder; Assert.IsNotNull(bottomBorder); TestUtility.TestBorder <BottomBorder>(bottomBorder, BorderValues.Single, "auto", 4U); rightBorder = cellBorders.ChildElements[3] as RightBorder; Assert.IsNotNull(rightBorder); TestUtility.TestBorder <RightBorder>(rightBorder, BorderValues.Single, "auto", 4U); Paragraph para = cell.ChildElements[1] as Paragraph; Assert.IsNotNull(para); Assert.AreEqual(1, para.ChildElements.Count); Run run = para.ChildElements[0] as Run; Assert.IsNotNull(run); Assert.AreEqual(1, run.ChildElements.Count); Word.Text text = run.ChildElements[0] as Word.Text; Assert.IsNotNull(text); Assert.AreEqual(0, text.ChildElements.Count); Assert.AreEqual("test", text.InnerText); OpenXmlValidator validator = new OpenXmlValidator(); var errors = validator.Validate(doc.WordprocessingDocument); Assert.AreEqual(0, errors.Count()); } }
// Create a new test with the given table style and object count. public TestSet(TableStyle ts, int count) { // Use one random number generator for the life of the test. Could support explicit seeds for // reproducible tests here. m_rng = new Random(); // Remember our parameters. m_count = count; m_style = ts; // Various arrays. m_nodes = new Node[count]; // The array of objects m_collected = new bool[count]; // Records whether each object has been collected (entries are set by // the finalizer on Node) m_marks = new bool[count]; // Array used during individual test runs to calculate whether each // object should still be alive (allocated once here to avoid // injecting further garbage collections at run time) // Allocate each object (Node). Each knows its own unique ID (the index into the node array) and has a // back pointer to this test object (so it can phone home to report its own collection at finalization // time). for (int i = 0; i < count; i++) m_nodes[i] = new Node(this, i); // Determine how many handles we need to allocate given the number of nodes. This varies based on the // table style. switch (ts) { case TableStyle.Unconnected: // Primaries and secondaries are completely different objects so we split our nodes in half and // allocate that many handles. m_handleCount = count / 2; break; case TableStyle.ForwardLinked: // Nodes are primaries in one handle and secondary in another except one that falls off the end. // So we have as many handles as nodes - 1. m_handleCount = count - 1; break; case TableStyle.BackwardLinked: // Nodes are primaries in one handle and secondary in another except one that falls off the end. // So we have as many handles as nodes - 1. m_handleCount = count - 1; break; case TableStyle.Random: // Each node is a primary in some handle (secondaries are selected from amongst all the same nodes // randomly). So we have as many nodes as handles. m_handleCount = count; break; } // Allocate an array of HandleSpecs. These aren't the real handles, just structures that allow us // remember what's in each handle (in terms of the node index number for the primary and secondary). // We need to track this information separately because we can't access the real handles directly // (ConditionalWeakTable hides them) and we need to recall exactly what the primary and secondary of // each handle is so we can compute our own notion of object liveness later. m_handles = new HandleSpec[m_handleCount]; // Initialize the handle specs to assign objects to handles based on the table style. for (int i = 0; i < m_handleCount; i++) { int primary = -1, secondary = -1; switch (ts) { case TableStyle.Unconnected: // Assign adjacent nodes to the primary and secondary of each handle. primary = i * 2; secondary = (i * 2) + 1; break; case TableStyle.ForwardLinked: // Primary of each handle is the secondary of the last handle. primary = i; secondary = i + 1; break; case TableStyle.BackwardLinked: // Primary of each handle is the secondary of the next handle. primary = i + 1; secondary = i; break; case TableStyle.Random: // Primary is each node in sequence, secondary is any of the nodes randomly. primary = i; secondary = m_rng.Next(m_handleCount); break; } m_handles[i].Set(primary, secondary); } // Allocate a ConditionalWeakTable mapping Node keys to Node values. m_table = new ConditionalWeakTable<Node, Node>(); // Using our handle specs computed above add each primary/secondary node pair to the // ConditionalWeakTable in turn. This causes the ConditionalWeakTable to allocate a dependent handle // for each entry with the primary and secondary objects we specified as keys and values (note that // this scheme prevents us from creating multiple handles with the same primary though if this is // desired we could achieve it by allocating multiple ConditionalWeakTables). for (int i = 0; i < m_handleCount; i++) m_table.Add(m_nodes[m_handles[i].m_primary], m_nodes[m_handles[i].m_secondary]); }
Table GenerateBasiceReportDataTable() { Table table1 = new Table(); // Li Zheng 2010.11.21 线框 BorderValues bv = BorderValues.Single; TableBorders tblBorders = new TableBorders(); tblBorders.TopBorder = new DocumentFormat.OpenXml.Wordprocessing.TopBorder(); tblBorders.TopBorder.Val = new EnumValue<BorderValues>(bv); tblBorders.BottomBorder = new DocumentFormat.OpenXml.Wordprocessing.BottomBorder(); tblBorders.BottomBorder.Val = new EnumValue<BorderValues>(bv); tblBorders.LeftBorder = new DocumentFormat.OpenXml.Wordprocessing.LeftBorder(); tblBorders.LeftBorder.Val = new EnumValue<BorderValues>(bv); tblBorders.RightBorder = new DocumentFormat.OpenXml.Wordprocessing.RightBorder(); tblBorders.RightBorder.Val = new EnumValue<BorderValues>(bv); tblBorders.InsideHorizontalBorder = new DocumentFormat.OpenXml.Wordprocessing.InsideHorizontalBorder(); tblBorders.InsideHorizontalBorder.Val = bv; tblBorders.InsideVerticalBorder = new DocumentFormat.OpenXml.Wordprocessing.InsideVerticalBorder(); tblBorders.InsideVerticalBorder.Val = bv; //WordWrap ww = new WordWrap(); //ww.Val=true; TableProperties tableProperties1 = new TableProperties(); TableStyle tableStyle1 = new TableStyle() { Val = "TableGrid" }; TableWidth tableWidth1 = new TableWidth() { Width = "16100", Type = TableWidthUnitValues.Dxa }; TableIndentation tableIndentation1 = new TableIndentation() { Width = 30, Type = TableWidthUnitValues.Dxa }; TableLook tableLook1 = new TableLook() { Val = "04A0", FirstRow = true, LastRow = false, FirstColumn = true, LastColumn = false, NoHorizontalBand = false, NoVerticalBand = true }; tableProperties1.Append(tableStyle1); tableProperties1.Append(tableWidth1); tableProperties1.Append(tableIndentation1); tableProperties1.Append(tableLook1); TableGrid tableGrid1 = new TableGrid(); GridColumn gridColumn1 = new GridColumn() { Width = "16100" }; tableGrid1.Append(gridColumn1); TableRow tableRow1 = new TableRow() { RsidTableRowAddition = "000063AD", RsidTableRowProperties = "000E6055" }; TableCell tableCell1 = new TableCell(); TableCellProperties tableCellProperties1 = new TableCellProperties(); TableCellWidth tableCellWidth1 = new TableCellWidth() { Width = "16100", Type = TableWidthUnitValues.Dxa }; TableCellVerticalAlignment tableCellVerticalAlignment1 = new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center }; tableCellProperties1.Append(tableCellWidth1); tableCellProperties1.Append(tableCellVerticalAlignment1); Paragraph paragraph1 = new Paragraph() { RsidParagraphAddition = "000063AD", RsidRunAdditionDefault = "000063AD" }; ParagraphProperties paragraphProperties1 = new ParagraphProperties(); Justification justification1 = new Justification() { Val = JustificationValues.Center }; paragraphProperties1.Append(justification1); BookmarkStart bookmarkStart1 = new BookmarkStart() { Name = "_GoBack", Id = "0" }; BookmarkEnd bookmarkEnd1 = new BookmarkEnd() { Id = "0" }; paragraph1.Append(paragraphProperties1); paragraph1.Append(bookmarkStart1); paragraph1.Append(bookmarkEnd1); tableCell1.Append(tableCellProperties1); tableCell1.Append(paragraph1); tableRow1.Append(tableCell1); table1.Append(tableProperties1); table1.Append(tableGrid1); table1.Append(tableRow1); //table1.Append(ww); return table1; }
public void ThWithSpanAndDiv() { using MemoryStream mem = new MemoryStream(); WordDocument doc = new WordDocument(mem); doc.Process(new HtmlParser("<table><tr><th><span>one</span><div>two</div></th></tr></table>")); Assert.IsNotNull(doc.Document.Body); Assert.AreEqual(1, doc.Document.Body.ChildElements.Count); Word.Table table = doc.Document.Body.ChildElements[0] as Word.Table; Assert.IsNotNull(table); Assert.AreEqual(3, table.ChildElements.Count); TableProperties tableProperties = table.ChildElements[0] as TableProperties; Assert.IsNotNull(tableProperties); TableStyle tableStyle = tableProperties.ChildElements[0] as TableStyle; Assert.IsNotNull(tableStyle); Assert.AreEqual("TableGrid", tableStyle.Val.Value); TableGrid tableGrid = table.ChildElements[1] as TableGrid; Assert.IsNotNull(tableGrid); Assert.AreEqual(1, tableGrid.ChildElements.Count); TableRow row = table.ChildElements[2] as TableRow; Assert.IsNotNull(row); Assert.AreEqual(1, row.ChildElements.Count); TableCell cell = row.ChildElements[0] as TableCell; Assert.IsNotNull(cell); Assert.AreEqual(2, cell.ChildElements.Count); Paragraph para = cell.ChildElements[0] as Paragraph; Assert.IsNotNull(para); Assert.AreEqual(1, para.ChildElements.Count); Run run = para.ChildElements[0] as Run; Assert.IsNotNull(run); Assert.AreEqual(2, run.ChildElements.Count); Assert.IsNotNull(run.RunProperties); Bold bold = run.RunProperties.ChildElements[0] as Bold; Assert.IsNotNull(bold); Word.Text text = run.ChildElements[1] as Word.Text; Assert.IsNotNull(text); Assert.AreEqual(0, text.ChildElements.Count); Assert.AreEqual("one", text.InnerText); para = cell.ChildElements[1] as Paragraph; Assert.IsNotNull(para); Assert.AreEqual(1, para.ChildElements.Count); run = para.ChildElements[0] as Run; Assert.IsNotNull(run); Assert.AreEqual(2, run.ChildElements.Count); Assert.IsNotNull(run.RunProperties); bold = run.RunProperties.ChildElements[0] as Bold; Assert.IsNotNull(bold); text = run.ChildElements[1] as Word.Text; Assert.IsNotNull(text); Assert.AreEqual(0, text.ChildElements.Count); Assert.AreEqual("two", text.InnerText); OpenXmlValidator validator = new OpenXmlValidator(); var errors = validator.Validate(doc.WordprocessingDocument); Assert.AreEqual(0, errors.Count()); }
private void CreateTableStyle(string tableStyleName, string textStyleName, LineWeight lineWeight, out ObjectId tsObjID) { using (Transaction tr = m_db.TransactionManager.StartTransaction()) { tsObjID = ObjectId.Null; DBDictionary dbDic = tr.GetObject(m_db.TableStyleDictionaryId, OpenMode.ForRead) as DBDictionary; if (dbDic.Contains(tableStyleName)) { tsObjID = dbDic.GetAt(tableStyleName); } else { TableStyle newTs = new TableStyle(); TextStyleTable test = tr.GetObject(m_db.TextStyleTableId, OpenMode.ForRead) as TextStyleTable; //if (test.Has(textStyleName)) //newTs.SetTextStyle(m_db.TextStyleTableId, textStyleName); newTs.SetGridLineWeight(lineWeight, (int)GridLineType.AllGridLines, (int)GridLineType.AllGridLines); tsObjID = newTs.PostTableStyleToDatabase(m_db, tableStyleName); tr.AddNewlyCreatedDBObject(newTs, true); } tr.Commit(); } }
private Table GenerateBasiceReportDataTable() { Table table1 = new Table(); TableProperties tableProperties1 = new TableProperties(); TableStyle tableStyle1 = new TableStyle() { Val = "TableGrid" }; TablePositionProperties tablePositionProperties1 = new TablePositionProperties() { LeftFromText = 180, RightFromText = 180, VerticalAnchor = VerticalAnchorValues.Text, HorizontalAnchor = HorizontalAnchorValues.Margin, TablePositionXAlignment = HorizontalAlignmentValues.Center, TablePositionY = 103 }; TableWidth tableWidth1 = new TableWidth() { Width = "15026", Type = TableWidthUnitValues.Dxa }; TableLook tableLook1 = new TableLook() { Val = "04A0", FirstRow = true, LastRow = false, FirstColumn = true, LastColumn = false, NoHorizontalBand = false, NoVerticalBand = true }; tableProperties1.Append(tableStyle1); tableProperties1.Append(tablePositionProperties1); tableProperties1.Append(tableWidth1); tableProperties1.Append(tableLook1); TableGrid tableGrid1 = new TableGrid(); GridColumn gridColumn1 = new GridColumn() { Width = "15026" }; tableGrid1.Append(gridColumn1); TableRow tableRow1 = new TableRow() { RsidTableRowAddition = "004E307B", RsidTableRowProperties = "00D273DB" }; TableCell tableCell1 = new TableCell(); TableCellProperties tableCellProperties1 = new TableCellProperties(); TableCellWidth tableCellWidth1 = new TableCellWidth() { Width = "15026", Type = TableWidthUnitValues.Dxa }; tableCellProperties1.Append(tableCellWidth1); Paragraph paragraph1 = new Paragraph() { RsidParagraphMarkRevision = "004E307B", RsidParagraphAddition = "004E307B", RsidParagraphProperties = "004E307B", RsidRunAdditionDefault = "004E307B" }; ParagraphProperties paragraphProperties1 = new ParagraphProperties(); Justification justification1 = new Justification() { Val = JustificationValues.Center }; paragraphProperties1.Append(justification1); paragraph1.Append(paragraphProperties1); tableCell1.Append(tableCellProperties1); tableCell1.Append(paragraph1); tableRow1.Append(tableCell1); table1.Append(tableProperties1); table1.Append(tableGrid1); table1.Append(tableRow1); return table1; }
//[LoginFilter(Order = 0)] //[SecurityFilter(Order = 1)] private Table GenerateBasiceReportDataTable() { Table table1 = new Table(); // Li Zheng 2010.11.21 线框 BorderValues bv = BorderValues.Single; TableBorders tblBorders = new TableBorders(); tblBorders.TopBorder = new DocumentFormat.OpenXml.Wordprocessing.TopBorder(); tblBorders.TopBorder.Val = new EnumValue<BorderValues>(bv); tblBorders.BottomBorder = new DocumentFormat.OpenXml.Wordprocessing.BottomBorder(); tblBorders.BottomBorder.Val = new EnumValue<BorderValues>(bv); tblBorders.LeftBorder = new DocumentFormat.OpenXml.Wordprocessing.LeftBorder(); tblBorders.LeftBorder.Val = new EnumValue<BorderValues>(bv); tblBorders.RightBorder = new DocumentFormat.OpenXml.Wordprocessing.RightBorder(); tblBorders.RightBorder.Val = new EnumValue<BorderValues>(bv); tblBorders.InsideHorizontalBorder = new DocumentFormat.OpenXml.Wordprocessing.InsideHorizontalBorder(); tblBorders.InsideHorizontalBorder.Val = bv; tblBorders.InsideVerticalBorder = new DocumentFormat.OpenXml.Wordprocessing.InsideVerticalBorder(); tblBorders.InsideVerticalBorder.Val = bv; TableProperties tableProperties1 = new TableProperties(); TableStyle tableStyle1 = new TableStyle() { Val = "TableGrid", }; TableWidth tableWidth1 = new TableWidth() { Width = "11157", Type = TableWidthUnitValues.Dxa };//表格宽度 TableIndentation tableIndentation1 = new TableIndentation() { Width = 0, Type = TableWidthUnitValues.Dxa };//首字缩进 TableLook tableLook1 = new TableLook() { Val = "04A0", FirstRow = true, LastRow = false, FirstColumn = true, LastColumn = false, NoHorizontalBand = false, NoVerticalBand = true }; tableProperties1.Append(tblBorders); tableProperties1.Append(tableStyle1); tableProperties1.Append(tableWidth1); tableProperties1.Append(tableIndentation1); tableProperties1.Append(tableLook1); TableGrid tableGrid1 = new TableGrid(); GridColumn gridColumn1 = new GridColumn() { Width = "11157" }; tableGrid1.Append(gridColumn1); TableRow tableRow1 = new TableRow() { RsidTableRowMarkRevision = "00E77591", RsidTableRowAddition = "00E77591", RsidTableRowProperties = "00E77591" }; TableCell tableCell1 = new TableCell(); TableCellProperties tableCellProperties1 = new TableCellProperties(); TableCellWidth tableCellWidth1 = new TableCellWidth() { Width = "11157", Type = TableWidthUnitValues.Dxa }; TableCellVerticalAlignment tableCellVerticalAlignment1 = new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center }; tableCellProperties1.Append(tableCellWidth1); tableCellProperties1.Append(tableCellVerticalAlignment1); Paragraph paragraph1 = new Paragraph() { RsidParagraphAddition = "005D4399", RsidParagraphProperties = "001D44EB", RsidRunAdditionDefault = "005D4399" }; ParagraphProperties paragraphProperties1 = new ParagraphProperties(); Justification justification1 = new Justification() { Val = JustificationValues.Center }; ParagraphMarkRunProperties paragraphMarkRunProperties1 = new ParagraphMarkRunProperties(); RunFonts runFonts1 = new RunFonts() { AsciiTheme = ThemeFontValues.MinorEastAsia, HighAnsiTheme = ThemeFontValues.MinorEastAsia, EastAsiaTheme = ThemeFontValues.MinorEastAsia }; paragraphMarkRunProperties1.Append(runFonts1); paragraphMarkRunProperties1.Append(); paragraphProperties1.Append(justification1); paragraphProperties1.Append(paragraphMarkRunProperties1); BookmarkStart bookmarkStart1 = new BookmarkStart() { Name = "_GoBack", Id = "0" }; paragraph1.Append(paragraphProperties1); paragraph1.Append(bookmarkStart1); tableCell1.Append(tableCellProperties1); tableCell1.Append(paragraph1); tableRow1.Append(tableCell1); BookmarkEnd bookmarkEnd1 = new BookmarkEnd() { Id = "0" }; table1.Append(tableProperties1); table1.Append(tableGrid1); table1.Append(tableRow1); table1.Append(bookmarkEnd1); return table1; }
private Table CreateFilledTable(bool hasBorder, bool hasInsideBorder) { //枠線有りテーブルを生成する(幅はページの幅) Table table = new Table(); TableProperties tableProperties = new TableProperties(); TableStyle tableStyle = new TableStyle() { Val = "TableGrid" }; TableWidth tableWidth = new TableWidth() { Width = "5000", Type = TableWidthUnitValues.Pct }; TableLook tableLook = new TableLook() { Val = "04A0", FirstRow = true, LastRow = false, FirstColumn = true, LastColumn = false, NoHorizontalBand = false, NoVerticalBand = true }; tableProperties.Append(tableStyle); tableProperties.Append(tableWidth); tableProperties.Append(tableLook); TableBorders borders = new TableBorders(); tableProperties.Append(borders); EnumValue<BorderValues> val = hasBorder ? BorderValues.Single : BorderValues.Nil; TopBorder topBorder = new TopBorder() { Val = val }; BottomBorder bottomBorder = new BottomBorder() { Val = val }; LeftBorder leftBorder = new LeftBorder() { Val = val }; RightBorder rightBorder = new RightBorder() { Val = val }; borders.Append(topBorder); borders.Append(bottomBorder); borders.Append(leftBorder); borders.Append(rightBorder); val = hasInsideBorder ? BorderValues.Single : BorderValues.Nil; InsideHorizontalBorder horizontalBorder = new InsideHorizontalBorder() { Val = val }; InsideVerticalBorder verticalBorder = new InsideVerticalBorder() { Val = val }; borders.Append(horizontalBorder); borders.Append(verticalBorder); table.Append(tableProperties); return table; }
private TableStyle GetDefaultContentTableStyle(string tableName, string attributeName) { var style = new TableStyle { Id = 0, RelatedIdentity = 0, TableName = tableName, AttributeName = attributeName, Taxis = 0, DisplayName = string.Empty, HelpText = string.Empty, List = false, InputType = InputType.Text, DefaultValue = string.Empty, Horizontal = true }; if (StringUtils.EqualsIgnoreCase(attributeName, nameof(Content.Title))) { style.AttributeName = nameof(Content.Title); style.DisplayName = "标题"; style.RuleValues = TranslateUtils.JsonSerialize(new List <InputStyleRule> { new InputStyleRule { Type = ValidateType.Required, Message = "标题为必填项" } }); style.Taxis = 1; } else if (StringUtils.EqualsIgnoreCase(attributeName, nameof(Content.SubTitle))) { style.AttributeName = nameof(Content.SubTitle); style.DisplayName = "副标题"; style.Taxis = 2; } else if (StringUtils.EqualsIgnoreCase(attributeName, nameof(Content.ImageUrl))) { style.AttributeName = nameof(Content.ImageUrl); style.DisplayName = "图片"; style.InputType = InputType.Image; style.Taxis = 3; } else if (StringUtils.EqualsIgnoreCase(attributeName, nameof(Content.VideoUrl))) { style.AttributeName = nameof(Content.VideoUrl); style.DisplayName = "视频"; style.InputType = InputType.Video; style.Taxis = 4; } else if (StringUtils.EqualsIgnoreCase(attributeName, nameof(Content.FileUrl))) { style.AttributeName = nameof(Content.FileUrl); style.DisplayName = "附件"; style.InputType = InputType.File; style.Taxis = 5; } else if (StringUtils.EqualsIgnoreCase(attributeName, nameof(Content.Body))) { style.AttributeName = nameof(Content.Body); style.DisplayName = "内容"; style.InputType = InputType.TextEditor; style.Taxis = 6; } else if (StringUtils.EqualsIgnoreCase(attributeName, nameof(Content.Summary))) { style.AttributeName = nameof(Content.Summary); style.DisplayName = "内容摘要"; style.InputType = InputType.TextArea; style.Taxis = 7; } else if (StringUtils.EqualsIgnoreCase(attributeName, nameof(Content.Author))) { style.AttributeName = nameof(Content.Author); style.DisplayName = "作者"; style.Taxis = 8; } else if (StringUtils.EqualsIgnoreCase(attributeName, nameof(Content.Source))) { style.AttributeName = nameof(Content.Source); style.DisplayName = "来源"; style.Taxis = 9; } style.Items = TranslateUtils.JsonDeserialize <List <InputStyleItem> >(style.ItemValues); style.Rules = TranslateUtils.JsonDeserialize <List <InputStyleRule> >(style.RuleValues); return(style); }
public void TableThCellStyles() { using (MemoryStream mem = new MemoryStream()) { WordDocument doc = new WordDocument(mem); doc.Process(new HtmlParser("<table><tr><th>Id</th></tr><tr><td>1</td></tr></table>")); Assert.IsNotNull(doc.Document.Body); Assert.AreEqual(1, doc.Document.Body.ChildElements.Count); Word.Table table = doc.Document.Body.ChildElements[0] as Word.Table; Assert.IsNotNull(table); Assert.AreEqual(4, table.ChildElements.Count); TableProperties tableProperties = table.ChildElements[0] as TableProperties; Assert.IsNotNull(tableProperties); TableStyle tableStyle = tableProperties.ChildElements[0] as TableStyle; Assert.IsNotNull(tableStyle); Assert.AreEqual("TableGrid", tableStyle.Val.Value); TableGrid tableGrid = table.ChildElements[1] as TableGrid; Assert.IsNotNull(tableGrid); Assert.AreEqual(1, tableGrid.ChildElements.Count); TableRow row = table.ChildElements[2] as TableRow; Assert.IsNotNull(row); Assert.AreEqual(1, row.ChildElements.Count); TableCell cell = row.ChildElements[0] as TableCell; Assert.IsNotNull(cell); Assert.AreEqual(1, cell.ChildElements.Count); Paragraph para = cell.ChildElements[0] as Paragraph; Assert.IsNotNull(para); Assert.AreEqual(1, para.ChildElements.Count); Run run = para.ChildElements[0] as Run; Assert.IsNotNull(run); Assert.AreEqual(2, run.ChildElements.Count); Assert.IsNotNull(run.RunProperties); Bold bold = run.RunProperties.ChildElements[0] as Bold; Assert.IsNotNull(bold); Word.Text text = run.ChildElements[1] as Word.Text; Assert.IsNotNull(text); Assert.AreEqual(0, text.ChildElements.Count); Assert.AreEqual("Id", text.InnerText); row = table.ChildElements[3] as TableRow; Assert.IsNotNull(row); Assert.AreEqual(1, row.ChildElements.Count); cell = row.ChildElements[0] as TableCell; cell.TestTableCell(1, "1"); OpenXmlValidator validator = new OpenXmlValidator(); var errors = validator.Validate(doc.WordprocessingDocument); Assert.AreEqual(0, errors.Count()); } }
static void Main(string[] args) { TableStyle tableStyle1 = new TableStyle("TableStyle1"); tableStyle1.Width = new Size(6.3, Unit.Inch); tableStyle1.Alignment = TableAlignment.Left; tableStyle1.LeftMargin = new Size(0, Unit.Inch); ColumnStyle columnStyle1 = new ColumnStyle("ColumnStyle1"); columnStyle1.Width = new Size(1.2, Unit.Inch); ColumnStyle columnStyle2 = new ColumnStyle("ColumnStyle2"); columnStyle2.Width = new Size(1.3, Unit.Inch); CellStyle cellStyle1 = new CellStyle("CellStyle1"); cellStyle1.CellProperties.BackgroundColor = "#CCCCCC"; //gray cellStyle1.CellProperties.Border = new Border(new Size(0.0069, Unit.Inch), BorderStyle.Solid, "#000000"); CellStyle cellStyle2 = new CellStyle("CellStyle2"); cellStyle2.CellProperties.Border = new Border(new Size(0.0069, Unit.Inch), BorderStyle.Solid, "#000000"); TextDocument doc = new TextDocument(); doc.AutomaticStyles.Styles.Add(tableStyle1); doc.AutomaticStyles.Styles.Add(columnStyle1); doc.AutomaticStyles.Styles.Add(columnStyle2); doc.AutomaticStyles.Styles.Add(cellStyle1); doc.AutomaticStyles.Styles.Add(cellStyle2); Column column1 = new Column(); column1.Style = "ColumnStyle1"; Column column2 = new Column(); column2.Style = "ColumnStyle1"; Column column3 = new Column(); column3.Style = "ColumnStyle2"; Column column4 = new Column(); column4.Style = "ColumnStyle2"; Column column5 = new Column(); column5.Style = "ColumnStyle2"; Table table1 = new Table(); table1.Style = "TableStyle1"; table1.Columns.Add(column1); table1.Columns.Add(column2); table1.Columns.Add(column3); table1.Columns.Add(column4); table1.Columns.Add(column5); Cell cell11 = new Cell("A"); cell11.Style = "CellStyle1"; Cell cell12 = new Cell("B"); cell12.Style = "CellStyle1"; Cell cell13 = new Cell("C"); cell13.Style = "CellStyle1"; Cell cell14 = new Cell("D"); cell14.Style = "CellStyle1"; Cell cell15 = new Cell("E"); cell15.Style = "CellStyle1"; Row row1 = new Row(); row1.Cells.Add(cell11); row1.Cells.Add(cell12); row1.Cells.Add(cell13); row1.Cells.Add(cell14); row1.Cells.Add(cell15); Cell cell21 = new Cell("1"); cell21.Style = "CellStyle2"; Cell cell22 = new Cell("2"); cell22.Style = "CellStyle2"; Cell cell23 = new Cell("3"); cell23.Style = "CellStyle2"; Cell cell24 = new Cell("4"); cell24.Style = "CellStyle2"; Cell cell25 = new Cell("5"); cell25.Style = "CellStyle2"; Row row2 = new Row(); row2.Cells.Add(cell21); row2.Cells.Add(cell22); row2.Cells.Add(cell23); row2.Cells.Add(cell24); row2.Cells.Add(cell25); table1.Rows.Add(row1); table1.Rows.Add(row2); table1.Rows.Add(row2); table1.Rows.Add(row2); Paragraph p1 = new Paragraph(); p1.Add("Table with style"); Paragraph p2 = new Paragraph(); doc.Body.Add(p1); doc.Body.Add(p2); doc.Body.Add(table1); doc.Save("c:\\test\\output.odt", true); }
internal override void restoreProperties(ItemProperties props) { TableProperties tprops = (TableProperties)props; caption = tprops.caption; captionColor = tprops.captionColor; captionFormat = tprops.captionFormat; captionHeight = tprops.captionHeight; cellBorders = tprops.cellBorders; columnWidth = tprops.columnWidth; currScrollRow = tprops.currScrollRow; linkStyle = tprops.linkStyle; picture = tprops.picture; picturePos = tprops.picturePos; rowHeight = tprops.rowHeight; scrollable = tprops.scrollable; selStyle = tprops.selStyle; style = tprops.style; textColor = tprops.textColor; EnableStyledText = tprops.enableStyledText; customDraw = tprops.customDraw; cellCustomDraw = tprops.cellCustomDraw; if (captionBackBrush != tprops.captionBackBrush) { if (captionBackBrush != null) captionBackBrush.Release(); captionBackBrush = tprops.captionBackBrush; if (captionBackBrush != null) captionBackBrush.AddRef(); } base.restoreProperties(props); }
public void TableCellWidth() { using (MemoryStream mem = new MemoryStream()) { WordDocument doc = new WordDocument(mem); doc.Process(new HtmlParser("<table style='width:500px'><tr><td style='width:250px'>1</td><td style='width:250px'>2</td></tr></table>")); Assert.IsNotNull(doc.Document.Body); Assert.AreEqual(1, doc.Document.Body.ChildElements.Count); Word.Table table = doc.Document.Body.ChildElements[0] as Word.Table; Assert.IsNotNull(table); Assert.AreEqual(3, table.ChildElements.Count); TableProperties tableProperties = table.ChildElements[0] as TableProperties; Assert.IsNotNull(tableProperties); Assert.AreEqual(2, tableProperties.ChildElements.Count); TableStyle tableStyle = tableProperties.ChildElements[0] as TableStyle; Assert.IsNotNull(tableStyle); Assert.AreEqual("TableGrid", tableStyle.Val.Value); TableWidth tableWidth = tableProperties.ChildElements[1] as TableWidth; Assert.IsNotNull(tableWidth); Assert.AreEqual("10000", tableWidth.Width.Value); Assert.AreEqual(TableWidthUnitValues.Dxa, tableWidth.Type.Value); TableRow row = table.ChildElements[2] as TableRow; Assert.IsNotNull(row); Assert.AreEqual(2, row.ChildElements.Count); TableCell cell = row.ChildElements[0] as TableCell; Assert.IsNotNull(cell); Assert.AreEqual(2, cell.ChildElements.Count); TableCellProperties cellProperties = cell.ChildElements[0] as TableCellProperties; Assert.IsNotNull(cellProperties); TableCellWidth cellWidth = cellProperties.ChildElements[0] as TableCellWidth; Assert.IsNotNull(cellWidth); Assert.AreEqual("5000", cellWidth.Width.Value); Assert.AreEqual(TableWidthUnitValues.Dxa, cellWidth.Type.Value); Paragraph para = cell.ChildElements[1] as Paragraph; Assert.IsNotNull(para); Assert.AreEqual(1, para.ChildElements.Count); Run run = para.ChildElements[0] as Run; Assert.IsNotNull(run); Assert.AreEqual(1, run.ChildElements.Count); Word.Text text = run.ChildElements[0] as Word.Text; Assert.IsNotNull(text); Assert.AreEqual(0, text.ChildElements.Count); Assert.AreEqual("1", text.InnerText); cell = row.ChildElements[1] as TableCell; Assert.IsNotNull(cell); Assert.AreEqual(2, cell.ChildElements.Count); cellProperties = cell.ChildElements[0] as TableCellProperties; Assert.IsNotNull(cellProperties); cellWidth = cellProperties.ChildElements[0] as TableCellWidth; Assert.IsNotNull(cellWidth); Assert.AreEqual("5000", cellWidth.Width.Value); Assert.AreEqual(TableWidthUnitValues.Dxa, cellWidth.Type.Value); para = cell.ChildElements[1] as Paragraph; Assert.IsNotNull(para); Assert.AreEqual(1, para.ChildElements.Count); run = para.ChildElements[0] as Run; Assert.IsNotNull(run); Assert.AreEqual(1, run.ChildElements.Count); text = run.ChildElements[0] as Word.Text; Assert.IsNotNull(text); Assert.AreEqual(0, text.ChildElements.Count); Assert.AreEqual("2", text.InnerText); OpenXmlValidator validator = new OpenXmlValidator(); var errors = validator.Validate(doc.WordprocessingDocument); Assert.AreEqual(0, errors.Count()); } }