Skip to content

Instantly share code, notes, and snippets.

@kanemu
Created October 9, 2013 05:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kanemu/6896524 to your computer and use it in GitHub Desktop.
Save kanemu/6896524 to your computer and use it in GitHub Desktop.
[groovy]groovyでodsを読む
@Grab('org.jopendocument:jOpenDocument:latest.release')
import org.jopendocument.dom.spreadsheet.*
def odsPath = '/Users/kanemu/Desktop/画像整理.ods'
def odsFile = new File(odsPath)
def odsDoc = SpreadSheet.createFromFile(odsFile)
def odsSheetLastIndex = odsDoc.getSheetCount()-1
MutableCell cell = null
for(int i in 0..odsSheetLastIndex){
def odsSheet = odsDoc.getSheet(i)
int colLastIndex = odsSheet.getColumnCount()-1
int rowLastIndex = odsSheet.getRowCount()-1
for(int r in 0..rowLastIndex){
for(int c in 0..4){
cell = odsSheet.getCellAt(c, r);
println cell.getValue()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment