Last active
March 25, 2021 02:17
-
-
Save conf8o/5f588fb520e84023efc39111b32e35dc to your computer and use it in GitHub Desktop.
Excelワークブックのシートの列を取得
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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