Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Printing Excel File programmatically

807603Nov 15 2007 — edited Nov 15 2007
Hi,

Can any body help me in printing an excel file with java

I tried executing the below code.

DocFlavor format = new DocFlavor("application/octet-stream", "java.io.FileInputStream");
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(MediaSizeName.ISO_A4);
aset.add(new Copies(1));
PrintService pservices = rintServiceLookup.lookupDefaultPrintService();
DocPrintJob djob = pservices.createPrintJob();
FileInputStream input = new FileInputStream("Test.xls");
Doc doc = new SimpleDoc(input, format, null);
djob.print(doc, aset);


it prints the file if it a plain text file,if i try to print Excel File it is printing some weird characters.

Can anybody help me in this ASAP?

-- Sowmya
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 13 2007
Added on Nov 15 2007
2 comments
2,049 views