|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
缺点:正版成本价格贵(盗版就不说了)、不够安全,大多数服务器用windows系统,没有linux安全呵呵,这个是我先容制造EXECL的第三种办法了,关于OWC,我在后面的文章里也已有所先容,空话少说,请看代码:
<%
OptionExplicit
ClassExcelGen
PrivateobjSpreadsheet
PrivateiColOffset
PrivateiRowOffset
SubClass_Initialize()
SetobjSpreadsheet=Server.CreateObject("OWC.Spreadsheet")
iRowOffset=2
iColOffset=2
EndSub
SubClass_Terminate()
SetobjSpreadsheet=NothingCleanup
EndSub
PublicPropertyLetColumnOffset(iColOff)
IfiColOff>0then
iColOffset=iColOff
Else
iColOffset=2
EndIf
EndProperty
PublicPropertyLetRowOffset(iRowOff)
IfiRowOff>0then
iRowOffset=iRowOff
Else
iRowOffset=2
EndIf
EndProperty
SubGenerateWorksheet(objRS)
PopulatestheExcelworksheetbasedonaRecordsetscontents
Startbydisplayingthetitles
IfobjRS.EOFthenExitSub
DimobjField,iCol,iRow
iCol=iColOffset
iRow=iRowOffset
ForEachobjFieldinobjRS.Fields
objSpreadsheet.Cells(iRow,iCol).Value=objField.Name
iCol=iCol+1
NextobjField
Displayallofthedata
DoWhileNotobjRS.EOF
iRow=iRow+1
iCol=iColOffset
ForEachobjFieldinobjRS.Fields
IfIsNull(objField.Value)then
objSpreadsheet.Cells(iRow,iCol).Value=""
Else
objSpreadsheet.Cells(iRow,iCol).Value=objField.Value
EndIf
iCol=iCol+1
NextobjField
objRS.MoveNext
Loop
EndSub
FunctionSaveWorksheet(strFileName)
Savetheworksheettoaspecifiedfilename
OnErrorResumeNext
CallobjSpreadsheet.ActiveSheet.Export(strFileName,0)
SaveWorksheet=(Err.Number=0)
EndFunction
EndClass
%>
<%
DimobjRS
SetobjRS=Server.CreateObject("ADODB.Recordset")
objRS.Open"SELECT*FROMtitles","DSN=FooBar"
DimobjExcel
SetobjExcel=NewExcelGen
objExcel.RowOffset=4
objExcel.ColumnOffset=1
objExcel.GenerateWorksheet(objRS)
IfobjExcel.SaveWorksheet(Server.MapPath("foo.xls"))then
Response.Write"Worksheet</p>国内有些大的CRM厂商的ASP就写得不错.无论是概念还是它里面用JAVASCRIPT的能力.并不是说现在的程序员用了ASP.NET来写程序就可以说自己高档了 |
|