poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yegor Kozlov <ye...@dinom.ru>
Subject Re: POI issue
Date Tue, 04 Jul 2006 06:11:39 GMT
Hi,

Your code is almost correct.

The last lines must be as follows:

        FileOutputStream out = new FileOutputStream("C:/Test/Presen.ppt");
        ppt.write(out);
        out.close();


I.e. To create a new PPT you call  SlideShow ppt = new SlideShow();
To write it to a output stream call  ppt.write(out);


HSSFWorkbook has nothing to do with the PPT stuff. It's about XLS generation.

Regards,
Yegor

        
K> Hi,
K> I am new to POI. I am trying out the sample examples that were given in POI 
K> site.
K> I am getting the following error while opening the ppt file generated,just 
K> after executing the following program. Can anyone tell me what might be the 
K> problem was?

K> Thanks in advance.


K> Error:PowerPoint cant open the type of file represented by C:\Test\Presen.ppt

K> And the java file is :

K> public class PPTExample {
K> public static void main(String ar[]){

K> try{
K> SlideShow ppt = new SlideShow();
K> HSSFWorkbook wb = new HSSFWorkbook();
K> Slide slide = ppt.createSlide();

K> //Line shape
K> Line line = new Line();
K> line.setAnchor(new java.awt.Rectangle(50, 50, 100, 20));
K> line.setLineColor(new Color(0, 128, 0));
K> line.setLineStyle(Line.LineDashDotSys);
K> slide.addShape(line);

K> //TextBox
K> TextBox txt = new TextBox();
K> txt.setText("Hello, World!");
K> txt.setAnchor(new java.awt.Rectangle(100, 100, 200, 50));
K> txt.setFontSize(32);
K> txt.setFontName("Arial");
K> txt.setBold(true);
K> slide.addShape(txt);

K> //Autoshape
K> //32-point star
K> AutoShape sh1 = new AutoShape(ShapeTypes.Star32);
K> sh1.setAnchor(new java.awt.Rectangle(50, 50, 100, 200));
K> sh1.setFillColor(Color.red);
K> slide.addShape(sh1);

K> //Trapezoid
K> AutoShape sh2 = new AutoShape(ShapeTypes.Trapezoid);
K> sh2.setAnchor(new java.awt.Rectangle(150, 150, 100, 200));
K> sh2.setFillColor(Color.blue);
K> slide.addShape(sh2);

K> FileOutputStream out = new FileOutputStream("C:/Test/Presen.ppt");
K> wb.write(out);
K> out.close();

K> }catch(Exception e){
K> System.out.println("Exception = "+e); 
K> }
K> }
K> } 



K> ---------------------------------------------------------------------
K> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
K> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
K> The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


Mime
View raw message