Replacing shapes

Hello,
I’m writing you because during tests I observed that shapes on Chart were replaced. Please compare attached original document and result (aspose-cells.8.4.0 as well as aspose-cells.8.5.0)
Could you please check it?
Thank you in advance

Hi,

Thanks for your posting and using Aspose.Cells.

We have tested this issue with the following sample code using the latest version: Aspose.Cells
for Java v8.5.0.4
and found that although shape is not replaced but grid lines have disappeared.

I have attached the output excel file for your reference. Please check this issue with the latest version and let us know your feedback.

Java


String filePath = “F:\Shak-Data-RW\Downloads\2.xlsx”;


Workbook workbook = new Workbook(filePath);

workbook.save(filePath + “.out.xlsx”);

  1. I’ve tested it with Aspose.Cells
    for Java v8.5.0.4 before and now (don’t pay attention on symbols - the issue was already created in aspose db)

    2) I convert it in image file:
    public boolean convert() throws ConversionServiceException {
    prepare();//There the license is loaded
    // Set conversion start time
    synchronized (ExcelToPNGConverter.class) {
    ArrayList paths = new ArrayList();
    paths.add(getFontPath());
    if (javaHome != null && !javaHome.isEmpty()) {
    paths.add(javaHome + “/lib/fonts/”);
    }
    CellsHelper.setFontDirs(paths);
    }
    Workbook book = null;
    int sheetCount = 0;
    String uploadedFile = formatUploadedFile(inputFileName);
    try {
    synchronized (ExcelToPNGConverter.class) {
    book = new Workbook(uploadedFile, loadOptions);
    sheetCount = book.getWorksheets().getCount();
    }
    }
    catch (CellsException e) {
    }
    catch (Exception e) {
    }

    if (book.getSettings().isProtected()) {
    handleException(…);
    }

    if (sheetCount > getPageLimit()) {
    handleException(…);
    }

    // Track page numbers independent of sheet no.
    int filePgNo = 0;
    com.aspose.cells.Font font;
    ImageOrPrintOptions imgOptions = getImageOrPrintOptions();
    try {
    for (int i = 0; i < sheetCount; i++) {
    if (imgOptions.getOnePagePerSheet()) {
    imgOptions.setOnePagePerSheet(false);
    }
    Worksheet sheet = book.getWorksheets().get(i);
    if (sheet != null) {
    Cells cells = sheet.getCells();
    if (cells != null) {
    cells.setDefaultRowHeightMatched(true);
    }
    PageSetup pageSetup = sheet.getPageSetup();
    pageSetup.setPaperSize(PaperSizeType.PAPER_LEDGER); // 17 in. x 11 in.
    pageSetup.setPrintHeadings(true);
    pageSetup.setPrintGridlines(true);
    pageSetup.setOrientation(PageOrientationType.LANDSCAPE);
    pageSetup.setFitToPagesWide(1);
    pageSetup.setFitToPagesTall(0);
    pageSetup.setTopMargin(0.5);
    pageSetup.setLeftMargin(0.5);
    SheetRender sheetRender = new SheetRender(sheet, imgOptions);
    int pgCount = sheetRender.getPageCount();
    if (pgCount == 1) {
    imgOptions.setOnePagePerSheet(true);
    sheetRender = new SheetRender(sheet, imgOptions);
    }
    // Check if there are more than one page per sheet
    if (pgCount > 1) {
    for (int p = 0; p < pgCount; p++) {
    saveImageToFile(filePgNo, p, sheetRender);
    filePgNo++;
    }
    }
    else {
    saveImageToFile(filePgNo, -1, sheetRender);
    filePgNo++;
    }
    }
    }
    }
    catch (Exception e) {
    handleException(…);
    }

    return true;
    }


    private ImageOrPrintOptions getImageOrPrintOptions() {
    ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
    imgOptions.setImageFormat(ImageFormat.getPng());
    imgOptions.setHorizontalResolution(dpi_Resolution);
    imgOptions.setVerticalResolution(dpi_Resolution);
    imgOptions.setOnePagePerSheet(false);
    imgOptions.setPrintingPage(PrintingPageType.IGNORE_BLANK);
    return imgOptions;
    }

    private void saveImageToFile(int sheetIx, int pgIx, SheetRender sheetRender) throws Exception {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    if (pgIx > 0) {
    sheetRender.toImage(pgIx, baos);
    }
    else {
    sheetRender.toImage(0, baos);
    }
    baos.close();
    byte[] pngImageInBytes = baos.toByteArray();

    String processFileName = formatProcessFile(sheetIx, PNG_EXTENSION);
    writeToFile(processFileName, pngImageInBytes);
    }

    protected void writeToFile(String processFileName, byte[] imageInBytes) throws IOException {
    OutputStream fos = null;
    try {
    fos = new FileOutputStream(processFileName);
    if (fos != null) {
    fos.write(imageInBytes);
    }
    }
    catch (IOException e) {
    throw e;
    }
    finally {
    if (fos != null) {
    fos.close();
    }
    }
    }
    3) There is no one vertical grid lines. All of that are shapes. (“Lines” type)
    4) I’ve retested it saving in *.xlsx file. The same result as on your screenshot.
    BestRegards

Hi,

Thanks for your feedback and using Aspose.Cells.

We were able to observe this issue by executing the following code with the latest version: Aspose.Cells
for Java v8.5.0.4
. Shape is replaced and lines disappear when workbook is resaved or when the sheet is converted to image.

We have logged these issues in our database for investigation. We will look into them and fix these issues. Once these issues are resolved or we have some other update for you, we will let you know asap.

These issues have been logged as

  • CELLSJAVA-41413 - Shape is replaced and lines disappeared when chart is converted to image
  • CELLSJAVA-41414 - Lines disappeared from chart when xlsx file is resaved

I have attached the output excel file and the pdf which shows the converted image for a reference.

Java

String filePath = “F:\Shak-Data-RW\Downloads\2.xlsx”;


Workbook workbook = new Workbook(filePath);


PdfSaveOptions opts = new PdfSaveOptions();

opts.setOnePagePerSheet(true);


workbook.save(filePath + “.out.pdf”);

workbook.save(filePath + “.out.xlsx”);

@QAkane,

Sorry for the delay.

This is to inform you that the following ticket has been resolved:

  • CELLSJAVA-41414 - Lines disappeared from chart when xlsx file is resaved

We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

The issues you have found earlier (filed as CELLSJAVA-41414) have been fixed in Aspose.Cells for Java 18.5. Please also see the document for your reference: Installation|Documentation

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan

@QAkane
Please try our latest version aspose-cells-21.6-java
If you find any issue, please provide the source Excel file to help us analyze it.