50 金钱
本帖最后由 tt0501 于 2014-5-13 15:49 编辑
Sub GetExcelFileForDailyReport()
'Session.CodePage = 950
'Response.Charset = "big5"
Server.ScriptTimeout=600
Dim SQL, Rs, fso
Dim filename, filepath, act
Dim ProductDate, IntervalId, Line, Moldel, LotNo, Brand, ReasonCategory, Remark, ProductTime, ManHour, PerHourQty, GoalQty, ActQty, QtyPercent, LostManHour, LostHourPercent
Dim strFilename, s, f, intFilelength
Dim rptStartDate, rptEndDate
rptStartDate = R_Date(Request.Form("rptStartDate"), 0)
rptEndDate = R_Date(Request.Form("rptEndDate"),0)
If rptStartDate > rptEndDate Then
ShowErrorMessage("The start date must be smaller than the deadline!")
Response.End
End If
Application("OutExcelSQL") = " SELECT * FROM Product_DailyReport_WorkOrder_View WHERE DATE = N'" & rptStartDate & "' "
'Response.Write(Application("OutExcelSQL"))
'Response.End
If Request.Form("btnOutExcelII") <> "" then
If Application("OutExcelSQL") <> "" then
Set Rs = Server.CreateObject("ADODB.RecordSet")
Rs.Open Application("OutExcelSQL"), gew, 1, 1
'沒有找到數據則提示并返回
If Rs.Eof Then
ShowErrorMessage("Sorry, No Data!")
Response.End
End If
filename = "GewProductReport(" & R_Date(Now,3) & ").xls"
set fso = CreateObject("Scripting.FileSystemObject")
filepath = Server.MapPath("excel/"&filename)
'Response.Write(filepath)
'Response.End
Application("filepath") = filepath
Set act = fso.CreateTextFile(filepath, true)
act.WriteLine("<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Strict//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"">")
act.WriteLine("<html xmlns=""http://www.w3.org/1999/xhtml"" xml:lang=""zh-TW"">")
act.WriteLine("<head><meta http-equiv=""content-type"" content=""text/html; charset=Big5"" /></head>")
act.Writeline("<body>")
act.Writeline("<TABLE border=1>")
act.Writeline("<TR>")
act.Writeline("<TD colspan=20 align=right style=font-size:14px;font-weight:bold>原因代碼:A</TD>")
act.Writeline("</TR> ")
act.Writeline("<TR>")
act.Writeline("<TD colspan=15 align=center style=font-size:22px;font-weight:bold>生產</TD>")
act.Writeline("<TD colspan=3 align=center style=font-size:22px;font-weight:bold>Production Date:"& rptStartDate &"</TD>")
act.Writeline("<td colspan=2></td>")
act.Writeline("</TR> ")
act.Writeline("<TR>")
act.Writeline("<TD RowSpan=2>LINE</TD>")
act.Writeline("<TD RowSpan=2>MODEL</TD>")
act.Writeline("<TD RowSpan=2>GEW MODEL</TD>")
act.Writeline("<TD RowSpan=2>BRAND</TD>")
act.Writeline("<TD RowSpan=2>LOT NO</TD>")
act.Writeline("<TD RowSpan=2>LOT QTY</TD>")
act.Writeline("<TD Colspan=3>DAILY PRODUCTION</TD>")
act.Writeline("<TD Colspan=3>Subtotal DAILY PRODUCTION</TD>")
act.Writeline("<TD Colspan=3>TOTAL QTY per LOT</TD>")
act.Writeline("<TD RowSpan=2>BALANCE</TD>")
act.Writeline("<TD RowSpan=2>人數</TD>")
act.Writeline("<TD RowSpan=2>原因代碼</TD>")
act.Writeline("<TD RowSpan=2>備註</TD>")
act.Writeline("<TD RowSpan=2>日期</TD>")
act.Writeline("</TR> ")
act.Writeline("<TR>")
act.Writeline("<TD>A.M.</TD>")
act.Writeline("<TD>P.M.</TD>")
act.Writeline("<TD>O.T.</TD>")
act.Writeline("<TD>PASS</TD>")
act.Writeline("<TD>REJ</TD>")
act.Writeline("<TD>IN PRD</TD>")
act.Writeline("<TD>COMPL</TD>")
act.Writeline("<TD>IN PRD</TD>")
act.Writeline("<TD>IN STORE</TD>")
act.Writeline("</TR> ")
While Not Rs.EOF
ProductDate = RemoveHtml(Rs("date"))
ProlineId = RemoveHtml(Rs("prolineId"))
Model = RemoveHtml(Rs("productId"))
Brand = RemoveHtml(Rs("Name"))
GewModel = RemoveHtml(Rs("GewModel"))
LotNo = RemoveHtml(Rs("approve_no"))
LotQty = RemoveHtml(Rs("approve_amount"))
AMQty = GewIntervalProQty(rptStartDate, ProlineId, LotNo, "AM")
PMQty = GewIntervalProQty(rptStartDate, ProlineId, LotNo, "PM")
OTQty = GewIntervalProQty(rptStartDate, ProlineId, LotNo, "OT")
ManHour = GewLineManHour(rptStartDate, ProlineId)
COMPL = GewCompleteProQty(rptStartDate, LotNo)
PASS = RemoveHtml(Rs("Pass_QTY"))
REJ = RemoveHtml(Rs("Rej_QTY"))
INPRD = RemoveHtml(Rs("Inprd_QTY"))
INSTORE = RemoveHtml(Rs("Cominstore_QTY"))
ReasonCode = RemoveHtml(Rs("Reason_Code"))
Remarks = RemoveHtml(Rs("Re_marks"))
CominprdQTY = RemoveHtml(Rs("Cominprd_QTY"))
TotalAMQty = TotalAMQty + AMQty
TotalPMQty = TotalPMQty + PMQty
TotalOTQty = TotalOTQty + OTQty
TotalManHour = TotalManHour + ManHour
act.WriteLine("<TR>")
act.WriteLine("<TD align=center>" & ProlineId & "</TD>")
act.WriteLine("<TD align=center>" & Model & "</TD>")
act.WriteLine("<TD align=center>" & GewModel & "</TD>")
act.WriteLine("<TD align=center>" & Brand & "</TD>")
act.WriteLine("<TD align=center>" & LotNo & "</TD>")
act.WriteLine("<TD align=center> " & LotQty & "</TD>")
act.WriteLine("<TD align=center>" & AMQty & "</TD>")
act.WriteLine("<TD align=center>" & PMQty & "</TD>")
act.WriteLine("<TD align=center>" & OTQty & "</TD>")
act.WriteLine("<TD align=center> " & PASS & " </TD>")
act.WriteLine("<TD align=center>"& REJ &"</TD>")
act.WriteLine("<TD align=center>"& INPRD &"</TD>")
act.WriteLine("<TD align=center>" & COMPL &"</TD>")
act.WriteLine("<TD align=center>"& INSTORE &"</TD>")
act.WriteLine("<TD align=center>"& CominprdQTY&"</TD>")
act.WriteLine("<TD align=center> </TD>")
act.WriteLine("<TD align=center>" & ManHour & "</TD>")
act.WriteLine("<TD align=center>"& ReasonCode &"</TD>")
act.WriteLine("<TD align=center>"& Remarks &"</TD>")
act.WriteLine("<TD align=center> </TD>")
act.WriteLine("</TR>")
Rs.MoveNext
Wend
act.WriteLine("<TR style=font-weight:bold>")
act.WriteLine("<TD Colspan=6> </TD>")
act.WriteLine("<TD align=center>" & TotalAMQty & "</TD>")
act.WriteLine("<TD align=center>" & TotalPMQty & "</TD>")
act.WriteLine("<TD align=center>" & TotalOTQty & "</TD>")
act.WriteLine("<TD align=center> </TD>")
act.WriteLine("<TD align=center> </TD>")
act.WriteLine("<TD align=center> </TD>")
act.WriteLine("<TD align=center> </TD>")
act.WriteLine("<TD align=center> </TD>")
act.WriteLine("<TD align=center> </TD>")
act.WriteLine("<TD align=center> </TD>")
act.WriteLine("<TD align=center>" & TotalManHour & "</TD>")
act.WriteLine("<TD align=center> </TD>")
act.WriteLine("<TD align=center> </TD>")
act.WriteLine("<TD align=center> </TD>")
act.WriteLine("</TR>")
Rs.close
Set Rs = Nothing
act.WriteLine("</table></body></html>")
act.close
ADODB.Recordset (0x800A0CC1)
在对应所需名称或序数的集合中,未找到项目。
/AppProline/proline.asp, 第 2336 行
PASS = RemoveHtml(Rs("Pass_QTY")) REJ = RemoveHtml(Rs("Rej_QTY"))
INPRD = RemoveHtml(Rs("Inprd_QTY"))
INSTORE = RemoveHtml(Rs("Cominstore_QTY"))
ReasonCode = RemoveHtml(Rs("Reason_Code"))
Remarks = RemoveHtml(Rs("Re_marks"))
CominprdQTY = RemoveHtml(Rs("Cominprd_QTY"))
就是这里 我刚加的 为什么会找不到 我 SQL表 里面 名字没错
我来回答