none
Stretch table coming from Excel to PowerPoint in C# RRS feed

  • Question

  • Hello,

    I'm trying to stretch a table in PowerPoint via C#

    The table has been copied from Excel into PowerPoint, the issue is that when pasting the table content is really small and can't be read.

    What I'm doing basically is, copying a HTML file into the

    Clipboard.SetText(html);

    Pasting it into an Excel range

    sheet.Range(cellmapp).PasteSpecial();  
    sheet.Columns.AutoFit();
    sheet.Rows.AutoFit();

    Now, I want to paste it in correct place in PowerPoint

    foreach (PowerPoint.Slide slide in presentation.Slides)
    {
         foreach (PowerPoint.Shape pptshape in slide.Shapes)
         {
               if (!pptshape.Type.ToString().Equals("msoAutoShape") && pptshape.AlternativeText.Contains("|"))
               {
                   if (xlsSheetName == pptSheetName && xlsShapeName == pptxlsShapeName)
                   {
                       ppApp.ActiveWindow.View.PasteSpecial();
                   }
               }
          }
    }

    It copies my table in PowerPoint at the place I choose.

    But the issue is, the table is really thiny and small and illisible, because it's too small.

    Is there a stretch function in C# for this?

    Thanks.

    mike

    Wednesday, April 3, 2013 10:07 AM

Answers

  • Hello,

    Basically what I am looking is to avoid the following code that set the table at my choosen location

    pptshape.Top = topsize;
    pptshape.Left = leftsize;
    pptshape.Width = slide.Master.Width - widthsize;
    pptshape.Height = slide.Master.Height - heightsize;

    And to iterate through all rows/columns to change the font of my tables

    for(int k=startmultiplicator;k<=i;k++)
    {
         for(int l=1;l<=pptshape.Table.Columns.Count;l++)
         {
             objTable.Cell(incrementer,l).Shape.TextFrame.TextRange.Text=pptshape.Table.Cell(k,l).Shape.TextFrame.TextRange.Text;
             objTable.Cell(incrementer, l).Shape.TextFrame.TextRange.Font.Size = fontsize;
             pptshape.Table.Cell(i, j).Shape.TextFrame.TextRange.Font.Size = fontsize;
         }
         incrementer++;
    }

    The issue is, my columns/rows and font should be changed automatically according to the size of my table content and not according to the font size which I declared.

    Hope someone might help me out.

     

    • Marked as answer by mike27015 Tuesday, May 14, 2013 8:59 AM
    Monday, April 8, 2013 12:25 PM

All replies

  • Hello,

    I'm trying to stretch a table in PowerPoint via C#

    The table has been copied from Excel into PowerPoint, the issue is that when pasting the table content is really small and can't be read.

    What I'm doing basically is, copying a HTML file into the

    Clipboard.SetText(html);

    Pasting it into an Excel range

    sheet.Range(cellmapp).PasteSpecial();  
    sheet.Columns.AutoFit();
    sheet.Rows.AutoFit();

    Now, I want to paste it in correct place in PowerPoint

    foreach (PowerPoint.Slide slide in presentation.Slides)
    {
         foreach (PowerPoint.Shape pptshape in slide.Shapes)
         {
               if (!pptshape.Type.ToString().Equals("msoAutoShape") && pptshape.AlternativeText.Contains("|"))
               {
                   if (xlsSheetName == pptSheetName && xlsShapeName == pptxlsShapeName)
                   {
                       ppApp.ActiveWindow.View.PasteSpecial();
                   }
               }
          }
    }

    It copies my table in PowerPoint at the place I choose.

    But the issue is, the table is really thiny and small and illisible, because it's too small.

    Is there a stretch function in C# for this?

    Thanks.

    mike

    Wednesday, April 3, 2013 12:54 PM
  • Hi mike27015,

    I would like to redirect you to appropriate forum for better responses.


    Bob Shen
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, April 4, 2013 9:25 AM
  • Hello,

    Basically what I am looking is to avoid the following code that set the table at my choosen location

    pptshape.Top = topsize;
    pptshape.Left = leftsize;
    pptshape.Width = slide.Master.Width - widthsize;
    pptshape.Height = slide.Master.Height - heightsize;

    And to iterate through all rows/columns to change the font of my tables

    for(int k=startmultiplicator;k<=i;k++)
    {
         for(int l=1;l<=pptshape.Table.Columns.Count;l++)
         {
             objTable.Cell(incrementer,l).Shape.TextFrame.TextRange.Text=pptshape.Table.Cell(k,l).Shape.TextFrame.TextRange.Text;
             objTable.Cell(incrementer, l).Shape.TextFrame.TextRange.Font.Size = fontsize;
             pptshape.Table.Cell(i, j).Shape.TextFrame.TextRange.Font.Size = fontsize;
         }
         incrementer++;
    }

    The issue is, my columns/rows and font should be changed automatically according to the size of my table content and not according to the font size which I declared.

    Hope someone might help me out.

     

    • Marked as answer by mike27015 Tuesday, May 14, 2013 8:59 AM
    Monday, April 8, 2013 12:25 PM