title: java create multiple excel files
body: <p>How to create multiple excel files and open for user to download. I am using next code for one, if I do it again , one after the other, I get two excels, but both are the one that is created second.</p>
  <p>code to create first excel</p>
  <pre><code>GotrPersClass gotrPersClas = ...;
  try {
      FileResource res;
      res = ReportTakeAway.generateCustomExcel1(gotrPersClas, office, dateF, dateT);
      if (res != null) {
          setResource(&quot;dlexcel&quot;, res);
          ResourceReference rr = ResourceReference.create(res, this, &quot;dlexcel&quot;);
          getUI().getPage().open(rr.getURL(), &quot;_blank&quot;, false);
      }
  }
  catch (Exception e) {
  }
  </code></pre>
  <p>code to create second excel</p>
  <pre><code>List&lt;Map&lt;String, Object&gt;&gt; rs = ...;
  try {
      FileResource resClass;
      resClass = ReportTakeAway.generateCustomExcel2(rs, office, dateF, dateT);
  
      if (resClass != null) {
          setResource(&quot;dlexcel&quot;, resClass);
          ResourceReference rr = ResourceReference.create(resClass, this, &quot;dlexcel&quot;);
          getUI().getPage().open(rr.getURL(), &quot;_blank&quot;, false);
  
      }
  }
  catch (Exception e) {
  }
  </code></pre>
  <p>both codes are one after another</p>
  <p>found <a href="https://stackoverflow.com/questions/60951455/loop-through-a-list-to-create-multiple-excel-files">this link</a>, but is not for java:</p>