哈,不明白你要做什么,具体一些:
一、文件内容是什么(txt表,Sql命令,dbf其它文件)
二、到出到Excel要什么格式,...作.net的报表,可以导入到Excel的
    你是要自己做,把数据导入到某个特定的cell吗?

解决方案 »

  1.   

    给你一个使用VB6.0写Excel的Class,自己去参考,我没有太多的时间,如果改成C#之后,麻烦给我发个过来[email protected]谢谢Option ExplicitPublic m_xlApp As Excel.Application
    Public m_xlBook As Excel.Workbook
    Public m_xlSheet As Excel.WorksheetPublic m_strFileName As StringPrivate Sub Class_Initialize()
        m_strFileName = "Books1.xls"
        Set m_xlApp = New Excel.Application
        Set m_xlBook = m_xlApp.Workbooks.Add
        Set m_xlSheet = m_xlBook.Sheets(1)
        
        m_xlApp.Visible = False
    End SubPrivate Sub Class_Terminate()
        
        m_xlBook.Close False
        m_xlApp.Quit
        
        Set m_xlApp = Nothing
        Set m_xlBook = Nothing
        Set m_xlSheet = Nothing
    End SubPublic Function OpenSaveAsFileName(strFileNameDefault As String) As Variant
        On Error Resume Next
        
        Dim strFileName As Variant
        strFileName = m_xlApp.GetSaveAsFilename(strFileNameDefault, "Microsoft Excel 工作薄(*.xls),*.xls")
        If strFileName <> False Then
            Me.m_strFileName = CStr(strFileName)
        End If
        OpenSaveAsFileName = strFileName
        
        If Err Then
            Err.Clear
        End If
    End FunctionPublic Sub SaveCurrExportedExcel()
        On Error Resume Next
        
        m_xlBook.SaveAs m_strFileName
        
        If Err Then
            Err.Clear
        End If
    End SubPublic Function AdodcExport(ByRef ctrADO As Adodc, ByVal nSheetStartRow As Long, ByVal nSheetStartCol As Long) As Long
        '''------------------------------------------------------
        ''' For Test Only:
        Dim nRow As Long
        Dim nCol As Long
        
        On Error Resume Next
        
        ctrADO.Recordset.MoveFirst
        
        If Err Then
            Err.Clear
            AdodcExport = 0
            Exit Function
        End If
        
        nRow = nSheetStartRow
        nCol = 0
        
        
        Do While (ctrADO.Recordset.EOF = False And ctrADO.Recordset.BOF = False)
            nRow = nRow + 1
            For nCol = 1 To ctrADO.Recordset.Fields.Count Step 1
                m_xlSheet.Cells(nRow, nCol + nSheetStartCol).Value = Trim(ctrADO.Recordset.Fields(nCol - 1).Value)
            Next nCol
            ctrADO.Recordset.MoveNext
            If Err Then
                Err.Clear
            End If
        Loop
        
        AdodcExport = nRow
    End FunctionPublic Function ResExport(ByRef rsADO As ADODB.Recordset, ByVal nSheetStartRow As Long, ByVal nSheetStartCol As Long) As Long
        '''------------------------------------------------------
        ''' For Test Only:
        Dim nRow As Long
        Dim nCol As Long
        
        On Error Resume Next
        
        If rsADO.EOF Or rsADO.BOF Then
            Exit Function
        End If
        
        rsADO.MoveFirst
        If Err Then
            Err.Clear
            ResExport = 0
            Exit Function
        End If
        
        nRow = nSheetStartRow
        nCol = 0
        
        
        Do While (rsADO.EOF = False And rsADO.BOF = False)
        
            nRow = nRow + 1
            For nCol = 1 To rsADO.Fields.Count Step 1
                m_xlSheet.Cells(nRow, nCol + nSheetStartCol).Value = Trim(rsADO.Fields(nCol - 1).Value)
            Next nCol
            
            rsADO.MoveNext
            
            If Err Then
                Err.Clear
            End If
        Loop
        
        ResExport = nRow
    End Function
      

  2.   

    为什么不试一试MS SQL2000的DTS ? 
      

  3.   

    要将数据库中的数据导入指定的CELL,并要设一些属性,比如线条,字体,合并单元格,分页,增加SHEET等。