What's? 
FileIn == FileOut?

But this is irrelevant to the problem.... or not ?!?


saper1281 wrote:
> 
> c://temp//template_final.ppt======>c://temp/template_final.ppt
> 
> 
> 
> 
> Luk@ wrote:
>> 
>> Hi,
>> I urgently need your help.
>> First I apologize for my bad English.
>> I am a newbie of POI, I'm just venturing into their use.
>> My environment is this:
>> J2SE 1.5
>> Eclipse
>> POI 03/06 (20091214)
>> 
>> I have this problem, I can not replace the text within a text to be
>> replaced when the ppt contains special characters. An example of a
>> special character is € 
>> 
>> Exception in thread "main" java.lang.NullPointerException
>>      at org.apache.poi.hslf.model.TextRun.storeText(TextRun.java:350)
>>      at org.apache.poi.hslf.model.TextRun.setRawText(TextRun.java:464)
>>      at org.apache.poi.hslf.model.TextRun.setText(TextRun.java:498)
>>      at ExampleError.main(ExampleError.java:41)
>> 
>> 
>> Banging his head on, but unable to solve. :,(:,(
>> 
>> Below the code that I'm using:
>> 
>> 
>> import org.apache.poi.hslf.HSLFSlideShow;
>> import org.apache.poi.hslf.model.Slide;
>> import org.apache.poi.hslf.model.TextRun;
>> import org.apache.poi.hslf.usermodel.RichTextRun;
>> import org.apache.poi.hslf.usermodel.SlideShow;
>> import org.apache.poi.poifs.filesystem.POIFSFileSystem;
>> 
>> 
>> public class ExampleError {
>> 
>>      public static void main(String[] args) {
>>              POIFSFileSystem fs; 
>> 
>>              try {
>>                      fs = new POIFSFileSystem(new
>> FileInputStream("c://temp//template_test.ppt"));
>>                      SlideShow ppt = new SlideShow(new HSLFSlideShow(fs));
>>                      Slide[] slides = ppt.getSlides(); 
>>                      
>>                      String replace = "Amount €100";
>>                      
>>                      int nSlide = slides.length;
>> 
>>                      for (int i = 0; i < nSlide; i++) {
>>                              TextRun[] txtRun = slides[i].getTextRuns();
>>                      
>>                              for (int j = 0; j < txtRun.length; j++) {
>>                                                      
>>                                      String textGet = txtRun[j].getText();
>>                                      
>>                                      String txtReplaced = 
>> textGet.replace("{txtTot}", replace);
>>                                      
>>                                      System.out.println("Replaced: " + 
>> txtReplaced);
>>                                      txtRun[j].setText(txtReplaced);
>>                              }
>>                      }
>>                      
>>                      FileOutputStream out = new
>> FileOutputStream("c://temp//template_final.ppt");
>>                      ppt.write(out);
>>                      out.close();
>>                      
>>              } catch (FileNotFoundException e) {
>>                      e.printStackTrace();
>>              } catch (IOException e) {
>>                      e.printStackTrace();
>>              }
>> 
>>      }
>> 
>> }
>> 
>> Please find attached a ppt that I use for simple tests.
>> Please help I no longer go forward suggestions are welcome, my code
>> changes ... in short anything.
>> 
>>   http://old.nabble.com/file/p29256267/template_test.ppt
>> template_test.ppt 
>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/-Help--Hslf-Error-%3ACan-not-replace-special-characters-tp29256267p29295154.html
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to