Row_ dCol_ Dim tempLastRange : tempLastRange getColNameUboundData_ 21 amp RowNum_ Dim BeginRow : BeginRow 1 if tempSheetTitle ltgt quotquot then BeginRow BeginRow 1 if tempTitleFirstLine true then BeginRow BeginRow 1 http://www.devdao.com/ if BeginRow1 then with Spreadsheet.RangequotA1:quotamp tempLastRange .Borders.LineStyle 1 .BorderAround -4119 -4138 设置外框 .NumberFormatLocal quotquot 文本格式 .Font.Bold False .Font.Italic False .Font.Size 10 .ShrinkToFittrue end with else with Spreadsheet.RangequotA1:quotamp tempLastRange .Borders.LineStyle 1 .BorderAround -4119 -4138 .ShrinkToFittrue end with with Spreadsheet.RangequotAquotamp BeginRow ampquot:quotamp tempLastRange .NumberFormatLocal quotquot .Font.Bold False .Font.Italic False .Font.Size 10 end with end if if tempTitleFirstLine true then BeginRow 1 if tempSheetTitle ltgt quotquot then BeginRow BeginRow 1 with Spreadsheet.RangequotAquotamp BeginRow ampquot:quotamp getColNameUboundData_ 21 amp BeginRow .NumberFormatLocal quotquot .Font.Bold True .Font.Italic False .Font.Size 12 .Interior.ColorIndex 37 .HorizontalAlignment 3 居中 .font.ColorIndex2 end with end if For iRow_ Line_ To RowNum_ For iCol_ 1 To UboundData_ 2 1 dCol_ iCol_ - 1 if tempSheetTitle ltgt quotquot then dRow_ iRow_ - 2 else dRow_ iRow_ - 1 If not IsNullData_dRow_ dCol_ then with Spreadsheet.CellsiRow_ iCol_ .Value Data_dRow_ dCol_ End with End If Next Next set Spreadsheet Nothing End Sub Rem 测试组件是否已经安装 Private Function IsObjInstalledstrClassString On Error Resume Next IsObjInstalled False Err 0 Dim xTestObj Set xTestObj Server.CreateObjectstrClassString If 0 Err Then IsObjInstalled True Set xTestObj Nothing Err 0 End Function Rem 取得数组维数 Private Function GetArrayDimByVal arr GetArrayDim Null Dim i_ temp If IsArrayarr Then For i_ 1 To 60 On Error Resume Next temp UBoundarr i_ If Err.Number ltgt 0 Then GetArrayDim i_ - 1 Err.Clear Exit Functio End If Next GetArrayDim i_ End If End Function Private Function GetNumFormatLocalDataType Select Case DataType Case quotCurrencyquot: GetNumFormatLocal quot0.00_0.00quot Case quotTimequot: GetNumFormatLocal quot-F800dddd mmmm dd yyyyquot Case quotCharquot: GetNumFormatLocal quotquot Case quotCommonquot: GetNumFormatLocal quotG/通用格式quot Case quotNumberquot: GetNumFormatLocal quot0.00_quot Case else : GetNumFormatLocal quotquot End Select End Function Public Sub AddDBDataByVal RsFlied ByVal FliedTitle ByVal tempSheetName_ ByVal tempSheetTitle_ DBTitle if RsFlied.Eof then Exit Sub Dim colNum_ : colNum_ RsFlied.fields.count Dim Rownum_ : Rownum_ RsFlied.RecordCount Dim ArrFliedTitle if DBTitle true then FliedTitle quotquot Dim ig_ For ig_0 to colNum_ - 1 FliedTitle FliedTitle amp RsFlied.fields.itemig_.name if ig_ ltgt colNum_ - 1 then FliedTitle FliedTitle ampquotquot Next end if if FliedTitleltgtquotquot then Rownum_ Rownum_ 1 ArrFliedTitle SplitFliedTitle quotquot if UboundArrFliedTitle ltgt colNum_ - 1 then InErrquot获取数据库表有误列数不符quot end if end if Dim tempData : ReDim tempDataRownum_ - 1 colNum_ - 1 Dim ix_ iy_ Dim iz if FliedTitleltgtquotquot then iz Rownum_ - 2 else iz Rownum_ - 1 For ix_ 0 To iz For iy_ 0 To colNum_ - 1 if FliedTitleltgtquotquot then if ix_0 then tempDataix_ iy_ ArrFliedTitleiy_ tempDataix_ 1 iy_ RsFliediy_ else tempDataix_ 1 iy_ RsFliediy_ end if else tempDataix_ iy_ RsFliediy_ end if Next RsFlied.MoveNext Next Dim tempFirstLine if FliedTitleltgtquotquot then tempFirstLine true else tempFirstLine false Call AddDatatempData tempFirstLine tempSheetName_ tempSheetTitle_ End Sub Public Sub AddDataByVal tempDate_ ByVal tempFirstLine_ ByVal tempSheetName_ ByVal tempSheetTitle_ if not isArrayExcelData then ExcelData tempDate_ TitleFirstLine tempFirstLine_ SheetName_ tempSheetName_ SheetTitle_ tempSheetTitle_ else if GetArrayDimExcelData 1 then Dim tempArrLen : tempArrLen UboundExcelDa ReDim Preserve ExcelDatatempArrLen ExcelDatatempArrLen tempDate_ ReDim Preserve TitleFirstLinetempArrLen TitleFirstLinetempArrLen tempFirstLine_ ReDim Preserve SheetName_tempArrLen SheetName_tempArrLen tempSheetName_ ReDim Preserve SheetTitle_tempArrLen SheetTitle_tempArrLen tempSheetTitle_ else Dim tempOldData : tempOldData ExcelData ExcelData ArraytempOldData tempDate_ TitleFirstLine ArrayTitleFirstLine tempFirstLine_ SheetName_ ArraySheetName_ tempSheetName_ SheetTitle_ ArraySheetTitle_ tempSheetTitle_ end if end if End Sub Rem 模板增加数据方法 Public Sub AddtDataByVal tempDate_ ByVal tempSheetName_ CreateType_ 2 if not isArrayExcelData then ExcelData ArraytempDate_ SheetName_ ArraytempSheetName_ else Dim tempArrLen : tempArrLen UboundExcelData1 ReDim Preserve ExcelDatatempArrLen ExcelDatatempArrLen tempDate_ ReDim Preserve SheetName_tempArrLen SheetName_tempArrLen tempSheetName_ End if End Sub Private Sub SetSheetsByVal Data_ DataId_ Dim Spreadsheet set Spreadsheet ExcelBook.SheetsSheetName_DataId_ Spreadsheet.Activate Dim ix_ For ix_ 0 To UboundData_ if not isArrayData_ix_ then InErrquot表数据载入有误数据格式错误quot if UboundData_ix_ ltgt 1 then InErrquot表数据载入有误数据格式错误quot Spreadsheet.RangeData_ix_0.value Data_ix_1 Next set Spreadsheet Nothing End Sub Public Function GetTimemsec_ Dim ReTime_ : ReTime_quotquot if msec_ lt 1000 then ReTime_ msec_ ampquotMSquot else Dim second_ second_ msec_ 1000 if msec_ mod 1000ltgt0 then msec_ msec_ mod 1000 ampquot毫秒quot else msec_ quotquot end if Dim n_ aryTime2 aryTimeunit2 aryTimeunit0 quot秒quot aryTimeunit1 quot分quot .
上一篇:
数据库开发入门与提高 第一章
下一篇:
那些令你为之触动的好句子,感慨万分