您好针对您的问题 ,需要对代码做如下更新
一个是 FpSpread1.NamedStyles.RemoveAt(0)
另一个是for循环重置header
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- Dim sfd As OpenFileDialog = New OpenFileDialog
- Dim JLs As String
- Try
- sfd.Filter = "Excel文件|*.xls|Excel新版|*.xlsx"
- sfd.InitialDirectory = Application.StartupPath & ""
- If sfd.ShowDialog() = Windows.Forms.DialogResult.Cancel Then Exit Sub
- JLs = sfd.FileName
- Me.FpSpread1.OpenExcel(JLs, FarPoint.Excel.ExcelOpenFlags.ColumnHeaders)
- FpSpread1.NamedStyles.RemoveAt(0)
- Me.FpSpread1.BorderStyle = BorderStyle.None
- Me.FpSpread1_Sheet1.ColumnHeaderAutoText = FarPoint.Win.Spread.HeaderAutoText.Blank
- Me.FpSpread1.TabStripPolicy = FarPoint.Win.Spread.TabStripPolicy.AsNeeded
- Dim i
- For i = 0 To FpSpread1.ActiveSheet.ColumnHeader.RowCount - 1
- FpSpread1.ActiveSheet.ColumnHeader.Rows(i).ResetBackColor()
- FpSpread1.ActiveSheet.ColumnHeader.Rows(i).ResetBorder()
- FpSpread1.ActiveSheet.ColumnHeader.Rows(i).ResetCanFocus()
- FpSpread1.ActiveSheet.ColumnHeader.Rows(i).ResetCellPadding()
- FpSpread1.ActiveSheet.ColumnHeader.Rows(i).ResetCellType()
- FpSpread1.ActiveSheet.ColumnHeader.Rows(i).ResetFont()
- FpSpread1.ActiveSheet.ColumnHeader.Rows(i).ResetForeColor()
- FpSpread1.ActiveSheet.ColumnHeader.Rows(i).ResetHorizontalAlignment()
- FpSpread1.ActiveSheet.ColumnHeader.Rows(i).ResetImeMode()
- FpSpread1.ActiveSheet.ColumnHeader.Rows(i).ResetImeSentenceMode()
- FpSpread1.ActiveSheet.ColumnHeader.Rows(i).ResetLockBackColor()
- FpSpread1.ActiveSheet.ColumnHeader.Rows(i).ResetLocked()
- FpSpread1.ActiveSheet.ColumnHeader.Rows(i).ResetLockFont()
- FpSpread1.ActiveSheet.ColumnHeader.Rows(i).ResetLockForeColor()
- FpSpread1.ActiveSheet.ColumnHeader.Rows(i).ResetMergePolicy()
- FpSpread1.ActiveSheet.ColumnHeader.Rows(i).ResetNoteIndicatorColor()
- FpSpread1.ActiveSheet.ColumnHeader.Rows(i).ResetNoteIndicatorPosition()
- FpSpread1.ActiveSheet.ColumnHeader.Rows(i).ResetNoteIndicatorSize()
- FpSpread1.ActiveSheet.ColumnHeader.Rows(i).ResetParentStyleName()
- FpSpread1.ActiveSheet.ColumnHeader.Rows(i).ResetTabStop()
- FpSpread1.ActiveSheet.ColumnHeader.Rows(i).ResetTextIndent()
- FpSpread1.ActiveSheet.ColumnHeader.Rows(i).ResetVerticalAlignment()
- FpSpread1.ActiveSheet.ColumnHeader.Rows(i).ResetVisualStyles()
- Next
- Catch ex As System.Exception
- MsgBox(ex.Message)
- End Try
- End Sub
复制代码 |