如下面:我将a1到j4合并,那我如何指定在a3单元格或是别的指定单元格内输入文本,谢谢大家!On Error Resume Next
If MSHFlexGrid1.TextMatrix(1, 2) = "" Then
MsgBox "没有数据导出", vbInformation, "提示"
Exit Sub
End If
Dim excelApp As Excel.Application
Set excelApp = New Excel.Application
Set excelApp = CreateObject("Excel.Application")
Dim exbook As Excel.Workbook
Dim exsheet As Excel.Worksheet
Set exbook = excelApp.Workbooks.Add
excelApp.SheetsInNewWorkbook = 1
excelApp.Visible = False '是否显示导出过程(true是)
excelApp.UserControl = True
Me.MousePointer = vbHourglass '控制鼠标为读取数据
'''''''''''''''''''''''''''''''''''''''''''表头设置'''''''''''''''''''''''''''''''''''''
With excelApp.ActiveSheet '表头合并
.Range("a1:j4").Merge '合并
.Range("a3:a3") = "入库单号:"
.Range("b3:c3") = t
.Range("d3:e3") = "仓库:"
.Range("f3:f3") = DataGrid2.Columns("仓库").CellValue(DataGrid2.Book)
.Range("g3:h3") = "入库日期:"
.Range("i3:j3") = DataGrid2.Columns("入库日期").CellValue(DataGrid2.Book)
.Range("a4:a4") = "供应商:"
.Range("b4:c4") = DataGrid2.Columns("供应商").CellValue(DataGrid2.Book)
.Range("d4:e4") = "入库类型:"
.Range("f4:f4") = DataGrid2.Columns("入库类型").CellValue(DataGrid2.Book)
.Range("g4:h4") = "打印日期"
.Range("i4:j4") = Format$(Now, "yyyy-mm-dd")
.Rows.HorizontalAlignment = xlVAlignCenter '
End With
With excelApp.ActiveSheet
.Range("A1:j4").Borders.LineStyle = xlContinuous '表头边框线
End With
If MSHFlexGrid1.TextMatrix(1, 2) = "" Then
MsgBox "没有数据导出", vbInformation, "提示"
Exit Sub
End If
Dim excelApp As Excel.Application
Set excelApp = New Excel.Application
Set excelApp = CreateObject("Excel.Application")
Dim exbook As Excel.Workbook
Dim exsheet As Excel.Worksheet
Set exbook = excelApp.Workbooks.Add
excelApp.SheetsInNewWorkbook = 1
excelApp.Visible = False '是否显示导出过程(true是)
excelApp.UserControl = True
Me.MousePointer = vbHourglass '控制鼠标为读取数据
'''''''''''''''''''''''''''''''''''''''''''表头设置'''''''''''''''''''''''''''''''''''''
With excelApp.ActiveSheet '表头合并
.Range("a1:j4").Merge '合并
.Range("a3:a3") = "入库单号:"
.Range("b3:c3") = t
.Range("d3:e3") = "仓库:"
.Range("f3:f3") = DataGrid2.Columns("仓库").CellValue(DataGrid2.Book)
.Range("g3:h3") = "入库日期:"
.Range("i3:j3") = DataGrid2.Columns("入库日期").CellValue(DataGrid2.Book)
.Range("a4:a4") = "供应商:"
.Range("b4:c4") = DataGrid2.Columns("供应商").CellValue(DataGrid2.Book)
.Range("d4:e4") = "入库类型:"
.Range("f4:f4") = DataGrid2.Columns("入库类型").CellValue(DataGrid2.Book)
.Range("g4:h4") = "打印日期"
.Range("i4:j4") = Format$(Now, "yyyy-mm-dd")
.Rows.HorizontalAlignment = xlVAlignCenter '
End With
With excelApp.ActiveSheet
.Range("A1:j4").Borders.LineStyle = xlContinuous '表头边框线
End With
解决方案 »
- vb6禁止窗口拖放,不通过设置BorderStyle怎么实现?
- 请问vb中怎样实现在执行当前程序的过程停止程序执行的,类似asp中response.end这样功能的语句
- 请教:调用哪个api函数可以让主板发出告警声?
- VB生成的activex控件,如何在IE中调用?答对再加100分
- VB上传文件到服务器
- 也不知道VB SCRIPT提问到哪里提,就在这里提好了。大家看看这几句是什么意思啊??
- 关于visdata的问题,帮忙up者有分
- 如何将两个已经打开的记录集联结成一个新的记录集?
- 如何正确地备份win9x、winme、win2000和winxp的注册表文件(请说出要备份哪几个文件,在什么位置)?
- vb6.0 dategrid 问题
- retert
- vb中的clscfxstrbuilder这个对象是什么?
excelapp.Cells(1, 1) = "XXX报表"
楼主看看这个:http://download.csdn.net/source/1262359
With excelApp.ActiveSheet
.Range("A1:j4").Borders.LineStyle = xlContinuous '表头边框线
End With出现每个单元格都有边框
With excelApp.ActiveSheet
.Range("A1:j4").Borders.LineStyle = xlContinuous '表头边框线
End With 出现每个单元格都有边框
excel中录制宏,看具体写法,用于VB中
以下是B10:D14内做法示例:
Range("B10:D14").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThick
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThick
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThick
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThick
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
那如果B10:D14中假如B11跟B12要合并,如何处理呢?
With excelApp.ActiveSheet
.Range("A1:j4").Borders.LineStyle = xlContinuous '表头边框线
End With