程序为:
xlSheet.Cells(i, j) = SourceGrid.TextMatrix(i, j)
转移到excel后整张表黑底无字,而且只剩下两行两列
这个现象只存在一个窗体中(上面的所有msflexgrid都有这个问题),其他窗体用同样的代码正常BTW,用debug.print sourcegrid.cols,返回值为2,而实际上该MSflexgrid上有24列

解决方案 »

  1.   

    窗体与msflexgrid的名称应该没有问题
      

  2.   

    也许不是代码的问题,也许是窗体网格格式设置的问题,可以与别的窗体比较一下.
    至于导出成为excel,方法实在太多.最简单的就是记录集直接saveas.或者将网格内的
    数据存为一个数组,将这个数组作为excel的数据源.一下就好了.
      

  3.   

    To haohaohappy:
    装了SP6,但没什么用'把窗体A中grdB(一个MSFlexGrid)导入到excel表(从excel表第五行开始)Public Sub GridToExl(SourceGrid As MSFlexGrid, StartRow As Long)
    Dim i As Long, j As Long    For i = 0 To SourceGrid.Rows - 1
            For j = 0 To SourceGrid.Cols - 1
                xlSheet.Cells(StartRow + i, 1 + j).Font.Name = "Verdana"
                xlSheet.Cells(StartRow + i, 1 + j).Font.Size = 9
                xlSheet.Cells(StartRow + i, 1 + j) = SourceGrid.TextMatrix(i, j)
                SourceGrid.Row = i
                SourceGrid.Col = j
                If j = 0 Then xlSheet.Cells(StartRow + i, 1 + j).Interior.Color = RGB(180, 180, 180)
                If i = 0 Then xlSheet.Cells(StartRow + i, 1 + j).Interior.Color = RGB(120, 120, 120)
                If i <> 0 And j <> 0 Then xlSheet.Cells(StartRow + i, 1 + j).Interior.Color = SourceGrid.CellBackColor
                xlSheet.Cells(StartRow + i, 1 + j).Font.Color = SourceGrid.CellForeColor
                xlSheet.Cells(StartRow + i, 1 + j).Font.Bold = SourceGrid.CellFontBold
                xlSheet.Cells(StartRow + i, 1 + j).Font.Italic = SourceGrid.CellFontItalic
            Next j
        Next iEnd Sub后来我新建了一窗体,重新建立所有控件,但问题还是不成To xghim:
    该窗体和网格的属性和其他的差不多,没看出什么异样