1.2.3-SNAPSHOT permalink Arrow_down_16x16

save-xls

incanter.excel

  • (save-xls dataset filename & options)
Save a dataset to an Excel file.
Options are:
:sheet defaults to "dataset" if not provided.
:use-bold defaults to true. Set the header line in bold.

Examples:
(use '(incanter core datasets excel))
(save-xls (get-dataset :cars) "/tmp/cars.xls")

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source incanter/excel.clj:43 top

(defn ^{:doc "Save a dataset to an Excel file.
Options are:
:sheet defaults to \"dataset\" if not provided.
:use-bold defaults to true.  Set the header line in bold.

Examples:
  (use '(incanter core datasets excel))
  (save-xls (get-dataset :cars) \"/tmp/cars.xls\")

"}
  save-xls
  [^:incanter.core/dataset dataset  ^String filename  & options]
  (write-file
   (let [opts (when options (apply assoc {} options))
	 bold-header (or (:use-bold opts) true)
	 workbook-blob (let [w (HSSFWorkbook.)]
			 {:workbook w
			  :normal  (make-font true w)
			  :bold    (make-font false w)})
	 workbook-sheet (. (:workbook workbook-blob) createSheet (or (:sheet opts) "dataset"))
	 align-row (fn [row cols] (map #(get row %1) cols))]
     (write-line workbook-sheet 0 (:column-names dataset) (if bold-header (:bold workbook-blob) (:normal workbook-blob)))
     (do-loop
      #(write-line workbook-sheet %1 (align-row %2 (:column-names dataset)) (:normal workbook-blob))
      1
      (:rows dataset))
     (:workbook workbook-blob))
   filename))
Vars in incanter.excel/save-xls: defn let
Used in 0 other vars

Comments top

No comments for save-xls. Log in to add a comment.