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;
}
}
}