title: R Save a excel workbook with password protection
body: <p>I'm a bit impressed because I couldn't find an answer so far.</p>
  
  <p>I have a small R script that is loading data from one source and writing a few dozens Excel files from it. The problem now is: those files need a password protection.</p>
  
  <p>Currently my script is using the <a href="https://cran.r-project.org/web/packages/XLConnect/index.html" rel="nofollow">XLConnect</a> library to save the excel files. The script is something like this:</p>
  
  <pre><code># Load data from source
  source = &lt;connection string to source&gt;
  dataFromSource = &lt;read from source&gt;
  
  # Process
  for (data in dataFromSource) {
      wb = loadWorkbook( paste("myWorkbook", sourceName, ".xlsx"), create = TRUE)
      createSheet(wb, name = "sheet")
      &lt;put data into the "sheet"&gt;
      saveWorkbook(wb)
  }
  </code></pre>
  
  <p>So, making it simple: <strong>how do I create an Excel file with password protection in R?</strong></p>