Public class OperatExcel
{
Private File file = new File (ParamenterInit. SRCEXCELPATH );
Private File outfile = new File (ParamenterInit. DESTEXCELPATH );
Private static String sheetName = ParamenterInit. SHEETNAME;
Private static int column = Integer. parseInt (ParamenterInit. SHELLCOLUMN );
Private static int sqlcolumn = Integer. parseInt (ParamenterInit. SQLCOLUMN );
Public static void main (String args []) throws IOException, RowsExceededException, BiffException, WriteException {
OperatExcel op = new OperatExcel ();
Op. writeExcel ();
}
Public list readexcel () throws ioexception {
Inputstream in = new fileinputstream (File );
List list = new arraylist ();
Try {
Workbook book = Workbook. getworkbook (in );
Sheet sheet = book. getsheet (sheetname );
Cell cell [] = sheet. getcolumn (column );
For (cell C: cell ){
List. Add (C. getcontents (). Trim (). startswith ("/")? C. getcontents (). substring (1). Trim (): C. getcontents (). Trim ());
}
In. close ();
// In. close ();
} Catch (Exception ex ){
Ex. printStackTrace ();
}
Return list;
}
Public void writeExcel () throws IOException, BiffException, RowsExceededException, WriteException {
SimpleParser parser = new SimpleParser ();
Map sqlMap = parser. getSqlMap ();
Iterator it = sqlMap. keySet (). iterator ();
While (it. hasNext ()){
System. out. println ("key:" + it. next ());
System. out. println ("value:" + sqlMap. get (it. next ()));
}
List shellList = readExcel ();
InputStream is = new FileInputStream (file );
Workbook book = Workbook. getWorkbook (is );
FileOutputStream fileout = new FileOutputStream (outfile );
WritableWorkbook bookWrite = Workbook. createWorkbook (fileout, book );
WritableSheet ws = bookWrite. getSheet (sheetName );
Ws. setColumnView (sqlcolumn 300 );
Int columns = ws. getRows ();
For (int I = 0; I <columns; I ++ ){
If (sqlMap. get (shellList. get (I ))! = Null ){
Label label = new Label (sqlcolumn, I, (String) sqlMap. get (shellList. get (I )));
Ws. addCell (label );
}
}
BookWrite. write ();
BookWrite. close ();
Fileout. close ();
Is. close ();
}
}