示例#1
0
        /// <summary>
        /// Gets the columns titles as an array of strings.
        /// </summary>
        public IEnumerable <string> ColumnTitles()
        {
            List <string> titles = new List <string>();

            A.Table    tbl = this.slideTemplate.FindTable(this.tblId);
            A.TableRow tr  = GetRow(tbl, 0); // The first table row == the columns

            int columnsCount = this.ColumnsCount();

            for (int i = 0; i < columnsCount; i++)
            {
                A.TableCell tc   = GetCell(tr, i);
                var         text = string.Join(" ", tc.Descendants <A.Paragraph>().Select(PptxParagraph.GetTexts).ToArray());
                titles.Add(text);
            }

            return(titles);
        }
示例#2
0
 private static void ModifyPowerPointCellTextContent(OXD.TableCell cell, string txt)
 {
     if (null != cell)
     {
         OXD.TextBody textbody = cell.Descendants <OXD.TextBody>().FirstOrDefault();
         if (null != textbody)
         {
             OXD.TextBody  final_textbody = textbody.CloneNode(true) as OXD.TextBody;
             OXD.Paragraph paragraph      = final_textbody.Descendants <OXD.Paragraph>().FirstOrDefault();
             if (null != paragraph)
             {
                 OXD.Paragraph final_paragraph = paragraph.CloneNode(true) as OXD.Paragraph;
                 ModifyPowerPointParagraphTextContent(final_paragraph, txt);
                 final_textbody.ReplaceChild <OXD.Paragraph>(final_paragraph, paragraph);
             }
             cell.ReplaceChild <OXD.TextBody>(final_textbody, textbody);
         }
     }
 }
 private void SetCellText(Xdr.TableCell cell, string strText, int weightage, Xdr.TableRow i)
 {
     // Add text dynamically.
     if (strText.Length > 150)
     {
         strText  = strText.Substring(0, 149);
         i.Height = i.Height * weightage - 5000;
         _intTaskhaving++;
     }
     Xdr.Text text = cell.Descendants <Xdr.Text>().FirstOrDefault();
     if (text == default(Xdr.Text))
     {
         return;
     }
     text.Text = strText;
     Xdr.Text newText = new Xdr.Text();
     newText.Text = strText;
     text         = newText;
 }
示例#4
0
        /// <summary>
        /// Replaces a tag inside a given table cell (a:tc).
        /// </summary>
        /// <param name="slide">The PptxSlide.</param>
        /// <param name="tc">The table cell (a:tc).</param>
        /// <param name="cell">Contains the tag, the new text and a picture.</param>
        /// <returns><c>true</c> if a tag has been found and replaced, <c>false</c> otherwise.</returns>
        private static bool ReplaceTag(PptxSlide slide, A.TableCell tc, Cell cell)
        {
            bool replacedAtLeastOnce = false;

            // a:p
            foreach (A.Paragraph p in tc.Descendants <A.Paragraph>())
            {
                bool replaced = PptxParagraph.ReplaceTag(p, cell.Tag, cell.NewText);
                if (replaced)
                {
                    replacedAtLeastOnce = true;

                    // a:tcPr
                    if (cell.Picture != null)
                    {
                        A.TableCellProperties tcPr = tc.GetFirstChild <A.TableCellProperties>();
                        SetTableCellPropertiesWithBackgroundPicture(slide, tcPr, cell.Picture);
                    }
                }
            }

            return(replacedAtLeastOnce);
        }