Sign In  Sign Up Live-Chat

Create & Insert Graphs?

Last post 05-13-2008, 8:58 AM by simonbell. 6 replies.
Sort Posts: Previous Next
  •  05-09-2008, 1:38 AM 126155

    Create & Insert Graphs?

    hi Guys,

    How do i create and insert  native word charts in documents with Aspose.Words? i can't find it in the documentation.

    Greetings,

    Simon
     
  •  05-09-2008, 5:34 AM 126199 in reply to 126155

    Re: Create & Insert Graphs?

    Hi

     

    Thanks for your request. As I know Word format has no native charts. As a rule charts are inserted into the word document as embedded OLE objects. Unfortunately Aspose.Words doesn’t allow inserting of OLE objects.

    I think that you can use Aspose.Chart component to create graph and then insert it into the word document. For example see the following code:

     

    //Create a sample chart.

    Aspose.Chart.Chart lineChart = new Aspose.Chart.Chart();

    lineChart.Height = 300;

    lineChart.Width = 400;

    Aspose.Chart.Series lineSeries = new Aspose.Chart.Series();

    lineSeries.ChartType = Aspose.Chart.ChartType.Line;

    lineSeries.Name = "Series";

    lineSeries.DataPoints.Add(new Aspose.Chart.DataPoint(1, 1));

    lineSeries.DataPoints.Add(new Aspose.Chart.DataPoint(2, 2));

    lineSeries.DataPoints.Add(new Aspose.Chart.DataPoint(3, 3));

    // Fill a series manually

    lineChart.SeriesCollection.Add(lineSeries);

    //Save chatr in EMF format

    MemoryStream ms = new MemoryStream();

    lineChart.Save(ms, ImageFormat.Emf);

    //Create new document

    Document doc = new Document();

    DocumentBuilder builder = new DocumentBuilder(doc);

    //Insert chart using GetChartImage method

    builder.InsertImage(lineChart.GetChartImage());

    //Insert chart as EMF

    builder.InsertImage(ms);

    //Save document

    doc.Save(@"Test068\out.doc");

     

    You can read about Aspose.Chart component here:

    http://www.aspose.com/documentation/visual-components/aspose.chart-for-.net/product-overview.html

     

    I hope this could help you.

     

    Best regards.


    Alexey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
  •  05-10-2008, 5:56 AM 126381 in reply to 126199

    Re: Create & Insert Graphs?

    Hi,

    thanks. with word 2007 you can insert graphs and double click them to make changes to their plots or change the chart type etc. it when graphs are inserted into the older .doc files.

    i'm suspecting word 2007 has a emf format its using for this. can this be done with Aspose.Chart?

    Greetings,

    Simon

    EDIT: i'll give it a try after the weekend

     
  •  05-10-2008, 8:18 AM 126387 in reply to 126381

    Re: Create & Insert Graphs?

    Hi

     

    Exactly this I meant. These charts are not native Word charts but these are embedded OLE objects.

    As you can see from my code example chart created by Aspose.Chart was inserted into the Word document in EMF format.

     

    Best regards.


    Alexey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
  •  05-13-2008, 2:44 AM 126618 in reply to 126387

    Re: Create & Insert Graphs?

    Hi

    thanks for the info
    - what is the format of native word graphs/charts? is it emf ? ( just making sure )
    - is it possible to insert an image from a bitmap object? (just a minor question i guess)

    sorry for all the questions. i'm kinda new to this

    Simon
     
  •  05-13-2008, 5:35 AM 126640 in reply to 126618

    Re: Create & Insert Graphs?

    Hi

     

    Thanks for your request. The native Word chart is Microsoft Graph Chart. You can double click this chart to edit it.

    EMF is just metafiles (vector images).

     

    Best regards.


    Alexey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
  •  05-13-2008, 8:58 AM 126680 in reply to 126640

    Re: Create & Insert Graphs?

    ok i understand. thanks
     
View as RSS news feed in XML