ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  How to export a PNG image form ChartDirector to Power point?
Posted by VerXus on Jun-19-2013 12:25
Attachments:
Please,Tell me

How to export a PNG image  form ChartDirector to Power point?




Thank a lot ; )
Pic.png

  Re: How to export a PNG image form ChartDirector to Power point?
Posted by VerXus on Jun-19-2013 12:29
I use Language c# ^ ^"

  Re: How to export a PNG image form ChartDirector to Power point?
Posted by Peter Kwan on Jun-20-2013 01:09
Hi VerXus,

You may use BaseChart.makeChart to output a chart as a PNG image file. For example:

c.makeChart("c:\\\\aaa.png");

To create a PowerPoint file containing an image file, please refer to Microsoft documentation on how to use PowerPoint. Most versions of PointPoint nowadays support .NET programming. See:

http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint(v=office.14).aspx

If you are using some old PowerPoint versions, you may use COM Interop to control the PowerPoint with C#. The COM Interop should work with newer PointPower version too. See

http://support.microsoft.com/kb/303718

An example based on the above Microsoft documentation is like:

PowerPoint.Application oApp = new PowerPoint.Application();
PowerPoint.Presentation oPres = oApp.Presentations.Add(Office.MsoTriState.msoFalse);
PowerPoint.Slide oSlide = oPres.Slides.Add(1, PowerPoint.PpSlideLayout.ppLayoutBlank);
oSlide.Shapes.AddPicture("c:\\\\aaa.png", Office.MsoTriState.msoFalse, Office.MsoTriState.msoTrue, 100, 100, 500, 350);
oPres.SaveCopyAs("c:\\\\aaa.ppt", PowerPoint.PpSaveAsFileType.ppSaveAsDefault, Office.MsoTriState.msoFalse);
oApp.Quit();

Note that like any .NET library, to use it, you would need to reference it in your .NET project. For the above COM Interop method, please reference the PowerPoint COM object in your .NET project.

Hope this can help.

Regards
Peter Kwan

  Re: How to export a PNG image form ChartDirector to Power point?
Posted by Peter Kwan on Jun-20-2013 01:11
Hi VerXus,

Note that if you are writing a web application, make sure the ASP.NET web server account has read and write access to the directory that you want to create the image and PowerPoint files. (The ASP.NET web server account represents the anonymous user, and it may not have write acess to most of the directories in the system.)

Regards
Peter Kwan

  Re: How to export a PNG image form ChartDirector to Power point?
Posted by VerXus on Jun-21-2013 12:12
Thank you! Peter Kwan.

I'm new for ASP.NET

This is my code. Please give me some instructions.

<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="ChartDirector" %>
<%@ Register TagPrefix="chart" Namespace="ChartDirector"
Assembly="netchartdir" %>
<script runat="server">

//
// Page Load event handler
//
protected void Page_Load(object sender, EventArgs e)
{
    // The XY points for the bubble chart. The bubble chart has independent bubble
    // size on the X and Y direction.
    double[] dataX0 = { 1000 };
    double[] dataY0 = { 25 };
    double[] dataZX0 = { 350 };
    double[] dataZY0 = { 8 };

    double[] dataX1 = { 500 };
    double[] dataY1 = { 35 };
    double[] dataZX1 = { 350 };
    double[] dataZY1 = { 8 };

    double[] dataX2 = { 250 };
    double[] dataY2 = { 10 };
    double[] dataZX2 = { 350 };
    double[] dataZY2 = { 8 };

    // Create a XYChart object of size 450 x 420 pixels
    XYChart c = new XYChart(450, 420);

    // Set the plotarea at (55, 65) and of size 350 x 300 pixels, with a light grey
    // border (0xc0c0c0). Turn on both horizontal and vertical grid lines with light
    // grey color (0xc0c0c0)
    c.setPlotArea(55, 65, 350, 300, -1, -1, 0xc0c0c0, 0xc0c0c0, -1);

    // Add a legend box at (50, 30) (top of the chart) with horizontal layout. Use 12
    // pts Times Bold Italic font. Set the background and border color to
    // Transparent.
    c.addLegend(50, 30, false, "Times New Roman Bold Italic", 12).setBackground(
        Chart.Transparent);

    // Add a title to the chart using 18 pts Times Bold Itatic font.
    c.addTitle("Plasma Battery Comparison", "Times New Roman Bold Italic", 18);

    // Add titles to the axes using 12 pts Arial Bold Italic font
    c.yAxis().setTitle("Operating Current", "Arial Bold Italic", 12);
    c.xAxis().setTitle("Operating Voltage", "Arial Bold Italic", 12);

    // Set the axes line width to 3 pixels
    c.xAxis().setWidth(3);
    c.yAxis().setWidth(3);

    // Add (dataX0, dataY0) as a standard scatter layer, and also as a "bubble"
    // scatter layer, using circles as symbols. The "bubble" scatter layer has symbol
    // size modulated by (dataZX0, dataZY0) using the scale on the x and y axes.
    c.addScatterLayer(dataX0, dataY0, "Vendor A", Chart.CircleSymbol, 9, 0xff3333,
        0xff3333);
    c.addScatterLayer(dataX0, dataY0, "", Chart.CircleSymbol, 9,
        unchecked((int)0x80ff3333), unchecked((int)0x80ff3333)).setSymbolScale(
        dataZX0, Chart.XAxisScale, dataZY0, Chart.YAxisScale);

    // Add (dataX1, dataY1) as a standard scatter layer, and also as a "bubble"
    // scatter layer, using squares as symbols. The "bubble" scatter layer has symbol
    // size modulated by (dataZX1, dataZY1) using the scale on the x and y axes.
    c.addScatterLayer(dataX1, dataY1, "Vendor B", Chart.CircleSymbol, 7, 0x3333ff,
        0x3333ff);
    c.addScatterLayer(dataX1, dataY1, "", Chart.CircleSymbol, 9,
        unchecked((int)0x803333ff), unchecked((int)0x803333ff)).setSymbolScale(
        dataZX1, Chart.XAxisScale, dataZY1, Chart.YAxisScale);

    // Add (dataX2, dataY2) as a standard scatter layer, and also as a "bubble"
    // scatter layer, using diamonds as symbols. The "bubble" scatter layer has
    // symbol size modulated by (dataZX2, dataZY2) using the scale on the x and y
    // axes.
    c.addScatterLayer(dataX2, dataY2, "Vendor C", Chart.CircleSymbol, 9, 0x00ff00,
        0x00ff00);
    c.addScatterLayer(dataX2, dataY2, "", Chart.CircleSymbol, 9,
        unchecked((int)0x8033ff33), unchecked((int)0x8033ff33)).setSymbolScale(
        dataZX2, Chart.XAxisScale, dataZY2, Chart.YAxisScale);

    // Output the chart
    WebChartViewer1.Image = c.makeWebImage(Chart.PNG);


    // Include tool tip for the chart
    //WebChartViewer1.ImageMap = c.getHTMLImageMap("", "",
      //  "title='Voltage = {x} +/- {={zx}/2} V, Current = {value} +/- {={zy}/2} A'");
}



protected void Button1_Click(object sender, EventArgs e)
{
    ShowPresentation();
    GC.Collect();
}

private void ShowPresentation()
{
    PowerPoint.Application oApp = new PowerPoint.Application();
    PowerPoint.Presentation oPres =
oApp.Presentations.Add(Office.MsoTriState.msoFalse);
    PowerPoint.Slide oSlide = oPres.Slides.Add(1,
PowerPoint.PpSlideLayout.ppLayoutBlank);
    oSlide.Shapes.AddPicture("c:\\\\aaa.png", Office.MsoTriState.msoFalse,
Office.MsoTriState.msoTrue, 100, 100, 500, 350);
    oPres.SaveCopyAs("c:\\\\aaa.ppt", PowerPoint.PpSaveAsFileType.ppSaveAsDefault,
Office.MsoTriState.msoFalse);
    oApp.Quit();

}


</script>
<html>
<body>
    <form id="form1" runat="server">
    <chart:WebChartViewer id="WebChartViewer1" runat="server" />
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button" />
    </form>
</body>
</html>

Regards
VerXus

  Re: How to export a PNG image form ChartDirector to Power point?
Posted by Peter Kwan on Jun-22-2013 01:51
Hi VerXus,

In your code structure, I suggest you declare the "XYChart c" in the Form scope (as outside the Page_Load method, as member variables of the WebForm), so that you can use it in ShowPresentation.

In ShowPresentation, please create the chart as an image file first, then include the image file in the PowerPoint file.


c.makeChart("c:\\\\aaa.png");
.... your powerpoint code here to include "c:\\\\aaa.png" in the powerpoint slide ....

Note that in the above code, the "c:\\\\aaa.png" is just an example. Please modify the code to use a directory suitable for your case, The directory should be readable and writable by the web server (which is running under a special account representing the anonymous user), otherwise the file cannot be created. Similarly, the created PowerPoint file "c:\\\\aaa.ppt" is just an example. Please change it to a suitable name.

The above code should create the PointPoint file in the directory your specified.

If you want to send the PowerPoint file to the user, please just send it to the user just like a regular file. For example, you may create a link to the PowerPoint file in your web page, so the user can click and download the file, or you may just stream the fiile to the user (use the HttpResponse and directly output the file as a stream of suitable content type). For more information on how to send a file to the browser, you may refer to the ASP.NET documentation.

Hope this can help.

Regards
Peter Kwan

  Re: How to export a PNG image form ChartDirector to Power point?
Posted by VerXus on Jun-24-2013 12:29
Thank! Peter Kwan.

But..my teacher want to Xml code for work. T_T

Is it possible to create Powerpoint files?

Regards
VerXus

  Re: How to export a PNG image form ChartDirector to Power point?
Posted by Peter Kwan on Jun-25-2013 01:48
Hi VerXus,

ChartDirector can only create charts. You need to use PowerPoint to create PowerPoint files. The PointPoint file can include a slide with the chart image if you want. You may refer to Microsoft documentation on how to use PowerPoint.

I searched the Microsoft web site, and I immediately find an example of include an image in a slide in an XML PowerPoint file.

http://msdn.microsoft.com/en-us/library/bb727373.aspx#ManipulateOpenXMLExcelPowerPoint_ReplacetheImageonaSlide

So with the above code, I think you can create a template PowerPoint file with a dummy image. When you need to include the chart into the PowerPoint file, you can make a copy of the template PowerPoint file, then use the chart image to replace the dummy image.

Regards
Peter Kwan

  Re: How to export a PNG image form ChartDirector to Power point?
Posted by VerXus on Jun-30-2013 09:59
Hi Peter Kwan!

Thank you for every direction.


Finally,I made it successfully.


Thank you so much ;)