Failed to Get the Exact Image for the Data for Different Locale in Java

Hi! Aspose Team,
I have the requirement where in Korean locale, I am not able to get the exact image of the Worksheet along with the data for Korean locale in Embedded Ole Object image.
But once I open the embedded excel in PPT and close, then it is showing the proper data in the image.
Let me know if you need further details for the same.
thanks!

@Rohan_Wankar,
Thank you for contacting support.

Please check your results using the latest version of Aspose.Slides for Java if possible. If the issue persists, please share the following files and information:

  • sample presentation file
  • code example that reproduces the problem
  • output file
  • OS version on which the code was executed
  • JDK version in your app
  • Aspose.Slides version you used

Hi! @andrey.potapov
I tried with the snippet code.
It is not giving issue in local to charset-Encoding.
But when I deploy it to any of the env, it is not displaying the actual Korean characters in the OLE Image.
I have added the snippet code.
Please could you help me why it is behaving differrently in an env.

package com.nielsen.discover.aspose.chart;

import java.io.ByteArrayOutputStream;

import com.aspose.cells.BackgroundType;
import com.aspose.cells.BorderType;
import com.aspose.cells.Cell;
import com.aspose.cells.CellBorderType;
import com.aspose.cells.Cells;
import com.aspose.cells.Color;
import com.aspose.cells.ImageOrPrintOptions;
import com.aspose.cells.ImageType;
import com.aspose.cells.SheetRender;
import com.aspose.cells.Style;
import com.aspose.cells.TextAlignmentType;
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;
import com.aspose.slides.IOleEmbeddedDataInfo;
import com.aspose.slides.IOleObjectFrame;
import com.aspose.slides.ISlide;
import com.aspose.slides.OleEmbeddedDataInfo;
import com.aspose.slides.Presentation;
import com.nielsen.discover.model.table.Shade;

public class OleFrameForGrid {

  public static void main(String[] args) throws Exception {
    String dataDir = "D:\\AsposeSlides\\";
    Workbook workbook = new Workbook();
    
    Cells cells = workbook.getWorksheets().get(0).getCells();
    
    
    
    cells.get("A4").putValue("Emp id");
    Cell cell1 = cells.get("A4");
    Style style1 = cell1.getStyle();
    style1.getFont().setBold(true);
    style1.getFont().setSize(16);
    style1.getFont().setName("Arial");
    Color c = Color.getGray();
    style1.setBorder(BorderType.TOP_BORDER, CellBorderType.THIN, c);
    style1.setBorder(BorderType.BOTTOM_BORDER, CellBorderType.THIN, c);
    style1.setBorder(BorderType.LEFT_BORDER, CellBorderType.THIN, c);
    style1.setBorder(BorderType.RIGHT_BORDER, CellBorderType.THIN, c);
    style1.setForegroundColor(c);
    cell1.setStyle(style1);
    
    cells.get("B4").putValue("City");
    Cell cell2 = cells.get("B4");
    Style style2 = cell2.getStyle();
    style2.getFont().setBold(true);
    style2.getFont().setSize(16);
    style2.getFont().setName("Arial");
    style2.setBorder(BorderType.TOP_BORDER, CellBorderType.THIN, c);
    style2.setBorder(BorderType.BOTTOM_BORDER, CellBorderType.THIN, c);
    style2.setBorder(BorderType.LEFT_BORDER, CellBorderType.THIN, c);
    style2.setBorder(BorderType.RIGHT_BORDER, CellBorderType.THIN, c);
    style2.setForegroundColor(c);
    cell2.setStyle(style2);
    
    cells.get("C4").putValue("Name");
    Cell cell3 = cells.get("C4");
    Style style3 = cell3.getStyle();
    style3.getFont().setBold(true);
    style3.getFont().setSize(16);
    style3.getFont().setName("Arial");
    style3.setBorder(BorderType.TOP_BORDER, CellBorderType.THIN, c);
    style3.setBorder(BorderType.BOTTOM_BORDER, CellBorderType.THIN, c);
    style3.setBorder(BorderType.LEFT_BORDER, CellBorderType.THIN, c);
    style3.setBorder(BorderType.RIGHT_BORDER, CellBorderType.THIN, c);
    style3.setForegroundColor(c);
    cell3.setStyle(style3);
    
    cells.get("D4").putValue("Last Name");
    Cell cell4 = cells.get("D4");
    Style style4 = cell4.getStyle();
    style4.getFont().setBold(true);
    style4.getFont().setSize(16);
    style4.getFont().setName("Arial");
    style4.setBorder(BorderType.TOP_BORDER, CellBorderType.THIN, c);
    style4.setBorder(BorderType.BOTTOM_BORDER, CellBorderType.THIN, c);
    style4.setBorder(BorderType.LEFT_BORDER, CellBorderType.THIN, c);
    style4.setBorder(BorderType.RIGHT_BORDER, CellBorderType.THIN, c);
    style4.setForegroundColor(c);
    cell4.setStyle(style4);
    
    
    cells.get("E4").putValue("$");
    Cell cell5 = cells.get("E4");
    Style style5 = cell5.getStyle();
    style5.getFont().setBold(true);
    style5.getFont().setSize(16);
    style5.getFont().setName("Arial");
    style5.setBorder(BorderType.TOP_BORDER, CellBorderType.THIN, c);
    style5.setBorder(BorderType.BOTTOM_BORDER, CellBorderType.THIN, c);
    style5.setBorder(BorderType.LEFT_BORDER, CellBorderType.THIN, c);
    style5.setBorder(BorderType.RIGHT_BORDER, CellBorderType.THIN, c);
    style5.setHorizontalAlignment(TextAlignmentType.RIGHT);
    style5.setForegroundColor(c);
    cell5.setStyle(style5);
    
    
    cells.get("A5").putValue("코카콜라");
    cells.get("A6").putValue("코카콜라");
    cells.get("A7").putValue("ong Text needed");
    cells.get("A8").putValue("코카콜라");
    cells.get("A9").putValue("코카콜라");
    cells.get("A10").putValue("코카콜라");
    cells.get("A11").putValue("코카콜라");
    cells.get("A12").putValue("코카콜라");
    cells.get("A13").putValue("코카콜라");
    cells.get("A14").putValue("코카콜라");
    cells.get("A15").putValue("코카콜라");
    cells.get("A16").putValue("코카콜라");
    cells.get("A17").putValue("코카콜라");
    cells.get("A18").putValue("코카콜라");
    cells.get("A19").putValue("코카콜라");
    cells.get("A20").putValue("코카콜라");
    cells.get("A21").putValue("Long Text neede7");
    cells.get("A22").putValue("코카콜라");
    cells.get("A23").putValue("코카콜라");
    cells.get("A24").putValue("코카콜라");
    cells.get("A25").putValue("코카콜라");
    cells.get("A26").putValue("코카콜라");
    cells.get("A27").putValue("코카콜라");

    for(int i=1;i<=24;i++) {
      Cell cell = cells.get("A"+(i+4));
      Style style = cell.getStyle();
      style.setBorder(BorderType.TOP_BORDER, CellBorderType.THIN, c);
      style.setBorder(BorderType.BOTTOM_BORDER, CellBorderType.THIN, c);
      style.setBorder(BorderType.LEFT_BORDER, CellBorderType.THIN, c);
      style.setBorder(BorderType.RIGHT_BORDER, CellBorderType.THIN, c);
      style.setHorizontalAlignment(TextAlignmentType.LEFT);
      style.getFont().setName("Arial");
      style.getFont().setSize(11);
      
      
      
      cell.setStyle(style);


    }
    
    
    cells.get("B5").putValue("코카콜라");
    cells.get("B6").putValue("코카콜라");
    cells.get("B7").putValue("코카콜라");
    cells.get("B8").putValue("코카콜라");
    cells.get("B9").putValue("코카콜라");
    cells.get("B10").putValue("코카콜라");
    cells.get("B11").putValue("코카콜라");
    cells.get("B12").putValue("코카콜라");
    cells.get("B13").putValue("코카콜라");
    cells.get("B14").putValue("코카콜라");
    cells.get("B15").putValue("코카콜라");
    cells.get("B16").putValue("코카콜라");
    cells.get("B17").putValue("코카콜라");
    cells.get("B18").putValue("코카콜라");
    cells.get("B19").putValue("코카콜라");
    cells.get("B20").putValue("코카콜라");
    cells.get("B21").putValue("코카콜라");
    cells.get("B22").putValue("코카콜라");
    cells.get("B23").putValue("코카콜라");
    cells.get("B24").putValue("코카콜라");
    cells.get("B25").putValue("코카콜라");
    cells.get("B26").putValue("코카콜라");
    cells.get("B27").putValue("코카콜라");
    
    
    for(int i=1;i<=24;i++) {
      Cell cell = cells.get("B"+(i+4));
      Style style = cell.getStyle();
      style.setBorder(BorderType.TOP_BORDER, CellBorderType.THIN, c);
      style.setBorder(BorderType.BOTTOM_BORDER, CellBorderType.THIN, c);
      style.setBorder(BorderType.LEFT_BORDER, CellBorderType.THIN, c);
      style.setBorder(BorderType.RIGHT_BORDER, CellBorderType.THIN, c);
      style.setHorizontalAlignment(TextAlignmentType.LEFT);
      style.getFont().setSize(11);
      style.getFont().setName("Arial");

      
      
      cell.setStyle(style);


    }
    
    cells.get("C5").putValue("코카콜라");
    cells.get("C6").putValue("코카콜라");
    cells.get("C7").putValue("c3");
    cells.get("C8").putValue("코카콜라");
    cells.get("C9").putValue("e5");
    cells.get("C10").putValue("f6");
    cells.get("C11").putValue("코카콜라");
    cells.get("C12").putValue("h8");
    cells.get("C13").putValue("i9");
    cells.get("C14").putValue("코카콜라");
    cells.get("C15").putValue("k11");
    cells.get("C16").putValue("l12");
    cells.get("C17").putValue("코카콜라");
    cells.get("C18").putValue("n14");
    cells.get("C19").putValue("o15");
    cells.get("C20").putValue("o15s");
    cells.get("C21").putValue("코카콜라");
    cells.get("C22").putValue("o1ssss52");
    cells.get("C23").putValue("o1v545");
    cells.get("C24").putValue("코카콜라");
    cells.get("C25").putValue("코카콜라");
    cells.get("C26").putValue("ot15");
    cells.get("C27").putValue("코카콜라");
    
    for(int i=1;i<=24;i++) {
      Cell cell = cells.get("C"+(i+4));
      Style style = cell.getStyle();
      style.setBorder(BorderType.TOP_BORDER, CellBorderType.THIN, c);
      style.setBorder(BorderType.BOTTOM_BORDER, CellBorderType.THIN, c);
      style.setBorder(BorderType.LEFT_BORDER, CellBorderType.THIN, c);
      style.setBorder(BorderType.RIGHT_BORDER, CellBorderType.THIN, c);
      style.setHorizontalAlignment(TextAlignmentType.LEFT);
      style.getFont().setSize(11);
      style.getFont().setName("Arial");

      
      
      cell.setStyle(style);


    }
    
    cells.get("D5").putValue("코카콜라");
    cells.get("D6").putValue("코카콜라");
    cells.get("D7").putValue("코카콜라");
    cells.get("D8").putValue("r");
    cells.get("D9").putValue("s");
    cells.get("D10").putValue("코카콜라");
    cells.get("D11").putValue("u");
    cells.get("D12").putValue("v");
    cells.get("D13").putValue("코카콜라");
    cells.get("D14").putValue("x");
    cells.get("D15").putValue("코카콜라");
    cells.get("D16").putValue("z");
    cells.get("D17").putValue("ab");
    cells.get("D18").putValue("ac");
    cells.get("D19").putValue("a4d");
    cells.get("D20").putValue("adh");
    cells.get("D21").putValue("코카콜라");
    cells.get("D22").putValue("ad6");
    cells.get("D23").putValue("ad4");
    cells.get("D24").putValue("ad3");
    cells.get("D25").putValue("ad2");
    cells.get("D26").putValue("코카콜라");
    cells.get("D27").putValue("코카콜라");

    for(int i=1;i<=24;i++) {
      Cell cell = cells.get("D"+(i+4));
      Style style = cell.getStyle();
      style.setBorder(BorderType.TOP_BORDER, CellBorderType.THIN, c);
      style.setBorder(BorderType.BOTTOM_BORDER, CellBorderType.THIN, c);
      style.setBorder(BorderType.LEFT_BORDER, CellBorderType.THIN, c);
      style.setBorder(BorderType.RIGHT_BORDER, CellBorderType.THIN, c);
      style.setHorizontalAlignment(TextAlignmentType.LEFT);
      style.getFont().setSize(11);
      style.getFont().setName("Arial");

      
      
      cell.setStyle(style);


    }
    
    cells.get("E5").putValue(9678988800L);
    cells.get("E6").putValue(9678988800L);
    cells.get("E7").putValue(9678988800L);
    cells.get("E8").putValue(9678988800L);
    cells.get("E9").putValue(9678988800L);
    cells.get("E10").putValue(9678988800L);
    cells.get("E11").putValue(9678988800L);
    cells.get("E12").putValue(9678988800L);
    cells.get("E13").putValue(9678988800L);
    cells.get("E14").putValue(9678988800L);
    cells.get("E15").putValue(9678988800L);
    cells.get("E16").putValue(9678988800L);
    cells.get("E17").putValue(8678988800L);
    cells.get("E18").putValue(9678988800L);
    cells.get("E19").putValue(9678988800L);
    cells.get("E20").putValue(9678988800L);
    cells.get("E21").putValue(9678988800L);
    cells.get("E22").putValue(9678988800L);
    cells.get("E23").putValue(9678988800L);
    cells.get("E24").putValue(1000000000L);
    cells.get("E25").putValue(1000000000L);
    cells.get("E26").putValue(1000000000L);
    cells.get("E27").putValue(1000000000L);




    for(int i=1;i<=24;i++) {
      Cell cell = cells.get("E"+(i+4));
      Style style = cell.getStyle();
      style.setBorder(BorderType.TOP_BORDER, CellBorderType.THIN, c);
      style.setBorder(BorderType.BOTTOM_BORDER, CellBorderType.THIN, c);
      style.setBorder(BorderType.LEFT_BORDER, CellBorderType.THIN, c);
      style.setBorder(BorderType.RIGHT_BORDER, CellBorderType.THIN, c);
      style.getFont().setSize(11);
      style.getFont().setName("Arial");
      style.setHorizontalAlignment(TextAlignmentType.RIGHT);
      style.setVerticalAlignment(TextAlignmentType.TOP);
      Shade shade = new Shade();
      shade.setColor("#FDFDFD");
      ColourProvider d1 = new ColourProvider();
      Color d = d1.getColorFromShade(shade);
      style.setForegroundColor(d);
      style.setPattern(BackgroundType.SOLID);
      style.setIndentLevel(0);
      

      style.setCustom("₩#,##0;₩(#,##0)");
      
      cell.setStyle(style);

    }



    // set visible rows and columns count
    int chartRows = 25;
    int chartCols = 11;
    Worksheet dataSheet = workbook.getWorksheets().get(0);
    dataSheet.autoFitColumns();
    // Set chart print area
    dataSheet.getPageSetup().setPrintArea(dataSheet.getCells().get(0, 0).getName() + ":"
        + dataSheet.getCells().get(chartRows + 1, chartCols).getName());
    // Set chart ole size
    workbook.getWorksheets().setOleSize(0, chartRows, 0, chartCols);

    // Get the chart worksheet as an image
    ImageOrPrintOptions imageOptions = new ImageOrPrintOptions();
    imageOptions.setImageType(ImageType.EMF);
    imageOptions.setOnlyArea(false);
    imageOptions.setOnePagePerSheet(true);
    imageOptions.setAllColumnsInOnePagePerSheet(true);
    SheetRender sheetRender = new SheetRender(dataSheet, imageOptions);
    ByteArrayOutputStream imageStream = new ByteArrayOutputStream();
    sheetRender.toImage(0, imageStream);
    byte[] imageByteArray = imageStream.toByteArray();

    // Save the workbook to stream
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    workbook.save(bout, com.aspose.cells.SaveFormat.XLSX);

    // Create a presentation
    Presentation pres = new Presentation();
    ISlide sld = pres.getSlides().get_Item(0);
    

    // Add the workbook to the slide
    IOleEmbeddedDataInfo dataInfo = new OleEmbeddedDataInfo(bout.toByteArray(), "xlsx");
    IOleObjectFrame oof = sld.getShapes().addOleObjectFrame(1f, 1f,
        (float) pres.getSlideSize().getSize().getWidth() - 2,
        (float) pres.getSlideSize().getSize().getHeight() - 2, dataInfo);
    oof.getSubstitutePictureFormat().getPicture()
        .setImage(pres.getImages().addImage(imageByteArray));

    
    // Write the presentation to disk
    pres.save(dataDir+"Issue6.pptx", com.aspose.slides.SaveFormat.Pptx);
    System.out.println("File Generated");
}

  }


thanks!
Rohan

@Rohan_Wankar,

I tested your scenario/case using your sample code. It works fine on my end. First, I set region to “Korea” in OS (Windows10) settings. To check if the image itself is rendered fine, I simply added a line to your code to save the image to disk as well (via Aspose.Cells API):


// Get the chart worksheet as an image
ImageOrPrintOptions imageOptions = new ImageOrPrintOptions();
imageOptions.setImageType(ImageType.EMF);
imageOptions.setOnlyArea(false);
imageOptions.setOnePagePerSheet(true);
imageOptions.setAllColumnsInOnePagePerSheet(true);
SheetRender sheetRender = new SheetRender(dataSheet, imageOptions);
ByteArrayOutputStream imageStream = new ByteArrayOutputStream();
sheetRender.toImage(0, “f:\files\out1.emf”);
sheetRender.toImage(0, imageStream);
byte[] imageByteArray = imageStream.toByteArray();

files1.zip (57.2 KB)

Both image and output PPTX is Ok. I am using newer versions of the APIs.

Could you please zip and attach your output files (image file and PPTX) in Korean locale after processing your sample code? We will check your issue further.