欢迎来到天天文库
浏览记录
ID:50178583
大小:32.50 KB
页数:19页
时间:2020-03-04
《ASP导出Ecel数据的四种方法说明.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、ASP导出Excel数据的四种方法作者:佚名点击数:1948更新:2007-2-29:03:46热★★★【字体:小大】一、使用OWC 什么是OWC? OWC是OfficeWebCompent的缩写,即Microsoft的OfficeWeb组件,它为在Web中绘制图形提供了灵活的同时也是最差不多的机制。在一个intranet环境中,假如能够假设客户机上存在特定的扫瞄器和一些功能强大的软件(如IE5和Office2000),那么就有能力利用OfficeWeb组件提供一个交互式图形开发环境。这种模式下,客户端工作站将在整个任务中分担专门大的比重。<%Opti
2、onExplicitClassExcelGenPrivateobjSpreadsheetPrivateiColOffsetPrivateiRowOffsetSubClass_Initialize()SetobjSpreadsheet=Server.CreateObject("OWC.Spreadsheet")iRowOffset=2iColOffset=2EndSubSubClass_Terminate()SetobjSpreadsheet=Nothing'CleanupEndSubPublicPropertyLetColumnOffset(iColOff
3、)IfiColOff>0theniColOffset=iColOffElseiColOffset=2EndIfEndPropertyPublicPropertyLetRowOffset(iRowOff)IfiRowOff>0theniRowOffset=iRowOffElseiRowOffset=2EndIfEndPropertySubGenerateWorksheet(objRS)'PopulatestheExcelworksheetbasedonaRecordset'scontents'StartbydisplayingthetitlesIfobjRS
4、.EOFthenExitSubDimobjField,iCol,iRowiCol=iColOffsetiRow=iRowOffsetForEachobjFieldinobjRS.FieldsobjSpreadsheet.Cells(iRow,iCol).Value=objField.NameobjSpreadsheet.Columns(iCol).AutoFitColumns'设置Excel表里的字体objSpreadsheet.Cells(iRow,iCol).Font.Bold=TrueobjSpreadsheet.Cells(iRow,iCol).F
5、ont.Italic=FalseobjSpreadsheet.Cells(iRow,iCol).Font.Size=10objSpreadsheet.Cells(iRow,iCol).Halignment=2'居中iCol=iCol+1Next'objField'DisplayallofthedataDoWhileNotobjRS.EOFiRow=iRow+1iCol=iColOffsetForEachobjFieldinobjRS.FieldsIfIsNull(objField.Value)thenobjSpreadsheet.Cells(iRow,iC
6、ol).Value=""ElseobjSpreadsheet.Cells(iRow,iCol).Value=objField.ValueobjSpreadsheet.Columns(iCol).AutoFitColumnsobjSpreadsheet.Cells(iRow,iCol).Font.Bold=FalseobjSpreadsheet.Cells(iRow,iCol).Font.Italic=FalseobjSpreadsheet.Cells(iRow,iCol).Font.Size=10EndIfiCol=iCol+1Next'objFieldo
7、bjRS.MoveNextLoopEndSubFunctionSaveWorksheet(strFileName)'SavetheworksheettoaspecifiedfilenameOnErrorResumeNextCallobjSpreadsheet.ActiveSheet.Export(strFileName,0)SaveWorksheet=(Err.Number=0)EndFunctionEndClassDimobjRSSetobjRS=Server.CreateObject("ADODB.Recordset")objRS.Open"SELEC
8、T*FROMxxxx","Provider=SQLOLEDB.1;
此文档下载收益归作者所有