Skip to content

Instantly share code, notes, and snippets.

@kanemu
Created October 9, 2013 05:13

Revisions

  1. kanemu created this gist Oct 9, 2013.
    21 changes: 21 additions & 0 deletions read_ods.groovy
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    @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()
    }
    }
    }