Excel to TIFF options

I need to convert excel files to TIFF format.


1. How can i set the output to be 8bit or 24bit tiff file?

2. How can I set the color scheme (black/white, rgb, etc.)?

3. How can i set the Last page offset point to NULL?

Please clarify.

Thanks
Tashani

Hi Tashani,

Thanks for your posting and using Aspose.Cells.

We are afraid, you cannot set tiff to 8 or 24 bit in Java version but in .NET version you can set the Pixel format. However, if you need this feature, we will log a New Feature request in our database to support it in Aspose.Cells Java version.

You can control as Black/White, RGB color scheme using Tiff compression. You can also control which area to be output in tiff by setting the print area of worksheet.

Please see the following sample code and its comments. I have attached the source Excel file used in this code and output tiff image for your reference.

Java

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


//Create workbook object

Workbook workbook = new Workbook(filePath);


//Access first worksheet

Worksheet worksheet = workbook.getWorksheets().get(0);


//Set the print area as you want, it is not necessary

//This way you can control what portion of worksheet you want to print

worksheet.getPageSetup().setPrintArea(“A5:E10”);


//Control your image or print options

ImageOrPrintOptions opts = new ImageOrPrintOptions();

Hi,

Thank you for the info.
Yes, we do need to be able to set the output image to be 8bit or 24bit.

Thanks!

Hi Tashani,


Thank you for writing back.

You may use Aspose.Imaging for Java API to convert the Aspose.Cells generated TIFF images to your desired bits. Please check the following piece of code that converts a TIFF image to 24bits & 8bits.

Java

Image image = Image.load(inImage);
TiffOptions options = new TiffOptions();
options.setCompression(TiffCompressions.Lzw);

//Set 24 Bits Per Pixel
options.setPhotometric(TiffPhotometrics.Rgb);
options.setBitsPerSample(new int[]{8,8,8});
image.save(“D:/24bitsPerSample.tif”, options);

//Set 8 Bits Per Pixel
options.setPhotometric(TiffPhotometrics.MinIsBlack);
options.setBitsPerSample(new int[]{8});

image.save(“D:/8bitsPerSample.tif”, options);


Please feel free to write back in case you have any concerns.