Convert Excel to TIFF using Stream

Hi,

I am trying to use Aspose cells to convert excel file to TIFF format in Java.

I want the input to be a InputStream and output as a Stream too.

Any code examples to perform this is appreciated.

Here is what I use right now.. but I need input and output to be streams.

Workbook workbook = new Workbook(fileName);

workbook.save(outDir + fileName + ".tiff", SaveFormat.TIFF);


Thank You.

Hi Tashni,


Thank you for using Aspose products.

Please refer to the detailed article on Converting Worksheets to Images, and amend the code to render the worksheets in TIFF image format using the ImageOrPrintOptions.setImageFormat method.

Please feel free to write back in case you need our further assistance.

Hi,

The code example shows that I have to convert the workbook, one worksheet at a time. but I need to convert the complete workbook to a single TIFF image using OutputStream

Hi again,


Please use the WorkbookRender instead as demonstrated below.

Java

Workbook excel = new Workbook(myDir + “Book1.xlsx”);
ImageOrPrintOptions options = new ImageOrPrintOptions();
options.setImageFormat(ImageFormat.getTiff());
WorkbookRender render = new WorkbookRender(excel,options);
render.toImage(myDir + “output.tiff”);
// render.toImage(OutputStream stream);

Please note, WorkbookRender.toImage has an overload version that accepts an object of OutputStream, whereas Workbook constructor can be initiated with an object of InputStream to fulfill your requirement.

Note, you have add the reference of jai_imageio.jar in your project to run the above code correctly.

Thank You. It worked

Hi Tashni,


Thank you for the confirmation. Please feel free to write back in case you need our further assistance with Aspose APIs.