title: Printing entire Excel Workbook in java without opening the excel document
body: <p>How do I print an <code>excel Workbook</code> without having it open in the background, using <code>Java</code>? </p>
  
  <p>Please note that I need to print all the sheets, not just the active one. </p>
  
  <p>I have tried things like <code>Desktop.print(FileName);</code> but that doesn't seem to work for all the sheets. </p>
  
  <p>I am using the <code>Apache POI API</code> to create <code>Excel</code> files through <code>Java</code>.</p>
  
  <p>Many thanks! </p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>To explain my problem a little more, I am using <code>Apace POI</code> to print the <code>Excel</code> file as - </p>
  
  <pre><code>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));
  </code></pre>
  
  <p>But this seems to work only for the <code>active workbook</code>. If I have a <code>workbook</code> in my <code>Excel file</code> as the following - </p>
  
  <p><a href="https://i.stack.imgur.com/xB57g.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xB57g.png" alt="enter image description here"></a></p>
  
  <p>The code above will only print the <code>active sheet</code> i.e. <code>sheet # 5</code>. How do I use <code>Jexcel</code> to print <code>Sheet 5, 6</code> <strong>AND</strong> <code>7</code>? </p>
  
  <p>Many thanks! </p>