Free Support Forum - aspose.com

How to create TIF image by using Aspose.cells for Java

Hi,

I am trying to to render an excel file to tif image but fail, the tif files always have 0 byte. I can't find any Java example from the web so i put my code here. Am I missing something in the code? Your help is most appreciated

Workbook book = new Workbook("C:\\AsposeCell.xls");

//Create an object for ImageOptions

ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();

//Set the image type

imgOptions.setHorizontalResolution(500);

imgOptions.setVerticalResolution(500);

imgOptions.setTiffCompression(TiffCompression.COMPRESSION_NONE);

imgOptions.setImageFormat(ImageFormat.getTiff());

//Get the first worksheet.

Iterator iterator = book.getWorksheets().iterator();

int i = 0;

while(iterator.hasNext()) {

Worksheet sheet = iterator.next();

//Create a SheetRender object for the target sheet

SheetRender sr = new SheetRender(sheet, imgOptions);

for (int j = 0; j < sr.getPageCount(); j++) {

//Generate an image for the worksheet

sr.toImage(j, "C:\\AsposeCells" + i + "_" + j + ".tiff");

}

i++;

}

Hi,

Thanks for your sample code. Please also provide us your source xlsx file to further look into this issue.

We have looked into this issue and found the problem. It seems like there is some library missing in classpath.

We will investigate this issue and help/advise you asap.

This issue has been logged as CELLSJAVA-40360.

Below is a sample test code for your reference.

Java

String filePath = “F:\Shak-Data-RW\Downloads\source.xlsx”;
Workbook book = new Workbook(filePath);

// Create an object for ImageOptions
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();

// Set the image type
imgOptions.setHorizontalResolution(500);
imgOptions.setVerticalResolution(500);
imgOptions.setTiffCompression(TiffCompression.COMPRESSION_NONE);
imgOptions.setImageFormat(ImageFormat.getTiff());
for(int i=0; i<book.getWorksheets().getCount(); i++) {
Worksheet sheet = book.getWorksheets().get(i);
// Create a SheetRender object for the target sheet
SheetRender sr = new SheetRender(sheet, imgOptions);
for (int j = 0; j < sr.getPageCount(); j++) {
// Generate an image for the worksheet
sr.toImage(j, filePath + “AsposeCells” + i + “_” + j + “.tiff”);
}//inner for
}//outer for

Hi,

Thanks for your posting and using Aspose.Cells for Java.

After further investigation, we found, Aspose.Cells for Java does not support this feature i.e converting the worksheet into tiff images.

It is in our plan to implement this feature sometime in future, however we cannot support it soon. Once, this feature is supported, we will let you know by posting here.

We are sorry for the inconvenience caused.

Hi,

We have already supported converting excel to tiff in java version.

You should add JAI lib when you convert excel to tiff.

Please download and try this fix: Aspose.Cells for Java (Latest Version) and let us know your feedback.

The issues you have found earlier (filed as CELLSJAVA-40360) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.