Skip to content

Instantly share code, notes, and snippets.

@conf8o
Last active March 25, 2021 02:17
Show Gist options
  • Save conf8o/5f588fb520e84023efc39111b32e35dc to your computer and use it in GitHub Desktop.
Save conf8o/5f588fb520e84023efc39111b32e35dc to your computer and use it in GitHub Desktop.
Excelワークブックのシートの列を取得
(ns micro-tools.excel
(:require [dk.ative.docjure.spreadsheet :as spreadsheet])
(:import [org.apache.poi.xssf.usermodel XSSFWorkbook XSSFSheet]
[java.lang String]))
(defrecord TableInfo [mapping sheet-name])
(defmulti table (fn [info obj] (class obj)))
(defmethod table XSSFSheet [info sheet]
(->> sheet
(spreadsheet/select-columns (:mapping info))))
(defmethod table XSSFWorkbook [info workbook]
(->> workbook
(spreadsheet/select-sheet (:sheet-name info))
(table info)))
(defmethod table String [info path]
(->> path
(spreadsheet/load-workbook)
(table info)))
(def table-info
(TableInfo.
{:A :first}
"sheet1"))
(defn run []
(table
table-info
"test.xlsx"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment