Issue saving images


#1

The following code fails:

 boolean npe = false;
    try {
        Workbook workbook = new Workbook(filePath);
        Worksheet worksheet = workbook.getWorksheets().get(1);
        int imageCounter = 0;
        for(int j=0; j<worksheet.getCharts().getCount(); j++) {
            Chart chart = worksheet.getCharts().get(j);

             String filename = MessageFormat.format("{0}{1}{2}_", "C", 1, imageCounter) + "fc336084-170a-4ce9-a7e3-673a9921f11d";
            String tempFileName = FileUtilities.getTempFile(filename, ".chart.png");
            chart.toImage(tempFileName, imgOptions);
            imageCounter++;
        }

     } catch (Exception e) {
        e.printStackTrace(System.err);
        npe = true;
    }

     p = Paths.get(s3Uris[1]);
    fileName = p.getFileName().toString();

     filePath = "/tmp/" + fileName;
    com.csdisco.process.utilities.Utilities.downloadFile(s3Uris[1], filePath);

     int notFound = 0;
    try {
        Set<String> outputFiles = new HashSet<>();
        int imageCounter = 0;
        Workbook workbook = new Workbook(filePath);
        Worksheet worksheet = workbook.getWorksheets().get(3);
        for(int j=0; j<worksheet.getSparklineGroupCollection().getCount(); j++) {
            SparklineGroup sparklineGroup = worksheet.getSparklineGroupCollection().get(j);

             for (int z = 0; z < sparklineGroup.getSparklineCollection().getCount(); z++) {
                Sparkline sparkline = sparklineGroup.getSparklineCollection().get(z);

                 String filename = MessageFormat.format("{0}{1}{2}_", "K", 3, imageCounter) + "fc336084-170a-4ce9-a7e3-673a9921f11d";
                String tempFileName = FileUtilities.getTempFile(filename, ".sparkline.png");

                 sparkline.toImage(tempFileName, imgOptions);
                imageCounter++;
                outputFiles.add(tempFileName);
            }
        }

         for (String outputFilename : outputFiles) {
            File f = new File(outputFilename);
            if(!f.exists()) {
                System.err.println("File Not found: " + f.getName());
                notFound++;
            }
        }

     }
    catch (Exception e){
        e.printStackTrace();
    }

     assertEquals("Chart NPE", false, npe);
    assertEquals("File Not Found", 0, notFound);

Files:



#2

@russ.nichols,
Thank you for writing to Aspose support team. This code seems to be taken from an existing project and contains many references and variables whose values are not known. Please provide us a standalone console application which can be directly executed without any error to reproduce the issue here. It will help us to observe the issue here and provide assistance accordingly.


#3

ISSUE WITH chart.toImage()

try {
    Workbook workbook = new Workbook(<PATH TO FILE - runtime-cells.xlsm>);
    Worksheet worksheet = workbook.getWorksheets().get(1);
    int imageCounter = 0;
    for(int j=0; j<worksheet.getCharts().getCount(); j++) {
        Chart chart = worksheet.getCharts().get(j);

         String filename = MessageFormat.format("{0}{1}{2}_", "C", 1, imageCounter);
        String tempFileName = FileUtilities.getTempFile(filename, ".chart.png");
        chart.toImage(tempFileName, imgOptions);
        imageCounter++;
    }

 } catch (Exception e) {
    e.printStackTrace(System.err);
}

#4

ISSUE WITH sparkline.toImage()

    Set<String> outputFiles = new HashSet<>();
    int imageCounter = 0;
    Workbook workbook = new Workbook(<PATH TO FILE - image-not-found.xlsx>);
    Worksheet worksheet = workbook.getWorksheets().get(3); //Make sure this is set to 3
    for(int j=0; j<worksheet.getSparklineGroupCollection().getCount(); j++) {
        SparklineGroup sparklineGroup = worksheet.getSparklineGroupCollection().get(j);
         for (int z = 0; z < sparklineGroup.getSparklineCollection().getCount(); z++) {
            Sparkline sparkline = sparklineGroup.getSparklineCollection().get(z);

             String filename = MessageFormat.format("{0}{1}{2}_", "K", 3, imageCounter);
            String tempFileName = FileUtilities.getTempFile(filename, ".sparkline.png");

             sparkline.toImage(tempFileName, imgOptions);
            imageCounter++;
            outputFiles.add(tempFileName);
        }
    }

//NOTE The above code claims to produce about 8000 output files, only 88 is actuality.

     for (String outputFilename : outputFiles) {
        File f = new File(outputFilename);
        if(!f.exists()) {
            System.err.println("File Not found: " + f.getName());
            notFound++;
        }
    }

#5

@ravikashyap,
We were able to observe the issues but we need to look into them more. We have logged the issues in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

 CELLSJAVA-42992 – Exception raised while converting XLSM to image
 CELLSJAVA-42993 – Wrong numbers shown while creating images from Sparkline

#6

@ravikashyap,

We evaluated the issue in details. This is not an issue with Aspose.Cells. We found some rows are not visible in spreadsheet (See attached picture), so they are not saved to images.
1.png (38.0 KB)


#7

@ravikashyap,

Please try our latest version/fix: Aspose.Cells for Java v19.8.3 (attached)

Your issue “CELLSJAVA-42992” should be fixed in it.

Let us know your feedback.
Aspose_Cells_Java_v19.8.3.zip (6.6 MB)


#8

When is Aspose.Cells 19.9 getting released?


#9

@ravikashyap,
Aspose.Cells for Java 19.9 will be released at the end of next week. You will be automatically notified once this release is published and available online for download.


#11

The problem is that the call sparkline.ToImage(tempFileName, imgOptions) fails silently and not create the tempfile when it sees some rows are not visible.
This is a bug, IMO. The call should throw an exception when it cannot process an invisible row.
Otherwise how can I know when something went wrong?


#12

@ravikashyap,
We have recorded this information with the logged ticket for our reference. I will write back here as soon as some feedback is ready to share.