poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kumar <chinnionl...@rediffmail.com>
Subject Nick Re: How to store the Modified slide back into ppt
Date Mon, 17 Jul 2006 05:58:34 GMT

>> With the commented the entire file is replacing with the present slide, 
>> erasing the header information.
>>
>> So is there any procedure to save the changes back into the ppt, having 
>> said that the slide can be at anywhere in the ppt.

>Despite several attempts to read the above, I'm affraid I still can't 
>figure out what's not working for you.

>The process is:
>* open a powerpoint file
>* change some stuff
>* write it out to a new file
>* open that file in powerpoint
>* marvel at your changes

>At what point are things misbehaving?



Hi Nick,

>* open that file in powerpoint
Here I am getting the problem.

Here I am pasting the sample code.

Thanks,
Kumar


import java.io.*;
import org.apache.poi.hslf.model.Shape;
import org.apache.poi.hslf.HSLFSlideShow;
import org.apache.poi.hslf.usermodel.SlideShow;
import org.apache.poi.hslf.model.Slide;
import org.apache.poi.hslf.model.*;

public class CopyOfCopy {
	public static void main(String ar[]){
		try{
	        SlideShow ss = new SlideShow(new HSLFSlideShow
("C:/Test/IndividualSlideProject/Demo1samp.ppt"));
	        Slide [] slides = ss.getSlides();
	        for(int i = 0; i < slides.length; i++){
	        	Shape shp[] = slides[i].getShapes();
	        	for(int j = 0; j<shp.length; j++){
	        		if(shp[j] instanceof Line ){
	        			System.out.println("Line Found");
	        		}
	        		else if(shp[j] instanceof TextBox){
	        			TextBox textShape = (TextBox)shp[j]; 
	        			String mesg = textShape.getText();
	        			if(mesg.equalsIgnoreCase("sample")){// 
If the message is in the text bos is "sample"
	        				textShape.setText("Kumar");    
	// I want to replace the text with "Kumar"			
	        				shp[j] = (Shape)textShape;	
	// Adding text back to Shapes
	        			}
	        		}
	        		else if(shp[j] instanceof Picture){
	        			System.out.println("Picture Found");
	        		}
	        		else{
	        			System.out.println("Something Found");
	        		}
	        	
	        	}
	        }
	        FileOutputStream outFile = new FileOutputStream
("C:/Test/IndividualSlideProject/Demo1samp.ppt");
			ss.write(outFile);
			outFile.close();
			}catch(Exception e){
			System.out.println("Exception e = "+e);
			}
	}
}






---------------------------------------------------------------------
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