PowerPoint Table C#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chrizstone
    New Member
    • Nov 2009
    • 3

    PowerPoint Table C#

    Hi Guys,

    What i want to do is:

    I want to create a Slide programmaticall y where a Table is on it! Here´s my Code:

    Code:
    String strTemplate;
                strTemplate = template;
                String tableSlide = @"C:\Temp\TableSlide_" + guid.ToString();
    
    	        PowerPoint.Application objApp;
    	        PowerPoint.Presentations objPresSet;
    	        PowerPoint._Presentation objPres;
    	        PowerPoint.Slides objSlides;
    	        PowerPoint._Slide objSlide;
    	        PowerPoint.TextRange objTextRng;
    
    	        //Create a new presentation based on a template.
    	        objApp = new PowerPoint.Application();
    	        objApp.Visible = MsoTriState.msoTrue;
    	        objPresSet = objApp.Presentations;
    	        objPres = objPresSet.Open(strTemplate,
    		        MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
    	        objSlides = objPres.Slides;
    
    
    	        //Build Slide #1:
    	        //Add text to the slide, change the font and insert/position a
    	        //picture on the first slide.
    	        objSlide = objSlides.Add(1,PowerPoint.PpSlideLayout.ppLayoutTable);
                objSlide.HeadersFooters.Footer.Visible = MsoTriState.msoTrue;
                objSlide.HeadersFooters.Footer.Text = "hallo";
    
    
                objSlide.HeadersFooters.DateAndTime.Visible = MsoTriState.msoTrue;
                objSlide.HeadersFooters.DateAndTime.UseFormat = MsoTriState.msoTrue;
                objSlide.HeadersFooters.DateAndTime.Format = Microsoft.Office.Interop.PowerPoint.PpDateTimeFormat.ppDateTimeddddMMMMddyyyy;
                objSlide.HeadersFooters.SlideNumber.Visible = MsoTriState.msoTrue;
    	        objTextRng = objSlide.Shapes[1].TextFrame.TextRange;
                objTextRng.Text = title;
                
    
    	        // insert a PowerPoint table
    	        // use data from a file
    	        PowerPoint.Table objTable = null;
            	
    	        objTable= objSlide.Shapes.AddTable(4,4,36,138,648,294).Table;
                
            		
    	        objTable.Cell(1,1).Shape.TextFrame.TextRange.Text = "Stundennnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn";
                objTable.Cell(1, 2).Shape.TextFrame.TextRange.Text = "Fach";
                objTable.Cell(1, 3).Shape.TextFrame.TextRange.Text = "Note";
                
            	
            			
            		
            	
    
                objPres.SaveAs(tableSlide, Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsDefault, MsoTriState.msoCTrue);
                //Close the presentation without saving changes and quit PowerPoint.
                objPres.Close();
                objApp.Quit();
    But if the String in Cell (1,1)for example, is very long then i want that the cell weigth goes bigger automatically! how can i do this?

    Sorry for my bad english...:)
  • chrizstone
    New Member
    • Nov 2009
    • 3

    #2
    No One? Can anybody help me?

    Comment

    Working...