Duffblog

前进一步,看看,需要前进更大一步才可以。

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  5 随笔 :: 53 文章 :: 5 评论 :: 0 Trackbacks
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
  int excelRowCount = 0;
  try{
   CommonCursor.setCursorBusy();
   String value = (String) (clipboard.getContents(this).getTransferData(DataFlavor.stringFlavor)); 
   if(value.indexOf("\t") == 0)
    value = value.replaceFirst("\t", " \t");
   while(value.indexOf("\t\t") >= 0){
    value = value.replace("\t\t", "\t \t");
   }
   value = value.replace("\n\t", "\n \t");
         StringTokenizer st1 = new StringTokenizer(value, "\n");
         excelRowCount = st1.countTokens();
         if(excelRowCount == 0)return;
         List<BidRouteInfo> pastedRouteInfos = new LinkedList<BidRouteInfo>();
         Date d = new Date();
         for (int i = 0; st1.hasMoreTokens(); i++) {
             BidRouteInfo routeInfo = new BidRouteInfo();
             routeInfo.setBidRouteInfoId(UUID.randomUUID().toString());
             routeInfo.setSeqNo(getMaxSequenceNo()+1);
             routeInfo.setRowStatus(BaseObject.ROWSTATUS_ADDED);
             bidHeader.addBidRouteInfo(routeInfo);
             pastedRouteInfos.add(routeInfo);
             String rowstring = st1.nextToken();
             StringTokenizer st2 = new StringTokenizer(rowstring, "\t");
             for (int j = 0; st2.hasMoreTokens(); j++) {
              String cellStr = (String) st2.nextToken();
              cellStr = cellStr.trim();
              cellStr = cellStr.toUpperCase();
              //第0列是隐藏的(冻结功能必须在有FixColumnHeader的情况下生效)
              switch( j ){
               case BidRouteFreightMode.POR_NAME-1:
                routeInfo.setPorName(cellStr);
                break;
               case BidRouteFreightMode.POR_STATE-1:
                routeInfo.setPorState(cellStr);
                break;
               case BidRouteFreightMode.POL_MODE-1:
                routeInfo.setPorPolMode(cellStr);
                break;
               case BidRouteFreightMode.POL_NAME-1:
                routeInfo.setPolName(cellStr);
                break;
               case BidRouteFreightMode.POD_NAME-1:
                routeInfo.setPodName(cellStr);
                break;
               case BidRouteFreightMode.DEST_NAME-1:
                routeInfo.setDestName(cellStr);
                break; 
               case BidRouteFreightMode.STATE-1:
                routeInfo.setStateCode(cellStr);
                break;
               case BidRouteFreightMode.POD_MODE-1:
                routeInfo.setPodDestMode(cellStr);
                break; 
              }
             }
            }
posted on 2006-09-25 22:45 追球者 阅读(1919) 评论(0)  编辑  收藏 所属分类: Java

只有注册用户登录后才能发表评论。


网站导航: