
### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###

  ## Example of input

  suppressPackageStartupMessages( library(XLConnect)   ) 

  ## Input files
  f.in <- ingest.p("file.xlsx")

  ## load in file
  wb <- loadWorkbook(f.in)

  ## Read in the sheets
  sheets <- getSheets(wb)

  ## remove any sheets not wanting to use.  For example. those starting with "_"
  sheets <- setdiff(sheets, extract("^_", sheets))

  results_per_sheet <- list()
  for (sheet in sheets) {

      ## Read in the worksheet data
      DT <- as.data.table(
                   readWorksheet(wb, sheet=sheet, check.names=FALSE)
            )

      ## grab the names of the columns
      nms <- names(DT)


      results_per_sheet[[sheet]] <- DT  # Or some functino of DT

  }

### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###


  ## Example of Output

  suppressPackageStartupMessages( library(XLConnect)   ) 
  
  f.out.xls <- out.p("TEST2", ext=".xlsx")


  # Load workbook (create if not existing)
  wb <- loadWorkbook(f.out.xls, create = TRUE)
  sheet <- "Sheet 1"

  # Create a worksheet called 'CO2'
  createSheet(wb, name=sheet)
   
  # Write built-in data set 'CO2' to the worksheet created above;
  # offset from the top left corner and with default header = TRUE
  writeWorksheet(wb, DT, sheet=sheet)

  ## Width units are 1/256th of a character
  setColumnWidth(wb, sheet=sheet, column=c(3, 7), width = 4000)

  # Save workbook (this actually writes the file to disk)
  saveWorkbook(wb)


  # -------
  .o(f.out.xls)



  # -----------
  # Shortcut
    writeWorksheetToFile(file=f.out.xls, data=DT, sheet="Sheet 1")

### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###
### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ###

