pb_plan.Position:=0;<br> datai:=0;<br> dataj:=0;<br> for i:=1 to xlsapp.WorkSheets[x].UsedRange.Rows.Count do begin<br> pb_plan.Position:=round(i/xlsapp.worksheets[x].usedrange.rows.count*100);<br> application.processmessages;<br> for j:=1 to xlsapp.worksheets[x].usedrange.Columns.count do begin<br> if pos('計划',trim(xlsapp.worksheets[x].Cells.item[i,j].value))>0 then splan_biaoti:=trim(xlsapp.worksheets[x].Cells.Item[i,j].value);<br> dbgrid1.BringToFront;<br> if cpos('rev:',trim(xlsapp.worksheets[x].Cells.item[i,j].value))>0 then begin<br> splan_rev:=trim(xlsapp.worksheets[x].Cells.item[i,j+1].value);<br> datai:=i+2;<br> dataj:=j;<br> end;<br> if cpos('2007/',trim(xlsapp.worksheets[x].Cells.item[i,j].value))>0 then splan_date:=trim(xlsapp.worksheets[x].Cells.item[i,j].value);<br> lbl_biaoti.Caption:=splan_biaoti;<br><br> sinput_date:=datetostr(now);<br><br> if (i>=datai) and (datai>0) and (j>=dataj) then begin<br> xlsApp.ActiveSheet.Range[chr(j+64)+inttostr(i)].Select;<br> case j of<br> 2: sshift:= trim(xlsapp.activesheet.cells.item[xlsApp.Selection.Row,xlsApp.Selection.Column]);<br> 3: sline_name:= trim(xlsapp.activesheet.cells.item[xlsApp.Selection.Row,xlsApp.Selection.Column]);<br> 4: sserial_no:= trim(xlsapp.activesheet.cells.item[xlsApp.Selection.Row,xlsApp.Selection.Column]);<br> 5: sfpn:= trim(xlsapp.activesheet.cells.item[xlsApp.Selection.Row,xlsApp.Selection.Column]);<br> 6: swo:= trim(xlsapp.activesheet.cells.item[xlsApp.Selection.Row,xlsApp.Selection.Column]);<br> 7: sbatch:= trim(xlsapp.activesheet.cells.item[xlsApp.Selection.Row,xlsApp.Selection.Column]);<br> 8: sprod_qty:= trim(xlsapp.activesheet.cells.item[xlsApp.Selection.Row,xlsApp.Selection.Column]);<br> 9: scust:= trim(xlsapp.activesheet.cells.item[xlsApp.Selection.Row,xlsApp.Selection.Column]);<br> 10: sin_store_qty:= trim(xlsapp.activesheet.cells.item[xlsApp.Selection.Row,xlsApp.Selection.Column]);<br> 11: sremark:= trim(xlsapp.activesheet.cells.item[xlsApp.Selection.Row,xlsApp.Selection.Column]);<br> 12: sprod_abibity:= trim(xlsapp.activesheet.cells.item[xlsApp.Selection.Row,xlsApp.Selection.Column]);<br> 13: smanpower:= trim(xlsapp.activesheet.cells.item[xlsApp.Selection.Row,xlsApp.Selection.Column]);<br> end;<br> end;<br><br> end;<br><br> if (i>=datai) and (datai>0) and (sfpn<>'') then begin<br> qry1.close;<br> qry1.sql.Clear;<br> qry1.sql.Add(' insert into m_daily_plan (shift,line_name,serial_no,fpn,wo,batch,prod_qty,cust,in_store_qty,remark,prod_ability,manpower, ');<br> qry1.SQL.add(' plan_rev,plan_date,input_date,user_name)values( ');<br> qry1.SQL.add(' '+Quotedstr(sshift)+','+Quotedstr(sline_name)+','+Quotedstr(sserial_no)+','+Quotedstr(sfpn)+','+Quotedstr(swo)+','+Quotedstr(sbatch)+',');<br> qry1.SQL.add(' '+Quotedstr(sprod_qty)+' ,'+Quotedstr(scust)+','+Quotedstr(sin_store_qty)+','+Quotedstr(sremark)+', ');<br> qry1.SQL.add(' '+Quotedstr(sprod_abibity)+','+Quotedstr(smanpower)+','+Quotedstr(splan_rev)+',
lan_date,:input_date,'''+emp+''' 
');<br> qry1.Parameters.ParamByName('plan_date').Value:=strtodate(splan_date);<br> qry1.Parameters.ParamByName('input_date').value:=now;<br> qry1.execsql;<br> application.ProcessMessages;<br> end;<br> end;