欢迎来到天天文库
浏览记录
ID:34721469
大小:91.68 KB
页数:19页
时间:2019-03-10
《access转excelandexcel导入access代码》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、Access转ExcelANDExcel导入Access代码JaAcc_Excel.Asp<%'**********************************************'CodebyASP导出EXCEL通用'修改引用By子言(JaStudio)'**********************************************DimxibuaDimmysqlxibua=Request.QueryString("ids")ifxibua="all"Thenmysql="selec
2、t*fromsingup"Elsemysql="select*fromsingupwhere[系部]='"&xibua&"'"EndIfserver.scripttimeout=100000'处理时间较长,设置值应大一点OnErrorResumeNextsetobjExcelApp=CreateObject("Excel.Application")objExcelApp.DisplayAlerts=falseobjExcelApp.Application.Visible=falseobjExcelApp.WorkBooks.addsetobjExcelBook=ob
3、jExcelApp.ActiveWorkBooksetobjExcelSheets=objExcelBook.WorksheetssetobjSpreadsheet=objExcelBook.Sheets(1)DimobjRSSetobjRS=Server.CreateObject("ADODB.Recordset")objRS.Openmysql,conn,1,3IfobjRS.EOFthenresponse.write("Error")respose.endEndifDimobjField,iCol,iRowiCol=1'取得列号iRow=1'取得行号objSp
4、readsheet.Cells(iRow,iCol).Value=""&xibua&"部的报名情况"'单元格插入数据objSpreadsheet.Columns(iCol).ShrinkToFit=true'设定是否自动适应表格单元大小(单元格宽不变)'设置Excel表里的字体objSpreadsheet.Cells(iRow,iCol).Font.Bold=True'单元格字体加粗objSpreadsheet.Cells(iRow,iCol).Font.Italic=False'单元格字体倾斜objSpreadsheet.Cells(iRow,iCol).Font
5、.Size=20'设置单元格字号objSpreadsheet.Cells(iRow,iCol).ParagraphFormat.Alignment=1'设置单元格对齐格式:居中objspreadsheet.Cells(iRow,iCol).font.name="宋体"'设置单元格字体objspreadsheet.Cells(iRow,iCol).font.ColorIndex=2'设置单元格文字的颜色,颜色可以查询,2为白色objSpreadsheet.Range("A1:F1").merge'合并单元格(单元区域)objSpreadsheet.Range("A1:
6、F1").Interior.ColorIndex=1'设计单元络背景色'objSpreadsheet.Range("A2:F2").WrapText=true'设置字符回卷(自动换行)iRow=iRow+1ForEachobjFieldinobjRS.Fields'objSpreadsheet.Columns(iCol).ShrinkToFit=trueobjSpreadsheet.Cells(iRow,iCol).Value=objField.Name'设置Excel表里的字体objSpreadsheet.Cells(iRow,iCol).Font.Bold=Tr
7、ueobjSpreadsheet.Cells(iRow,iCol).Font.Italic=FalseobjSpreadsheet.Cells(iRow,iCol).Font.Size=20objSpreadsheet.Cells(iRow,iCol).Halignment=2'居中iCol=iCol+1Next'objField'DisplayallofthedataDoWhileNotobjRS.EOFiRow=iRow+1iCol=1ForEachobjFieldinobjRS.FieldsIfIsNull(objField.Value)thenobjSp
此文档下载收益归作者所有