We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Chart Missing While Converting Excel to EMF Image

Hi Team,


In my excel (GraphMissing.xlsx) file a chart of bubble type exists.
Im trying to converting this xlsx to emf image.
In the generated emf image chart is missing.

Please find attached the java class used to convert xlsx to emf, xlsx file and also the generated emf files for your reference.

Note :
  • aspose-cells-16.12.0.jar has been used
Thanks in advance,
Sanjeev

Hi,


Thanks for your posting and using Aspose.Cells.

Please test the following sample code with the latest version: Aspose.Cells for Java (Latest Version) and it is working fine. I have attached the output emf image generated by your code for a reference.

Please comment this line in your original code or try the code as given below.

sr.toImage(0, imageStream);


Java
Workbook workbook = new Workbook(dirPath + “GraphMissing.xlsx”);

Worksheet sheet = workbook.getWorksheets().get(“Chart”);
if (null == sheet)
sheet = workbook.getWorksheets().get(0);
workbook.getWorksheets().setActiveSheetIndex(sheet.getIndex());

// Setup sheet
PageSetup pageSetup = sheet.getPageSetup();
pageSetup.setLeftMargin(0.0);
pageSetup.setRightMargin(0.0);
pageSetup.setTopMargin(0.0);
pageSetup.setBottomMargin(0.0);
pageSetup.setPaperSize(PaperSizeType.PAPER_A_4);
pageSetup.setOrientation(PageOrientationType.LANDSCAPE);
pageSetup.setFitToPagesWide(1);
pageSetup.setFitToPagesTall(1);
String printArea = pageSetup.getPrintArea();
Range printAreaRange = sheet.getCells().createRange(printArea);

ByteArrayOutputStream imageStream = null;
ImageOrPrintOptions imageOptions = new ImageOrPrintOptions();
imageOptions.setImageFormat(ImageFormat.getEmf());
imageOptions.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
imageOptions.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
// imageOptions.setOnePagePerSheet(isPptxOnePagePerSheetFlag());
imageOptions.setOnePagePerSheet(true);
imageOptions.setOnlyArea(true);
SheetRender sr = new SheetRender(sheet, imageOptions);
sr.toImage(0, dirPath + “output.emf”);