专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > VB Dotnet

有关DATAGRIDVIEW向excel导数据有关问题

发布时间:2011-06-23 14:31:18 文章来源:www.iduyao.cn 采编人员:星星草
有关DATAGRIDVIEW向excel导数据问题
请问用vb.net写excel区域所有连框,还有合并居中加粗怎么写?谢谢了!

------解决方案--------------------

 Dim xlApp As Excel.Application
        Dim xlBook As Excel.Workbook
        Dim xlSheet As Excel.Worksheet
        Dim myRange As Excel.Range
ShowMsg("创建Excel程序...")
        xlApp = New Excel.Application
        xlBook = xlApp.Workbooks.Add
        xlSheet = xlBook.Worksheets.Item(1)
'....
         ShowMsg("格式化单元格边框线条.")
            myRange = xlSheet.Range(xlSheet.Cells(1, 1), xlSheet.Cells(5,5))
            With myRange
                .Borders(Excel.XlBordersIndex.xlInsideHorizontal).LineStyle = Excel.XlLineStyle.xlDot
                .Borders(Excel.XlBordersIndex.xlInsideVertical).LineStyle = Excel.XlLineStyle.xlDot
                .Borders(Excel.XlBordersIndex.xlEdgeTop).LineStyle = Excel.XlLineStyle.xlContinuous
                .Borders(Excel.XlBordersIndex.xlEdgeRight).LineStyle = Excel.XlLineStyle.xlContinuous
                .Borders(Excel.XlBordersIndex.xlEdgeLeft).LineStyle = Excel.XlLineStyle.xlContinuous
                .Borders(Excel.XlBordersIndex.xlEdgeBottom).LineStyle = Excel.XlLineStyle.xlContinuous
            End With

With myRange
            .Merge()  '合并单元格
            .WrapText = True  '文本对齐
            .Font.Bold = True  '字体粗体
            .Font.Size = FontSize '字体大小
            .HorizontalAlignment = AlignNum '.HorizontalAlignment = 1默认,2 左对齐,3 居中对齐,4右对齐
            '.VerticalAlignment =  '1顶部 默认 2居中 3底部对齐 4顶部对齐
            If FUnderline = True Then '下划线
                .Borders(Excel.XlBordersIndex.xlEdgeBottom).LineStyle = 7 '7,9 细实线
            End If
            .Value = "文本内容"
        End With


------解决方案--------------------
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: