在线
客服

在线客服
尊敬的客户,我们24小时竭诚为您服务 公司总机: 0755-83312037 (32条线)

客服
热线

0755-83312037 (32条线)
7*24小时客服服务热线

?

关注
微信

关注官方微信
TOP

返回
顶部

ASP实例代码:asp操作Excel类

发布时间:2019-04-13浏览次数:986 <p> </p> <table style="BORDER-RIGHT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0"><tbody><tr> <td style="WORD-WRAP: break-word" bgcolor="#fdfddf"> <font color="#ff0000">WebjxCom提示:</font><font color="#000000">ASP实例代码:asp操作Excel类.</font> </td> </tr></tbody></table> <p><strong>asp操作Excel类</strong>:</p> <p><span class="code">&lt;%<br>'*******************************************************************<br>'使用说明<br>'Dim a<br>'Set a=new CreateExcel<br>'a.SavePath="x" '保存路径<br>'a.SheetName="工作簿名称"&#160; &#160;&#160;&#160;&#160;&#160;'多个工作表 a.SheetName=array("工作簿名称一","工作簿名称二")<br>'a.SheetTitle="表名称" &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;'可以为空&#160;&#160;多个工作表 a.SheetName=array("表名称一","表名称二")<br>'a.Data =d '二维数组 &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;'多个工作表 array(b,c) b与c为二维数组<br>'Dim rs<br>'Set rs=server.CreateObject("Adodb.RecordSet")<br>'rs.open "Select id, classid, className from [class] ",conn, 1, 1<br>'a.AddDBData rs, "字段名一,字段名二", "工作簿名称", "表名称", &#160;&#160;&#160;&#160;true&#160; &#160; 'true自动获取表字段名<br>'a.AddData c, true , "工作簿名称", "表名称"&#160; &#160; 'c二维数组&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;true&#160;&#160;第一行是否为标题行<br>'a.AddtData e, "Sheet1"&#160; &#160;'按模板生成&#160;&#160;c=array(array("AA1", "内容"), array("AA2", "内容2"))<br>'a.Create()<br>'a.UsedTime&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;生成时间,毫秒数<br>'a.SavePath&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;保存路径<br>'Set a=nothing<br>'设置COM组件的操作权限。在命令行键入“DCOMCNFG”,则进入COM组件配置界面,选择MicrosoftExcel后点击属性按钮,将三个单选项一律选择自定义,编辑中将Everyone加入所有权限<br>'*******************************************************************<br>Class CreateExcel <br>&#160;&#160;&#160;&#160;Private CreateType_<br>&#160;&#160;&#160;&#160;Private savePath_<br>&#160;&#160;&#160;&#160;Private readPath_<br>&#160;&#160;&#160;&#160;Private AuthorStr&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Rem 设置作者<br>&#160;&#160;&#160;&#160;Private VersionStr&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Rem 设置版本<br>&#160;&#160;&#160;&#160;Private SystemStr&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Rem 设置系统名称<br>&#160;&#160;&#160;&#160;Private SheetName_ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Rem 设置表名<br>&#160;&#160;&#160;&#160;Private SheetTitle_ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Rem 设置标题<br>&#160;&#160;&#160;&#160;Private ExcelData &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Rem 设置表数据<br>&#160;&#160;&#160;&#160;Private ExcelApp &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Rem Excel.Application<br>&#160;&#160;&#160;&#160;Private ExcelBook<br>&#160;&#160;&#160;&#160;Private ExcelSheets<br>&#160;&#160;&#160;&#160;Private UsedTime_&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Rem 使用的时间<br>&#160;&#160;&#160;&#160;Public TitleFirstLine&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Rem 首行是否标题<br>&#160;&#160;&#160;&#160;Private Sub Class_Initialize()<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Server.ScriptTimeOut = 99999<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;UsedTime_ = Timer<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;SystemStr&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;=&#160;&#160;&#160;&#160;"Lc00_CreateExcelServer"<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;AuthorStr&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;=&#160;&#160;&#160;&#160;"Surnfu&#160;&#160;surnfu@126.com&#160;&#160;31333716"<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;VersionStr&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;=&#160;&#160;&#160;&#160;"1.0"<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if not IsObjInstalled("Excel.Application") then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;InErr("服务器未安装Excel.Application控件")<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;set ExcelApp = createObject("Excel.Application")<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ExcelApp.DisplayAlerts = false<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ExcelApp.Application.Visible = false<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;CreateType_ = 1<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;readPath_ = null<br>&#160;&#160;&#160;&#160;End Sub <br><br>&#160;&#160;&#160;&#160;Private Sub Class_Terminate()<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ExcelApp.Quit<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;If Isobject(ExcelSheets) &#160;&#160;&#160;&#160;Then Set ExcelSheets&#160;&#160;&#160;&#160;=&#160;&#160;&#160;&#160;Nothing<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;If Isobject(ExcelBook) &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Then Set ExcelBook&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;=&#160;&#160;&#160;&#160;Nothing<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;If Isobject(ExcelApp) &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Then Set ExcelApp&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;=&#160;&#160;&#160;&#160;Nothing<br>&#160;&#160;&#160;&#160;End Sub <br><br>&#160;&#160;&#160;&#160;Public Property Let ReadPath(ByVal Val)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;If Instr(Val, ":\")&lt;&gt;0 Then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;readPath_ = Trim(Val)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;else<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;readPath_=Server.MapPath(Trim(Val))<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;End Property<br><br>&#160;&#160;&#160;&#160;Public Property Let SavePath(ByVal Val)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;If Instr(Val, ":\")&lt;&gt;0 Then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;savePath_ = Trim(Val)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;else<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;savePath_=Server.MapPath(Trim(Val))<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;End Property<br>&#160;&#160;&#160;&#160;<br>&#160;&#160;&#160;&#160;<br>&#160;&#160;&#160;&#160;Public Property Let CreateType(ByVal Val)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if Val &lt;&gt; 1 and Val &lt;&gt; 2 then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;CreateType_ = 1<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;else<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;CreateType_ = Val<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if&#160;&#160;&#160;&#160;<br>&#160;&#160;&#160;&#160;End Property<br>&#160;&#160;&#160;&#160;<br>&#160;&#160;&#160;&#160;Public Property Let Data(ByVal Val)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if not isArray(Val) then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;InErr("表数据设置有误")<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ExcelData = Val<br>&#160;&#160;&#160;&#160;End Property<br>&#160;&#160;&#160;&#160;Public Property Get SavePath()<br>&#160;&#160;&#160;&#160;SavePath = savePath_<br>&#160;&#160;&#160;&#160;End Property<br>&#160;&#160;&#160;&#160;Public Property Get UsedTime()<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;UsedTime = UsedTime_<br>&#160;&#160;&#160;&#160;End Property<br>&#160;&#160;&#160;&#160;Public Property Let SheetName(ByVal Val)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if not isArray(Val) then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if Val = "" then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;InErr("表名设置有误")<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;TitleFirstLine = true<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;else<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ReDim TitleFirstLine(Ubound(Val))<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim ik_<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;For ik_ = 0 to Ubound(Val)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;TitleFirstLine(ik_) = true<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Next<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;SheetName_ = Val<br>&#160;&#160;&#160;&#160;End Property<br>&#160;&#160;&#160;&#160;<br>&#160;&#160;&#160;&#160;Public Property Let SheetTitle(ByVal Val)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if not isArray(Val) then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if Val = "" then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;InErr("表标题设置有误")<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;SheetTitle_ = Val<br>&#160;&#160;&#160;&#160;End Property<br>&#160;&#160;&#160;&#160;<br>&#160;&#160;&#160;&#160;Rem 检查数据<br>&#160;&#160;&#160;&#160;Private Sub CheckData()<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if savePath_ = "" then InErr("保存路径不能为空")<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if not isArray(SheetName_) then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if SheetName_ = "" then InErr("表名不能为空")<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if CreateType_ = 2 then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if not isArray(ExcelData) then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;InErr("数据载入错误,或者未载入")<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Exit Sub<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if isArray(SheetName_) then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if not isArray(SheetTitle_) then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if SheetTitle_ &lt;&gt; "" then InErr("表标题设置有误,与表名不对应")<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if not IsArray(ExcelData) then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;InErr("表数据载入有误")<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if isArray(SheetName_) then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if GetArrayDim(ExcelData) &lt;&gt; 1 then InErr("表数据载入有误,数据格式错误,维度应该为一")<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;else<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if GetArrayDim(ExcelData) &lt;&gt; 2 then InErr("表数据载入有误,数据格式错误,维度应该为二")<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;End Sub<br>&#160;&#160;&#160;&#160;Rem 生成Excel<br>&#160;&#160;&#160;&#160;Public Function Create()<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Call CheckData()<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if not isnull(readPath_) then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ExcelApp.WorkBooks.Open(readPath_) <br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;else<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ExcelApp.WorkBooks.add<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;set ExcelBook = ExcelApp.ActiveWorkBook<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;set ExcelSheets = ExcelBook.Worksheets<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if CreateType_ = 2 then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim ih_<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;For ih_ = 0 to Ubound(ExcelData)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Call SetSheets(ExcelData(ih_), ih_)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Next<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ExcelBook.SaveAs savePath_<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;UsedTime_ = FormatNumber((Timer - UsedTime_)*1000, 3)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Exit Function<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if IsArray(SheetName_) then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim ik_<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;For ik_ = 0 to Ubound(ExcelData)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Call CreateSheets(ExcelData(ik_), ik_)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Next<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;else<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Call CreateSheets(ExcelData, -1)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ExcelBook.SaveAs savePath_<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;UsedTime_ = FormatNumber((Timer - UsedTime_)*1000, 3)<br>&#160;&#160;&#160;&#160;End Function <br>&#160;&#160;&#160;&#160;Private Sub CreateSheets(ByVal Data_, DataId_)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim Spreadsheet<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim tempSheetTitle<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim tempTitleFirstLine<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if DataId_&lt;&gt;-1 then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if DataId_ &gt; ExcelSheets.Count - 1 then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ExcelSheets.Add()<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;set Spreadsheet = ExcelBook.Sheets(1)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;else<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;set Spreadsheet = ExcelBook.Sheets(DataId_ + 1)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if isArray(SheetTitle_) then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;tempSheetTitle = SheetTitle_(DataId_)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;else<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;tempSheetTitle = ""<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;tempTitleFirstLine = TitleFirstLine(DataId_)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Spreadsheet.Name = SheetName_(DataId_)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;else<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;set Spreadsheet = ExcelBook.Sheets(1)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Spreadsheet.Name = SheetName_<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;tempSheetTitle = SheetTitle_<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;tempTitleFirstLine = TitleFirstLine<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim Line_ : Line_ = 1<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim RowNum_ : RowNum_ = Ubound(Data_, 1) + 1<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim LastCols_<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if tempSheetTitle &lt;&gt; "" then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;'Spreadsheet.Columns(1).ShrinkToFit=true '设定是否自动适应表格单元大小(单元格宽不变)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;LastCols_ = getColName(Ubound(Data_, 2) + 1)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;with Spreadsheet.Cells(1, 1)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.value = tempSheetTitle<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;'设置Excel表里的字体 <br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Font.Bold = True '单元格字体加粗<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Font.Italic = False '单元格字体倾斜<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Font.Size = 20 '设置单元格字号<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.font.name="宋体" '设置单元格字体<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;'.font.ColorIndex=2 '设置单元格文字的颜色,颜色可以查询,2为白色<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;End with<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;with Spreadsheet.Range("A1:"&amp; LastCols_ &amp;"1")<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.merge '合并单元格(单元区域)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;'.Interior.ColorIndex = 1 '设计单元络背景色<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.HorizontalAlignment = 3 '居中<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;End with<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Line_ = 2<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;RowNum_ = RowNum_ + 1<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim iRow_, iCol_<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim dRow_, dCol_<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim tempLastRange : tempLastRange = getColName(Ubound(Data_, 2)+1) &amp; (RowNum_)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim BeginRow : BeginRow = 1<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if tempSheetTitle &lt;&gt; "" then BeginRow = BeginRow + 1<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if tempTitleFirstLine = true then BeginRow = BeginRow + 1<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if BeginRow=1 then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;with Spreadsheet.Range("A1:"&amp; tempLastRange)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Borders.LineStyle = 1<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.BorderAround -4119, -4138 '设置外框<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.NumberFormatLocal = "@"&#160; &#160;'文本格式<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Font.Bold = False <br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Font.Italic = False <br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Font.Size = 10<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.ShrinkToFit=true <br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end with<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;else<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;with Spreadsheet.Range("A1:"&amp; tempLastRange)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Borders.LineStyle = 1<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.BorderAround -4119, -4138<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.ShrinkToFit=true <br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end with<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;with Spreadsheet.Range("A"&amp; BeginRow &amp;":"&amp; tempLastRange)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.NumberFormatLocal = "@" <br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Font.Bold = False <br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Font.Italic = False <br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Font.Size = 10<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end with<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if tempTitleFirstLine = true then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;BeginRow = 1<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if tempSheetTitle &lt;&gt; "" then BeginRow = BeginRow + 1<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;with Spreadsheet.Range("A"&amp; BeginRow &amp;":"&amp; getColName(Ubound(Data_, 2)+1) &amp; (BeginRow))<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.NumberFormatLocal = "@"<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Font.Bold = True <br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Font.Italic = False <br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Font.Size = 12<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Interior.ColorIndex = 37<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.HorizontalAlignment = 3 '居中<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.font.ColorIndex=2<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end with<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;For iRow_ = Line_ To RowNum_<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;For iCol_ = 1 To (Ubound(Data_, 2) + 1)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;dCol_ = iCol_ - 1<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if tempSheetTitle &lt;&gt; "" then dRow_ = iRow_ - 2 else dRow_ = iRow_ - 1<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;If not IsNull(Data_(dRow_, dCol_)) then <br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;with Spreadsheet.Cells(iRow_, iCol_)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;.Value = Data_(dRow_, dCol_)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;End with<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;End If <br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Next<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Next<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;set Spreadsheet = Nothing<br>&#160;&#160;&#160;&#160;End Sub <br>&#160;&#160;&#160;&#160;Rem 测试组件是否已经安装<br>&#160;&#160;&#160;&#160;Private Function IsObjInstalled(strClassString)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;On Error Resume Next<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;IsObjInstalled = False<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Err = 0<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim xTestObj<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Set xTestObj = Server.CreateObject(strClassString)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;If 0 = Err Then IsObjInstalled = True<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Set xTestObj = Nothing<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Err = 0<br>&#160;&#160;&#160;&#160;End Function<br>&#160;&#160;&#160;&#160;Rem 取得数组维数<br>&#160;&#160;&#160;&#160;Private Function GetArrayDim(ByVal arr)&#160; &#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;GetArrayDim = Null&#160; &#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim i_, temp&#160; &#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;If IsArray(arr) Then&#160;&#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;For i_ = 1 To 60&#160; &#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;On Error Resume Next&#160;&#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;temp = UBound(arr, i_)&#160; &#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;If Err.Number &lt;&gt; 0 Then&#160;&#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;GetArrayDim = i_ - 1<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Err.Clear <br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Exit Function&#160;&#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;End If&#160;&#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Next&#160;&#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;GetArrayDim = i_&#160; &#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;End If&#160;&#160;<br>&#160;&#160;&#160;&#160;End Function <br>&#160;&#160;&#160;&#160;Private Function GetNumFormatLocal(DataType)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Select Case DataType<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Case "Currency":<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;GetNumFormatLocal = "¥#,##0.00_);(¥#,##0.00)"<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Case "Time":<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;GetNumFormatLocal = "[$-F800]dddd, mmmm dd, yyyy"<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Case "Char":<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;GetNumFormatLocal = "@"<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Case "Common":<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;GetNumFormatLocal = "G/通用格式"<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Case "Number":<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;GetNumFormatLocal = "#,##0.00_"<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Case else :<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;GetNumFormatLocal = "@"<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;End Select<br>&#160;&#160;&#160;&#160;End Function<br>&#160;&#160;&#160;&#160;Public Sub AddDBData(ByVal RsFlied, ByVal FliedTitle, ByVal tempSheetName_, ByVal tempSheetTitle_, DBTitle)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if RsFlied.Eof then Exit Sub<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim colNum_ : colNum_ = RsFlied.fields.count<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim Rownum_ : Rownum_ = RsFlied.RecordCount<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim ArrFliedTitle<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if DBTitle = true then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;FliedTitle = ""<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim ig_<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;For ig_=0 to colNum_ - 1<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;FliedTitle = FliedTitle &amp; RsFlied.fields.item(ig_).name<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if ig_ &lt;&gt; colNum_ - 1 then FliedTitle = FliedTitle &amp;","<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Next<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if FliedTitle&lt;&gt;"" then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Rownum_ = Rownum_ + 1<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ArrFliedTitle = Split(FliedTitle, ",")<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if Ubound(ArrFliedTitle) &lt;&gt; colNum_ - 1&#160;&#160;then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;InErr("获取数据库表有误,列数不符")<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if&#160;&#160;&#160;&#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim tempData : ReDim tempData(Rownum_ - 1, colNum_ - 1)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim ix_, iy_<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim iz<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if FliedTitle&lt;&gt;"" then iz = Rownum_ - 2&#160;&#160;else iz = Rownum_ - 1<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;For ix_ = 0 To iz<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;For iy_ = 0 To colNum_ - 1<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if FliedTitle&lt;&gt;"" then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if ix_=0 then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;tempData(ix_, iy_) = ArrFliedTitle(iy_)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;tempData(ix_ + 1, iy_) = RsFlied(iy_)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;else<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;tempData(ix_ + 1, iy_) = RsFlied(iy_)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;else<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;tempData(ix_, iy_) = RsFlied(iy_)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Next<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;RsFlied.MoveNext<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Next<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim tempFirstLine <br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if FliedTitle&lt;&gt;"" then tempFirstLine = true else tempFirstLine = false<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Call AddData(tempData, tempFirstLine, tempSheetName_, tempSheetTitle_)<br>&#160;&#160;&#160;&#160;End Sub<br>&#160;&#160;&#160;&#160;Public Sub AddData(ByVal tempDate_, ByVal tempFirstLine_, ByVal tempSheetName_, ByVal tempSheetTitle_)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if not isArray(ExcelData) then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ExcelData = tempDate_<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;TitleFirstLine = tempFirstLine_<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;SheetName_ = tempSheetName_<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;SheetTitle_ = tempSheetTitle_<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;else<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if GetArrayDim(ExcelData) = 1 then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim tempArrLen : tempArrLen = Ubound(ExcelData)+1<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ReDim Preserve ExcelData(tempArrLen)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ExcelData(tempArrLen) = tempDate_<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ReDim Preserve TitleFirstLine(tempArrLen)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;TitleFirstLine(tempArrLen) = tempFirstLine_<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ReDim Preserve SheetName_(tempArrLen)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;SheetName_(tempArrLen) = tempSheetName_<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ReDim Preserve SheetTitle_(tempArrLen)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;SheetTitle_(tempArrLen) = tempSheetTitle_<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;else<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim tempOldData : tempOldData = ExcelData<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ExcelData = Array(tempOldData, tempDate_)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;TitleFirstLine = Array(TitleFirstLine, tempFirstLine_)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;SheetName_ = Array(SheetName_, tempSheetName_)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;SheetTitle_ = Array(SheetTitle_, tempSheetTitle_)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;End Sub<br>&#160;&#160;&#160;&#160;Rem 模板增加数据方法<br>&#160;&#160;&#160;&#160;Public Sub AddtData(ByVal tempDate_, ByVal tempSheetName_)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;CreateType_ = 2<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if not isArray(ExcelData) then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ExcelData = Array(tempDate_)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;SheetName_ = Array(tempSheetName_)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;else<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim tempArrLen : tempArrLen = Ubound(ExcelData)+1<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ReDim Preserve ExcelData(tempArrLen)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ExcelData(tempArrLen) = tempDate_<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ReDim Preserve SheetName_(tempArrLen)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;SheetName_(tempArrLen) = tempSheetName_<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;End if<br>&#160;&#160;&#160;&#160;End Sub<br>&#160;&#160;&#160;&#160;Private Sub SetSheets(ByVal Data_, DataId_)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim Spreadsheet<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;set Spreadsheet = ExcelBook.Sheets(SheetName_(DataId_))<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Spreadsheet.Activate<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim ix_<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;For ix_ =0 To Ubound(Data_)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if not isArray(Data_(ix_)) then InErr("表数据载入有误,数据格式错误")<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if Ubound(Data_(ix_)) &lt;&gt; 1 then InErr("表数据载入有误,数据格式错误")<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Spreadsheet.Range(Data_(ix_)(0)).value = Data_(ix_)(1)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Next<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;set Spreadsheet = Nothing<br>&#160;&#160;&#160;&#160;End Sub<br>&#160;&#160;&#160;&#160;Public Function GetTime(msec_)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim ReTime_ : ReTime_=""<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if msec_ &lt; 1000 then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ReTime_ = msec_ &amp;"MS"<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;else<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim second_<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;second_ = (msec_ \ 1000)<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if (msec_ mod 1000)&lt;&gt;0 then<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;msec_ = (msec_ mod 1000) &amp;"毫秒"<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;else<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;msec_ = ""<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end if<br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Dim n_, aryTime(2), aryTimeunit(2)<br>&#160;&#160;&#160;&#160;