【asp源码栏目提醒】:本文主要为网学会员提供“ASP操作EXECL类 - 中学课件”,希望对需要ASP操作EXECL类 - 中学课件网友有所帮助,学习一下!
程序代码 lt 使用说明 Dim a Set anew CreateExcel a.SavePathquotxquot 保存路径 a.SheetNamequot工作簿名称quot 多个工作表 a.SheetNamearrayquot工作簿名称一quotquot工作簿名称二quot a.SheetTitlequot表名称quot 可以为空 多个工作表 a.SheetNamearrayquot表名称一quotquot表名称二quot a.Data d 二维数组 多个工作表 arraybc b与c为二维数组 Dim rs Set rsserver.CreateObjectquotAdodb.RecordSetquot rs.open quotSelect id classid className from class quotconn 1 1 a.AddDBData rs quot字段名一字段名二quot quot工作簿名称quot quot表名称quot true true自动获取表字段名 a.AddData c true quot工作簿名称quot quot表名称quot c二维数组 true 第一行是否为标题行 a.AddtData e quotSheet1quot 按模板生成 carrayarrayquotAA1quot quot内容quot arrayquotAA2quot quot内容2quot a.Create a.UsedTime 生成时间毫秒数 a.SavePath 保存路径 Set anothing 设置COM组件的操作权限。
在命令行键入“DCOMCNFG”则进入COM组件配置界面选择MicrosoftExcel后点击属性按钮将三个单选项一律选择自定义编辑中将Everyone加入所有权限 Class CreateExcel Private CreateType_ Private savePath_ Private readPath_ Private AuthorStr Rem 设置作者 Private VersionStr Rem 设置版本 Private SystemStr Rem 设置系统名称 Private SheetName_ Rem 设置表名 Private SheetTitle_ Rem 设置标题 Private ExcelData Rem 设置表数据 Private ExcelApp Rem Excel.Application Private ExcelBook Private ExcelSheets Private UsedTime_ Rem 使用的时间 Public TitleFirstLine Rem 首行是否标题 Private Sub Class_Initialize Server.ScriptTimeOut 99999 UsedTime_ Timer SystemStr quotLc00_CreateExcelServerquot AuthorStr quotSurnfu surnfu126.com 31333716quot VersionStr quot1.0quot if not IsObjInstalledquotExcel.Applicationquot then InErrquot服务器未安装Excel.Application控件quot end if set ExcelApp createObjectquotExcel.Applicationquot ExcelApp.DisplayAlerts false ExcelApp.Application.Visible false CreateType_ 1 readPath_ null End Sub Private Sub Class_Terminate ExcelApp.Quit If IsobjectExcelSheets Then Set ExcelSheets Nothing If IsobjectExcelBook Then Set ExcelBook Nothing If IsobjectExcelApp Then Set ExcelApp Nothing End Sub Public Property Let ReadPathByVal Val If readPath_ TrimVal else readPath_Server.MapPathTrimVal end if End Property Public Property Let SavePathByVal Val If InstrVal quot:quotltgt0 Then savePath_ TrimVal else savePath_Server.MapPathTrimVal end if End Property Public Property Let CreateTypeByVal Val if Val ltgt 1 and Val ltgt 2 then CreateType_ 1 else CreateType_ Val end if End Property Public Property Let DataByVal Val if not isArrayVal then InErrquot表数据设置有误quot end if ExcelData Val End Property Public Property Get SavePath SavePath savePath_ End Property Public Property Get UsedTime UsedTime UsedTime_ End Property Public Property Let SheetNameByVal Val if not isArrayVal then if Val quotquot then InErrquot表名设置有误quot end if TitleFirstLine true else ReDim TitleFirstLineUboundVal Dim ik_ For ik_ 0 to UboundVal TitleFirstLineik_ true Next end if SheetName_ Val End Property Public Property Let SheetTitleByVal Val if not isArrayVal then if Val quotquot then InErrquot表标题设置有误quot end if end if SheetTitle_ Val End Property Rem 检查数据 Private Sub CheckData if savePath_ quotqu