Friday, May 13, 2016

How to keep images inside Oracle SQL Developer explain plan HTML export file


If you need to share SQL statement explain plan output created by Oracle SQL Developer, you can export it to html file. You need to press F10 to create Explain Plan tab, then RMB click on it and choose "Export HTML".


Oracle SQL Developer creates html file and saves all icons into "images" subfolder nearby. Therefore if you decide to copy or share this html file you will need to keep those images with it, or they will be replaced with ugly "broken image" icons:


To target this huge problem I've created small windows cmd script. It appends necessary images as CSS resources to html file and change internal <IMG> references accordingly. It also changes font style to "small sans-serif" since i think that it looks better :). For this script to run you'll need a SED utility from unxutils. Script expects html file with explain plan as a 1st parameter. Optional 2nd parameter "noimg" removes all image references from html. Result (all images are inside HTML, images subfolder is not required to share your HTML):


Use it at your own risk! Have fun. :)

References: