| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1197 人关注过本帖, 1 人收藏
标题:VB 内容导出excel 如何设置居中
只看楼主 加入收藏
ttt96ttt
Rank: 2
等 级:论坛游民
帖 子:14
专家分:20
注 册:2013-5-21
结帖率:0
收藏(1)
 问题点数:0 回复次数:0 
VB 内容导出excel 如何设置居中
Private Sub Command5_Click()
Dim A1, A2, A3, A4, A5, A6
Dim Row, Col, xlApp
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
On Error Resume Next
Set xlApp = New Application
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Dim strSource, strDestination As String        
strSource = "\\192.168.1.168\D$\Excels\MadeDepart\OutSuperSelllM.xls"
strDestination = "\\192.168.1.168\D$\Excels\MadeDepart\OutSuperSelllMTemp.xls"
FileCopy strSource, strDestination
Set xlbook = xlApp.Workbooks.Open("\\192.168.1.168\D$\Excels\MadeDepart\OutSuperSelllMTemp.xls")
Set xlsheet = xlbook.Worksheets("OutSuperSell")
xlsheet.Activate
If adoCon.State = adStateClosed Then adoCon.Open
Set adoRs.ActiveConnection = adoCon
adoRs.Open "select * from SuKiGuestInforGong where 编号='" & MSFlexGrid2.TextMatrix(1, 8) & "' order by 编号"
  
    If Not adoRs.EOF Then
     xlsheet.Cells(2, 5).Value = adoRs("名称")
     xlsheet.Cells(3, 5).Value = adoRs("联系人")
     xlsheet.Cells(4, 5).Value = adoRs("电话")
     xlsheet.Cells(5, 5).Value = adoRs("传真")
    End If
     adoRs.Close
     
 If Text5.Text <> "" Then
 
     adoRs.Open "select * from SuKiGuestInforGong where 编号='" & Text5.Text & "' order by 编号"
  
    If Not adoRs.EOF Then
'     xlsheet.Cells(2, 2).Value = adoRs1("名称")
     xlsheet.Cells(3, 2).Value = adoRs("联系人")
     xlsheet.Cells(4, 2).Value = adoRs("电话")
     xlsheet.Cells(5, 2).Value = adoRs("传真")
    End If
     adoRs.Close

 End If

xlsheet.Cells(6, 2).Value = Text1.Text
'xlsheet.Cells(4, 2).Value = MSFlexGrid2.TextMatrix(1, 9)
xlsheet.Cells(6, 6).Value = format(Date, "yyyy-mm-dd")


  Row = 8
  Col = 1

  i = 1
  Do While i < MSFlexGrid2.Rows
  Col = 1
   
    A1 = ""
    A2 = ""
    A3 = ""
    A4 = ""
    A5 = ""
    A6 = ""

    A1 = MSFlexGrid2.TextMatrix(i, 1)   '类型
    A2 = MSFlexGrid2.TextMatrix(i, 2)   '材料名称
    A3 = MSFlexGrid2.TextMatrix(i, 3)   '规格
    A4 = MSFlexGrid2.TextMatrix(i, 4)   '单位
    A5 = MSFlexGrid2.TextMatrix(i, 5)   '数量
    A6 = MSFlexGrid2.TextMatrix(i, 6)   '单位

   
   
   
    xlsheet.Cells(Row, Col).Value = A1
    Col = Col + 1
   
    xlsheet.Cells(Row, Col).Value = A2
    Col = Col + 1
   
    xlsheet.Cells(Row, Col).Value = A3
    Col = Col + 1
   
    xlsheet.Cells(Row, Col).Value = A4
    Col = Col + 1
   
    xlsheet.Cells(Row, Col).Value = A5
    Col = Col + 1
   
    xlsheet.Cells(Row, Col).Value = A6
   
   
    Row = Row + 1
   
    i = i + 1

  Loop
  
   
End Sub
搜索更多相关主题的帖子: 如何 excel 
2013-06-04 18:59
快速回复:VB 内容导出excel 如何设置居中
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015609 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved