how do i copy excel table as object in power point using c#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rshrestha
    New Member
    • Feb 2010
    • 5

    how do i copy excel table as object in power point using c#

    Hi,

    I have a some information i.e. is in Table format in Excel
    I want to insert that Table into power point
    using C#
    how do i do that
    Please help

    i've also added the snap shot of table

    thank you
    Attached Files
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    What have you coded/tried so far? Please so use what you are trying right now along with any error/exception you are getting.

    Comment

    • rshrestha
      New Member
      • Feb 2010
      • 5

      #3
      Here is the code
      that i've been using
      i'm able to insert the data into excel
      now after inserting those data
      i want to bring that whole table in power point
      something like ChartObject

      thank you
      Attached Files

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.


        Just copy/paste your code for extracting the table, along with the error message you are getting. Don't attache a file of your entire project. Just the code that is giving you trouble.

        Comment

        • rshrestha
          New Member
          • Feb 2010
          • 5

          #5
          Here is the code

          Code:
          protected void CreatePowerPointSlideFromExcelTemplate()
              {
                  excelApp = new Excel.Application();
          
                  excelApp.Visible = true;
                  string templatePath = MapPath("ChartTemplate.xlsx");
          
                  object missing = System.Type.Missing;
          
                  Excel.Workbook objWorkbook = excelApp.Workbooks.Open(templatePath, missing);
                  
          
                  Excel.Worksheet wSheetTest = (Excel.Worksheet)objWorkbook.Sheets["testTable1"]; //test Table
          
                  
          // HERE I WANT TO CAPTURE THAT TABLE IN PICTURE AS SOME KIND OF OBJECT // SO THAT I CAN ADD IT IN POWERPOINT SLIDE
                 CreateChartBasedOnEnteredValues(wSheetTest, "testTable");
          
                
          
                  CreateSlideForGraph(CreateChartBasedOnEnteredValues(wSheetTest, "testTable"));
          
                  // Close and release the Excel Workbook object.
                  if (objWorkbook != null)
                  {
                      objWorkbook.Close(false, missing, missing);
                      objWorkbook = null;
                  }
          
                  // Quit Excel and release the ApplicationClass object.
                  if (excelApp != null)
                  {
                      excelApp.Quit();
                      excelApp = null;
                  }
          
                 
          
              }
          
          
          
          protected CreateTableBasedOnEnteredValues(Excel.Worksheet wSheet, string chartName, string lbl1, string fy1Qtr1, string fy1Qtr2, string fy1Qtr3, string fy1Qtr4, string lbl2, string fy2Qtr1, string fy2Qtr2, string fy2Qtr3, string fy2Qtr4)
              {
                  Object missing = System.Type.Missing;
          
                
                  wSheet.get_Range("B3", "B3").set_Value(Excel.XlRangeValueDataType.xlRangeValueDefault, "test");
                  wSheet.get_Range("C3", "C3").set_Value(Excel.XlRangeValueDataType.xlRangeValueDefault, "test");
                  wSheet.get_Range("D3", "D3").set_Value(Excel.XlRangeValueDataType.xlRangeValueDefault, "test");
                  wSheet.get_Range("F3", "F3").set_Value(Excel.XlRangeValueDataType.xlRangeValueDefault, "test");
          
                  wSheet.get_Range("B4", "B4").set_Value(Excel.XlRangeValueDataType.xlRangeValueDefault, "test");
                  wSheet.get_Range("C4", "C4").set_Value(Excel.XlRangeValueDataType.xlRangeValueDefault, "test");
                  wSheet.get_Range("D4", "D4").set_Value(Excel.XlRangeValueDataType.xlRangeValueDefault, "test");
                  wSheet.get_Range("F4", "F4").set_Value(Excel.XlRangeValueDataType.xlRangeValueDefault, "test");
          
                  Excel.ChartObjects chartObjects = (Excel.ChartObjects)(wSheet.ChartObjects(missing));
                  Excel.ChartObject objChart = (Excel.ChartObject)(chartObjects.Item(chartName));
          
                  
              }

          Comment

          • tlhintoq
            Recognized Expert Specialist
            • Mar 2008
            • 3532

            #6
            // HERE I WANT TO CAPTURE THAT TABLE IN PICTURE AS SOME KIND OF OBJECT // SO THAT I CAN ADD IT IN POWERPOINT SLIDE
            This is not exactly what we here at Bytes consider your own effort to code this, before asking for help.

            Its more like you are asking for someone to just give you the code to do it.

            Originally posted by Original Poster
            Can anybody send me code to [...]
            The Bytes volunteers are not here to write your code for you. This is not a free homework service.
            Bytes is very much a "Give me a fish I eat for a day. Teach me to fish I eat for a lifetime" kind of place. Just giving you the code doesn't help you learn near as effectively as good old-fashioned trial and error.

            Do a little reading up and experimenting then if your trials aren't doing what you expect, post the code and relevant messages/errors and we'll see what we can do to point you in the right direction for making it work.

            Try hitting Google with terms of your programming language and primary terms of what you want to do. For example "C# custom events" or "VB datagrid Excel". I've found this to be a very effective tool.

            May I suggest
            • First: Do some research. I heard about thing thing called Google, or books even.
            • Second: Do some experiments yourself. You will learn so much from actually trying it before throwing up your hands in defeat before even starting.
            • Third: Show the volunteers here the code that you created that was the closest to successful along with relevant errors.

            Comment

            • rshrestha
              New Member
              • Feb 2010
              • 5

              #7
              sorry for the inconvenience.
              I really appreciate your help and time.
              Its not that i've given up
              but at this point i'm not able to go any further.
              so i had to go other way
              i.e. creating table object directly in PowerPoint
              but doing this really slows down the performance

              For getting that excel table as an object i had done lots of trial and error method
              but got no where

              thank you

              Comment

              • Niheel
                Recognized Expert Moderator Top Contributor
                • Jul 2005
                • 2433

                #8
                You can use the Open XML Format SDK to move data from one type of office document to another.

                There is more information available here:


                What is the Open XML Format SDK?
                The Open XML Format SDK provides a set of Microsoft .NET Framework application programming interfaces (APIs) that allows you to create and manipulate documents in both client and server environments by using the Open XML Formats without requiring Microsoft Office client applications.
                niheel @ bytes

                Comment

                Working...