exportHtml modified for exception handling