Generate a Multipage Tiff from XLS

Hi,


I’m evaluating the Aspose library at the moment, because I want to transform XLS/XLSX to tif. I have successfully created an example, which uses the SheetRenderer to save it to PNG, …

Is there any way, to transform an Excel-File to a Multipage TIFF?

document.save(outputDirectory + filename + “.tiff”, FileFormatType.TIFF); is not working. It is saving the XLS/XLSX file with the ending TIFF, but under the hood it is the xls. (BTW: Should throw an error ;))

Bye,
Daniel

Hi,

Please try the following code, it will generate multiple tiff from xls/xlsx file.

Please use the latest version:
Aspose.Cells for Java (Latest Version)

Java


String path = “F:\Shak-Data-RW\Downloads\source.xlsx”;


Workbook wb = new Workbook(path);

ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();

imgOptions.setImageFormat(ImageFormat.getTiff());


String number = “”;


WorksheetCollection worksheets = wb.getWorksheets();


for(int idx = 0; idx<worksheets.getCount(); idx ++)

{

Worksheet sheet = worksheets.get(idx);


imgOptions.setHorizontalResolution(118);

imgOptions.setVerticalResolution(112);

imgOptions.setOnePagePerSheet(false);

imgOptions.setImageFitToPage(true);


SheetRender sr = new SheetRender(sheet, imgOptions);


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

{

if (i < 10)

{


number = “00” + i;


}


else if (i >= 10 && i < 100)

{


number = “0” + i;


}


else

{


number = “” + i;


}

sr.toImage(i, path + “_” + sheet.getIndex() + number +“.tiff”);

}//for

}//for



Hmmm, I’m still getting 0 byte TIFFs. I’m using exactly your code.


What do you use to write the TIFFs? ImageIO?

I tested yesterday, that ImageIO is not returning a Writer for TIFFs. If I’m using JAI with TIFFEncodeParams, I can use the SheetRenderer.toImage(Graphics2D, …) creating Single and Multipage Tiffs.

I’ve added now jai_imageio.jar to the classpath, so the TIFF writer will be found.


I still don’t understand, why PNG is working like a charm and tiff not. :wink:


Any ideas, what could be missing?

Hi,

Thanks for using Aspose.Cells for Java.

We have investigation this issue further and found, we do not support conversion to TIFF images at this moment.

However, we have added a request for this feature in our database. We will look into this feature and support it.

Once, this feature is available, we will let you know asap by posting on this thread.

Hi,

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

You should add JAI lib when convert excel to tiff.

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