再问excel表格问题
请问怎样在导出数据的excel表中设置行、宽和字体 问题点数:40、回复次数:7Top
1 楼vbman2003(家人)回复于 2005-11-29 12:50:47 得分 0
你在EXCEL中把你想设置的操作一遍,同时录下操作过程的宏。然后按ctrl+F11看看模块中的代码就有了Top
2 楼faysky2(出来混,迟早是要还嘀)回复于 2005-11-29 13:09:10 得分 40
设置指定列的宽度(单位:字符个数)
eole.ActiveSheet.Columns(1).ColumnWidth=5
设置指定行的高度(单位:磅)
eole.ActiveSheet.Rows(1).RowHeight=1/0.035Top
3 楼faysky2(出来混,迟早是要还嘀)回复于 2005-11-29 13:10:40 得分 0
设置字体
eole.ActiveSheet.Cells(2,1).Font.Name=″黑体″
设置字体大小
eole.ActiveSheet.Cells(1,1).Font.Size=25
设置字体为斜体
eole.ActiveSheet.Cells(1,1).Font.Italic=.t.
设置整列字体为粗体
eole.ActiveSheet.Columns(1).Font.Bold=.t.
Top
4 楼ljqqyx()回复于 2005-11-29 13:12:43 得分 0
Dim xlApp As New Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim i, j As Integer
Dim a As Excel.CellFormat
Screen.MousePointer = 11
Set xlApp = CreateObject("Excel.Application")
Set xlBook = Nothing
Set xlSheet = Nothing
Set xlBook = xlApp.Workbooks().Add
Set xlSheet = xlBook.Worksheets("sheet1")
i = 0
xlSheet.Cells(1, (mfgContent.Cols \ 2)).Value = mfgContent.TextMatrix(1, 1)
For i = 0 To mfgContent.Rows - 1
For j = 0 To mfgContent.Cols
xlSheet.Cells(i + 2, j).Value = mfgContent.TextMatrix(i, j + 1)
Next j
Next i
With ActiveWorkbook
.SaveAs App.Path & "\excel.xls"
End With
xlApp.Visible = False
xlApp.Application.Visible = False
Set xlApp = Nothing
Set xlBook = Nothing
Set xlSheet = Nothing
Screen.MousePointer = 0
请高手指点一下,怎么在上面的代码中实现我的要求!!!谢谢!!!
Top
5 楼faysky2(出来混,迟早是要还嘀)回复于 2005-11-29 14:12:07 得分 0
Dim xlApp As New Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim i, j As Integer
Dim a As Excel.CellFormat
Screen.MousePointer = 11
Set xlApp = CreateObject("Excel.Application")
Set xlBook = Nothing
Set xlSheet = Nothing
Set xlBook = xlApp.Workbooks().Add
Set xlSheet = xlBook.Worksheets("sheet1")
i = 0
xlSheet.Cells(1, (mfgContent.Cols \ 2)).Value = mfgContent.TextMatrix(1, 1)
For i = 0 To mfgContent.Rows - 1
xlSheet.Columns(i+2).ColumnWidth = 11.25 '设置列宽
xlSheet.Columns(i+2).Font.Name = "黑体"
For j = 0 To mfgContent.Cols
If j=0 Then xlSheet.Rows(j).RowHeight = 30.75 '设置行高
xlSheet.cells(i + 2, j).Font.Name = "黑体" '设置字体
xlSheet.cells(i + 2, j).Font.Size=18 '设置字体大小
xlSheet.Cells(i + 2, j).Value = mfgContent.TextMatrix(i, j + 1)
Next j
Next i
With ActiveWorkbook
.SaveAs App.Path & "\excel.xls"
End With
xlApp.Visible = False
xlApp.Application.Visible = False
Set xlApp = Nothing
Set xlBook = Nothing
Set xlSheet = Nothing
Screen.MousePointer = 0
Top
6 楼ljqqyx()回复于 2005-11-29 14:28:16 得分 0
faysky20:
高手,在请教一下,怎样给导出的表加边框!!
谢谢!!!!!
Top
7 楼faysky2(出来混,迟早是要还嘀)回复于 2005-11-29 14:33:03 得分 0
'边框范围不合适的话,自己修改
j=mfgContent.Cols
' 画边框-------------------------------------------------
xlSheet.Range("a" & "2", "i" & j).Font.Size = 11
xlSheet.Range("A" & "5", "I" & j).Borders(xlEdgeLeft).LineStyle = xlContinuous
xlSheet.Range("A" & "5", "I" & j).Borders(xlEdgeLeft).Weight = xlThin
xlSheet.Range("A" & "5", "I" & j).Borders(xlEdgeLeft).ColorIndex = xlAutomatic
xlSheet.Range("A" & "5", "I" & j).Borders(xlEdgeTop).LineStyle = xlContinuous
xlSheet.Range("A" & "5", "I" & j).Borders(xlEdgeTop).Weight = xlThin
xlSheet.Range("A" & "5", "I" & j).Borders(xlEdgeTop).ColorIndex = xlAutomatic
xlSheet.Range("A" & "5", "I" & j).Borders(xlEdgeBottom).LineStyle = xlContinuous
xlSheet.Range("A" & "5", "I" & j).Borders(xlEdgeBottom).Weight = xlThin
xlSheet.Range("A" & "5", "I" & j).Borders(xlEdgeBottom).ColorIndex = xlAutomatic
xlSheet.Range("A" & "5", "I" & j).Borders(xlEdgeRight).LineStyle = xlContinuous
xlSheet.Range("A" & "5", "I" & j).Borders(xlEdgeRight).Weight = xlThin
xlSheet.Range("A" & "5", "I" & j).Borders(xlEdgeRight).ColorIndex = xlAutomatic
xlSheet.Range("A" & "5", "I" & j).Borders(xlInsideVertical).LineStyle = xlContinuous
xlSheet.Range("A" & "5", "I" & j).Borders(xlInsideVertical).Weight = xlThin
xlSheet.Range("A" & "5", "I" & j).Borders(xlInsideVertical).ColorIndex = xlAutomaticTop




