cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
  • New JMP features coming to desktops everywhere this September. Sign up to learn more at jmp.com/launch.
Choose Language Hide Translation Bar
SpannerHead
Level VI

Export to Powerpoint

I've looked around to see if there's a way to have a better export of a series of JMP graphs to Powerpoint or Word.  The native export is very bland and I'd like to be able to manipulate that somehow if anyone has had success with that.  I'm able to record and modify macros in Powerpoint to do the job but I'm hoping for something better than that.


Slán



SpannerHead
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Export to Powerpoint

I started using python-pptx for presentations.  It is pretty capable, but the documentation is a little lacking.  I like to create PowerPoint layouts and save them as a generic presentation then use JMP windows with user inputs to build my Python code.

 

An example of the first part of one of my PowerPoint presentation scripts:

 

pycode = Eval Insert(
	"\[from pptx import Presentation
from PIL import Image, ImageEnhance
import io
p = Presentation(r'^template_path^')
slid = p.slides[0]
mom = slid.shapes[1]
slid.shapes.title.text = '^pres^'
mom.text = '^name^'
for x in range(^Char( total_items )^):
	print("""adding placeholder slides....
    """ + str(x + 1) + ' out of ^Char( total_items )^')
	p.slides.add_slide(p.slide_layouts[6])
]\"
);

After this it loops through folders of sample inspection images I have.  You could create your graphs and save them as jpg files.  The following code adds information from a conditions table, pulls only jpg files from the folders, and enhances some of the darker pictures before putting them into the slide.  The options are basically endless.

 

For Each( {v, i}, sub_folders,
	condition = Left( Right( v, 4 ), 2 );
	pycode ||= Eval Insert(
		"slid = p.slides[^Char( i )^]
slid1 = slid.placeholders[10]
slid2 = slid.placeholders[11]
slid3 = slid.placeholders[12]
slid4 = slid.placeholders[13]
slid5 = slid.placeholders[14]
slid6 = slid.placeholders[15]
slid7 = slid.placeholders[16]
slid8 = slid.placeholders[17]
slid.shapes.title.text = \!"\!"\!"^v || Try( \!":  \!" || cond_array[condition], \!"\!" )^\!"\!"\!"\!N"
	);
	pics = Filter Each( {value, index}, Files In Directory( thefolder || v ),
		And( Ends With( Lowercase( value ), "jpg" ), !Contains( value, "_APA_" ) )
	);
	pycode ||= Eval Insert(
		"slid1.insert_picture(r'^thefolder || v || \!"/\!" || pics[1]^')
slid2.insert_picture(r'^thefolder || v || \!"/\!" || pics[3]^')
img = Image.open(r'^thefolder || v || \!"/\!" || pics[5]^')
enh = ImageEnhance.Brightness(img)
img = enh.enhance(3)
img2 = io.BytesIO()
img.save(img2, 'JPEG')
slid3.insert_picture(img2)
img = Image.open(r'^thefolder || v || \!"/\!" || pics[7]^')
enh = ImageEnhance.Brightness(img)
img = enh.enhance(2)
img2 = io.BytesIO()
img.save(img2, 'JPEG')
slid4.insert_picture(img2)
slid5.insert_picture(r'^thefolder || v || \!"/\!" || pics[2]^')
slid6.insert_picture(r'^thefolder || v || \!"/\!" || pics[4]^')
img = Image.open(r'^thefolder || v || \!"/\!" || pics[6]^')
enh = ImageEnhance.Brightness(img)
img = enh.enhance(3)
img2 = io.BytesIO()
img.save(img2, 'JPEG')
slid7.insert_picture(img2)
img = Image.open(r'^thefolder || v || \!"/\!" || pics[8]^')
enh = ImageEnhance.Brightness(img)
img = enh.enhance(2)
img2 = io.BytesIO()
img.save(img2, 'JPEG')
slid8.insert_picture(img2)
print('^Char( i )^ of ^Char( Length( sub_folders ) )^ complete....')\!N"
	);
);
pycode ||= Eval Insert( "\[p.slides.add_slide(p.slide_layouts[4])
p.save(r'^pptx_savefile^')
]\" );

I use placeholders to simplify image insertion, but you can directly add images and specify the size and position.

View solution in original post

1 REPLY 1

Re: Export to Powerpoint

I started using python-pptx for presentations.  It is pretty capable, but the documentation is a little lacking.  I like to create PowerPoint layouts and save them as a generic presentation then use JMP windows with user inputs to build my Python code.

 

An example of the first part of one of my PowerPoint presentation scripts:

 

pycode = Eval Insert(
	"\[from pptx import Presentation
from PIL import Image, ImageEnhance
import io
p = Presentation(r'^template_path^')
slid = p.slides[0]
mom = slid.shapes[1]
slid.shapes.title.text = '^pres^'
mom.text = '^name^'
for x in range(^Char( total_items )^):
	print("""adding placeholder slides....
    """ + str(x + 1) + ' out of ^Char( total_items )^')
	p.slides.add_slide(p.slide_layouts[6])
]\"
);

After this it loops through folders of sample inspection images I have.  You could create your graphs and save them as jpg files.  The following code adds information from a conditions table, pulls only jpg files from the folders, and enhances some of the darker pictures before putting them into the slide.  The options are basically endless.

 

For Each( {v, i}, sub_folders,
	condition = Left( Right( v, 4 ), 2 );
	pycode ||= Eval Insert(
		"slid = p.slides[^Char( i )^]
slid1 = slid.placeholders[10]
slid2 = slid.placeholders[11]
slid3 = slid.placeholders[12]
slid4 = slid.placeholders[13]
slid5 = slid.placeholders[14]
slid6 = slid.placeholders[15]
slid7 = slid.placeholders[16]
slid8 = slid.placeholders[17]
slid.shapes.title.text = \!"\!"\!"^v || Try( \!":  \!" || cond_array[condition], \!"\!" )^\!"\!"\!"\!N"
	);
	pics = Filter Each( {value, index}, Files In Directory( thefolder || v ),
		And( Ends With( Lowercase( value ), "jpg" ), !Contains( value, "_APA_" ) )
	);
	pycode ||= Eval Insert(
		"slid1.insert_picture(r'^thefolder || v || \!"/\!" || pics[1]^')
slid2.insert_picture(r'^thefolder || v || \!"/\!" || pics[3]^')
img = Image.open(r'^thefolder || v || \!"/\!" || pics[5]^')
enh = ImageEnhance.Brightness(img)
img = enh.enhance(3)
img2 = io.BytesIO()
img.save(img2, 'JPEG')
slid3.insert_picture(img2)
img = Image.open(r'^thefolder || v || \!"/\!" || pics[7]^')
enh = ImageEnhance.Brightness(img)
img = enh.enhance(2)
img2 = io.BytesIO()
img.save(img2, 'JPEG')
slid4.insert_picture(img2)
slid5.insert_picture(r'^thefolder || v || \!"/\!" || pics[2]^')
slid6.insert_picture(r'^thefolder || v || \!"/\!" || pics[4]^')
img = Image.open(r'^thefolder || v || \!"/\!" || pics[6]^')
enh = ImageEnhance.Brightness(img)
img = enh.enhance(3)
img2 = io.BytesIO()
img.save(img2, 'JPEG')
slid7.insert_picture(img2)
img = Image.open(r'^thefolder || v || \!"/\!" || pics[8]^')
enh = ImageEnhance.Brightness(img)
img = enh.enhance(2)
img2 = io.BytesIO()
img.save(img2, 'JPEG')
slid8.insert_picture(img2)
print('^Char( i )^ of ^Char( Length( sub_folders ) )^ complete....')\!N"
	);
);
pycode ||= Eval Insert( "\[p.slides.add_slide(p.slide_layouts[4])
p.save(r'^pptx_savefile^')
]\" );

I use placeholders to simplify image insertion, but you can directly add images and specify the size and position.

Recommended Articles