@@ -11,10 +11,12 @@ Date Author Change
1111 6/4/2022 EPPlus Software AB ExcelTable Html Export
1212 *************************************************************************************************/
1313using OfficeOpenXml . Core ;
14+ using OfficeOpenXml . Drawing ;
1415using OfficeOpenXml . Drawing . Interfaces ;
1516using OfficeOpenXml . Export . HtmlExport . Accessibility ;
1617using OfficeOpenXml . Export . HtmlExport . HtmlCollections ;
1718using OfficeOpenXml . Export . HtmlExport . Parsers ;
19+ using OfficeOpenXml . Export . HtmlExport . Translators ;
1820using OfficeOpenXml . Table ;
1921using OfficeOpenXml . Utils ;
2022using OfficeOpenXml . Utils . String ;
@@ -381,6 +383,24 @@ protected void AddContent(ExcelRangeBase cell, HTMLElement contentElement)
381383 }
382384 }
383385
386+
387+ private object GetContentType ( ePictureType type )
388+ {
389+ switch ( type )
390+ {
391+ case ePictureType . Ico :
392+ return "image/vnd.microsoft.icon" ;
393+ case ePictureType . Jpg :
394+ return "image/jpeg" ;
395+ case ePictureType . Svg :
396+ return "image/svg+xml" ;
397+ case ePictureType . Tif :
398+ return "image/tiff" ;
399+ default :
400+ return $ "image/{ type } ";
401+ }
402+ }
403+
384404 protected void AddImage ( HTMLElement parent , HtmlExportSettings settings , HtmlImage image , object value )
385405 {
386406 if ( image != null )
@@ -393,7 +413,18 @@ protected void AddImage(HTMLElement parent, HtmlExportSettings settings, HtmlIma
393413 {
394414 child . AddAttribute ( "id" , imageName ) ;
395415 }
396- child . AddAttribute ( "class" , $ "{ settings . StyleClassPrefix } image-{ name } { settings . StyleClassPrefix } image-prop-{ imageName } ") ;
416+
417+ if ( settings . Pictures . EmbedImagesInHtml )
418+ {
419+ ePictureType ? type ;
420+ var _encodedImage = ImageEncoder . EncodeImage ( image , out type ) ;
421+
422+ child . AddAttribute ( "src" , $ "data:{ GetContentType ( type . Value ) } ;base64,{ _encodedImage } ") ;
423+ }
424+ else
425+ {
426+ child . AddAttribute ( "class" , $ "{ settings . StyleClassPrefix } image-{ name } { settings . StyleClassPrefix } image-prop-{ imageName } ") ;
427+ }
397428 parent . _childElements . Add ( child ) ;
398429 }
399430 }
0 commit comments