按楼主说的方法,Excel输出可以满足要求,但PDF文件还是有格线显示。
以下是我的代码,请确认。
Protected Sub Page_int(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
FpSpread.UseClipboard = False
'FpSpread.Sheets(0).GridLineColor = Drawing.Color.Black
FpSpread.Sheets(0).DefaultStyle.Border.BorderColor = Color.Black
FpSpread.Sheets(0).DefaultStyle.Border.BorderSize = 1
FpSpread.Sheets(0).DefaultStyle.Border.BorderStyle = BorderStyle.Solid
FpSpread.Sheets(0).ColumnHeader.DefaultStyle.BackColor = Color.White
FpSpread.Sheets(0).ColumnHeader.DefaultStyle.Border.BorderColor = Color.Black
FpSpread.Sheets(0).ColumnHeader.DefaultStyle.Border.BorderSize = 1
FpSpread.Sheets(0).ColumnHeader.DefaultStyle.Border.BorderStyle = BorderStyle.Solid
'表格外框 Size
FpSpread.Height = 400
FpSpread.Width = 940
'表格中19列
FpSpread.Sheets(0).ColumnCount = 19
'列标题:4行
FpSpread.Sheets(0).ColumnHeader.RowCount = 4
'明细行高
FpSpread.Sheets(0).Rows.Default.Height = 23
FpSpread.Sheets(0).Rows.Default.VerticalAlign = VerticalAlign.Middle
FpSpread.Sheets(0).RowCount = 100
'表头
FpSpread.Sheets(0).ColumnHeader.Rows(0).Height = 20
FpSpread.Sheets(0).ColumnHeader.Cells(0, 14).Text = "承认"
FpSpread.Sheets(0).ColumnHeader.Cells(0, 15).Text = "确认"
FpSpread.Sheets(0).ColumnHeader.Cells(0, 16).Text = "确认"
FpSpread.Sheets(0).ColumnHeader.Cells(0, 17).Text = "确认"
FpSpread.Sheets(0).ColumnHeader.Cells(0, 18).Text = "担当"
FpSpread.Sheets(0).ColumnHeader.Cells(0, 14).Font.Size = 8
FpSpread.Sheets(0).ColumnHeader.Cells(0, 15).Font.Size = 8
FpSpread.Sheets(0).ColumnHeader.Cells(0, 16).Font.Size = 8
FpSpread.Sheets(0).ColumnHeader.Cells(0, 17).Font.Size = 8
FpSpread.Sheets(0).ColumnHeader.Cells(0, 18).Font.Size = 8
FpSpread.Sheets(0).ColumnHeader.Rows(1).Height = 70
FpSpread.Sheets(0).ColumnHeader.Rows(1).Font.Size = 12
FpSpread.Sheets(0).ColumnHeader.Rows(1).Font.Bold = True
FpSpread.Sheets(0).ColumnHeaderSpanModel.Add(1, 3, 1, 11)
FpSpread.Sheets(0).ColumnHeader.Cells(1, 3).Text = "资产经费金额汇总表"
FpSpread.Sheets(0).ColumnHeader.Rows(2).Height = 20
FpSpread.Sheets(0).ColumnHeader.Rows(2).Font.Size = 8
FpSpread.Sheets(0).ColumnHeaderSpanModel.Add(2, 0, 1, 4)
FpSpread.Sheets(0).ColumnHeader.Cells(2, 0).Text = "区分:1 资产 2 经费"
FpSpread.Sheets(0).ColumnHeader.Cells(2, 0).HorizontalAlign = HorizontalAlign.Left
FpSpread.Sheets(0).ColumnHeaderSpanModel.Add(2, 14, 1, 5)
FpSpread.Sheets(0).ColumnHeader.Cells(2, 14).Text = "做成日:" & Today
FpSpread.Sheets(0).ColumnHeader.Cells(2, 14).HorizontalAlign = HorizontalAlign.Right
FpSpread.Sheets(0).ColumnHeader.Rows(3).Height = 20
FpSpread.Sheets(0).ColumnHeader.Rows(3).Font.Size = 9
FpSpread.Sheets(0).ColumnHeader.Cells(3, 0).Text = "区分"
FpSpread.Sheets(0).ColumnHeader.Cells(3, 1).Text = "通货"
FpSpread.Sheets(0).ColumnHeader.Cells(3, 2).Text = "取引先"
FpSpread.Sheets(0).ColumnHeader.Cells(3, 3).Text = "取引先名"
FpSpread.Sheets(0).ColumnHeader.Cells(3, 4).Text = "1月"
FpSpread.Sheets(0).ColumnHeader.Cells(3, 5).Text = "2月"
FpSpread.Sheets(0).ColumnHeader.Cells(3, 6).Text = "3月"
FpSpread.Sheets(0).ColumnHeader.Cells(3, 7).Text = "4月"
FpSpread.Sheets(0).ColumnHeader.Cells(3, 8).Text = "5月"
FpSpread.Sheets(0).ColumnHeader.Cells(3, 9).Text = "6月"
FpSpread.Sheets(0).ColumnHeader.Cells(3, 10).Text = "上期累计"
FpSpread.Sheets(0).ColumnHeader.Cells(3, 11).Text = "7月"
FpSpread.Sheets(0).ColumnHeader.Cells(3, 12).Text = "8月"
FpSpread.Sheets(0).ColumnHeader.Cells(3, 13).Text = "9月"
FpSpread.Sheets(0).ColumnHeader.Cells(3, 14).Text = "10月"
FpSpread.Sheets(0).ColumnHeader.Cells(3, 15).Text = "11月"
FpSpread.Sheets(0).ColumnHeader.Cells(3, 16).Text = "12月"
FpSpread.Sheets(0).ColumnHeader.Cells(3, 17).Text = "下期累计"
FpSpread.Sheets(0).ColumnHeader.Cells(3, 18).Text = "通期累计"
'FpSpread.Sheets(0).ColumnHeader.Columns(0).Width = 30
'FpSpread.Sheets(0).ColumnHeader.Columns(1).Width = 50
'FpSpread.Sheets(0).ColumnHeader.Columns(2).Width = 50
'FpSpread.Sheets(0).ColumnHeader.Columns(3).Width = 180
FpSpread.Sheets(0).Columns(0).Width = 30
FpSpread.Sheets(0).Columns(1).Width = 30
FpSpread.Sheets(0).Columns(2).Width = 50
FpSpread.Sheets(0).Columns(3).Width = 180
Dim i As Integer
For i = 4 To 18
'FpSpread.Sheets(0).ColumnHeader.Columns(i).Width = 70
FpSpread.Sheets(0).Columns(i).Width = 80
Next
'行标题不可视
FpSpread.Sheets(0).RowHeader.Visible = False
'格线设定
'FpSpread.Sheets(0).ColumnHeader.DefaultStyle.BackColor = Color.White
'FpSpread.Sheets(0).ColumnHeader.DefaultStyle.Border.BorderColor = Color.Black
'FpSpread.Sheets(0).ColumnHeader.DefaultStyle.Border.BorderSize = 2
Dim style0, style1, style2, style3, style4, style5 As New Border
'style1.BorderColorTop = Color.White
'style1.BorderColorBottom = Color.White
'style1.BorderColorRight = Color.White
'style1.BorderColorLeft = Color.White
style1.BorderSizeTop = 0
style1.BorderSizeBottom = 0
style1.BorderSizeLeft = 0
style1.BorderSizeRight = 0
'style2.BorderColorTop = Color.White
'style2.BorderColorBottom = Color.White
'style2.BorderColorLeft = Color.White
'style2.BorderColorRight = Color.Black
style2.BorderSizeTop = 0
style2.BorderSizeBottom = 0
style2.BorderSizeLeft = 0
'style3.BorderColorTop = Color.White
'style3.BorderColorBottom = Color.Black
'style3.BorderColorLeft = Color.White
'style3.BorderColorRight = Color.White
'style3.BorderSize = 2
style3.BorderSizeTop = 0
style3.BorderSizeRight = 0
style3.BorderSizeLeft = 0
'style4.BorderColorTop = Color.Black
'style4.BorderColorBottom = Color.Black
'style4.BorderColorLeft = Color.Black
'style4.BorderColorRight = Color.Black
'style5.BorderColorTop = Color.Black
'style5.BorderColorBottom = Color.Black
'style5.BorderColorLeft = Color.White
'style5.BorderColorRight = Color.White
'style5.BorderSize = 2
style5.BorderSizeRight = 0
style5.BorderSizeLeft = 0
Dim mycell As FarPoint.Web.Spread.Cell
''第一行:
For i = 0 To 12
mycell = FpSpread.Sheets(0).ColumnHeader.Cells(0, i)
mycell.Border = style1
Next
mycell = FpSpread.Sheets(0).ColumnHeader.Cells(0, 13)
mycell.Border = style2
'For i = 14 To 18
' mycell = FpSpread.Sheets(0).ColumnHeader.Cells(0, i)
' mycell.Border = style4
'Next
''第二行:
For i = 0 To 13
mycell = FpSpread.Sheets(0).ColumnHeader.Cells(1, i)
mycell.Border = style1
Next
'mycell = FpSpread.Sheets(0).ColumnHeader.Cells(1, 13)
'mycell.Border = style2
'For i = 14 To 18
' mycell = FpSpread.Sheets(0).ColumnHeader.Cells(1, i)
' mycell.Border = style4
'Next
'第三行:
For i = 0 To 13
mycell = FpSpread.Sheets(0).ColumnHeader.Cells(2, i)
mycell.Border = style3
Next
'For i = 14 To 18
' mycell = FpSpread.Sheets(0).ColumnHeader.Cells(2, i)
' mycell.Border = style5
'Next
''第四行:
'For i = 0 To 18
' mycell = FpSpread.Sheets(0).ColumnHeader.Cells(3, i)
' mycell.Border = style4
'Next
FpSpread.Sheets(0).Columns.Default.Font.Size = 9
FpSpread.Sheets(0).AllowPage = False
FpSpread.Sheets(0).AllowInsert = True
FpSpread.Sheets(0).AllowDelete = True
FpSpread.ClientAutoCalculation = True
FpSpread.Sheets(0).AutoCalculation = True
Dim ObjDoubleCell_2 As New FarPoint.Web.Spread.GeneralCellType() '2位小数
Dim NumForm2 As New System.Globalization.NumberFormatInfo
NumForm2.CurrencySymbol = ""
ObjDoubleCell_2.FormatString = "c"
ObjDoubleCell_2.NumberFormat = NumForm2
Dim c As Integer
For c = 4 To 18
FpSpread.Sheets(0).Columns(c).CellType = ObjDoubleCell_2
FpSpread.Sheets(0).Columns(c).HorizontalAlign = HorizontalAlign.Right
Next
FpSpread.CommandBar.Visible = True
End Sub |