Extract Oracle data to Excel without header

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • steveKC
    New Member
    • Jul 2007
    • 1

    Extract Oracle data to Excel without header

    Hi,

    Anyone know how to extarct data from Oracle to excel without the header using vb.net?

    Below is my coding:

    Dim rst As ADODB.Recordset

    cn = New ADODB.Connectio n

    With cn
    .ConnectionStri ng = "Provider=MSDAO RA.1; " & conn.getCsatCon nection()
    .CursorLocation = CursorLocationE num.adUseClient
    .Open()
    End With

    Dim a As String

    a="Select * from Backlog"

    rst = cn.Execute(a)
    Dim oXL As _Application
    Dim oWB As _Workbook
    Dim oSheet As _Worksheet()
    Dim obj As Object
    Dim filename As String

    ReDim oSheet(3)


    oSheet(0) = oWB.Worksheets( 1)
    oSheet(0).Name = "Backlog Data"
    obj = oSheet(0).Query Tables.Add(rst, oSheet(0).Range ("A1"))
    obj.BackgroundQ uery = False
    obj.Recordset = rst
    obj.Refresh()

    oXL.DisplayAler ts = False
    filename = "C:\Backlog.xls "
    oWB.SaveAs(file name)

    The coding is workign fine, just that I want to exlude the header when extact to excel file.


    Thanks in advance

    Regards,
    Steve
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    One way is to remove unwanted columns (header text listed in removeColumnLis t arraylist) before you write to the xml. Here is a portion of c# code used for that purpose:
    Code:
                foreach (DataControlField field in grdView.Columns)
                {              
                    if (excludedColumnList.Contains(field.HeaderText))
                    {
                        field.Visible = false;
                    }
                }

    Comment

    Working...