How do I print an excel Workbook
without having it open in the background, using Java
?
Please note that I need to print all the sheets, not just the active one.
I have tried things like Desktop.print(FileName);
but that doesn't seem to work for all the sheets.
I am using the Apache POI API
to create Excel
files through Java
.
Many thanks!
UPDATE
To explain my problem a little more, I am using Apace POI
to print the Excel
file as -
HSSFSheet sheet = workbook.getSheet("Sheet5");
HSSFRow row21 = sheet.getRow((short)5);
row21.getCell((short)2).setCellValue(notcorrect);
desktop.print(new File(filename));
HSSFSheet sheet7 = workbook.getSheet("Sheet7");
HSSFRow row20 = sheet7.getRow((short)3);
row20.getCell((short)2).setCellValue(logreference);
row20.getCell((short)4).setCellValue(ISSUENUMBER);
desktop.print(new File(filename));
HSSFSheet sheet8 = workbook.getSheet("Sheet8");
HSSFRow row22 = sheet8.getRow((short)3);
row22.getCell((short)2).setCellValue(logreference);
row22.getCell((short)4).setCellValue(ISSUENUMBER);
desktop.print(new File(filename));
But this seems to work only for the active workbook
. If I have a workbook
in my Excel file
as the following -
The code above will only print the active sheet
i.e. sheet # 5
. How do I use Jexcel
to print Sheet 5, 6
AND 7
?
Many thanks!