Changeset 7820 for lang/scala

Show
Ignore:
Timestamp:
03/12/08 02:01:59 (9 months ago)
Author:
ryugate
Message:

apache/POI.scala

setValue系:既にcellが存在する場合はそれを取得するようにした。

Location:
lang/scala/sandbox/src/jp/ryugate/apache
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/scala/sandbox/src/jp/ryugate/apache/POI.scala

    r7818 r7820  
    9797    } 
    9898 
     99    def getOrCreate(ci:int) = get(ci) match {                                   // index start from 1 
     100      case None    => hssf_row.createCell((ci-1).toShort) 
     101      case Some(v) => v 
     102    } 
     103 
    99104    def apply(cellnum:int) = get(cellnum) match { 
    100105      case None => throw new NoSuchElementException(cellnum + " (Cell not found)") 
     
    118123 
    119124    //-------------------------------------------- 
    120     def setCell(ci:int, value:String, encoding:Short):HSSFCell = {              // index start from 1 
    121       val cell = hssf_row.createCell((ci-1).toShort) 
     125    def setCell(ci:int, value:String, encoding:Short):HSSFCell = { 
     126      val cell = getOrCreate(ci) 
    122127      cell.setEncoding(encoding) 
    123128      cell.setCellValue(value) 
  • lang/scala/sandbox/src/jp/ryugate/apache/POISpecification.scala

    r7818 r7820  
    7373      bk.sheet(1) must notBeNull 
    7474      sheet.row(1).setCell(1,"hoge").setCellStyle(style)  
    75       sheet.col(2).setCell(2,"piyo").setCellStyle(style) 
     75      sheet.col(1).setCell(1,"piyo") 
    7676      sheet.setCell(3,3,"HOGE").setCellStyle(style) 
    7777