exporting .net reports to excel

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • devolper
    New Member
    • Nov 2006
    • 3

    exporting .net reports to excel

    I am devolping a web application which which .net reports to a excel work book .each report in one excel sheet.i am using the following code..........


    Dim objDestinationE xcel As New Excel.Applicati on
    Dim objDestinationW BS As Excel.Workbooks
    objDestinationW BS = objDestinationE xcel.Workbooks
    objDestinationW BS.Open(Templat eFileName)
    Dim objDestinationW B As Excel.Workbook
    objDestinationW B = objDestinationW BS.Item(1)
    Dim objDestinationW SS As Excel.Sheets
    objDestinationW SS = objDestinationW B.Worksheets
    'Dim objNewSheet As Excel.Worksheet
    Dim a As Excel.Range = 2
    Dim objDestinationS heet As Excel.Worksheet
    'Dim objDestinationS heet As Excel.Workbook
    'objDestination Sheet = objDestinationW SS.Item(Positio n)


    Dim objSourceExcel As New Excel.Applicati on
    Dim objSourceWBS As Excel.Workbooks
    objSourceWBS = objSourceExcel. Workbooks
    Dim objSourceWB As Excel.Workbook
    Dim objSourceWSS As Excel.Sheets
    Dim objSourceSheet As Excel.Worksheet

    Dim objDestinationS heetAFTER As Excel.Worksheet

    ' Iterating through the file name list and opening one by one.
    Dim iCounter As Integer
    For iCounter = 0 To SourceFileName. Length - 1
    objSourceWBS.Op en(SourceFileNa me(iCounter))
    objSourceWB = objSourceWBS.It em(1)
    objSourceWSS = objSourceWB.Wor ksheets
    objSourceSheet = CType(objSource WSS.Item(1), Excel.Worksheet )
    'oSheet = CType(oSheets.I tem(iCount + 1), Excel.Worksheet )
    objDestinationS heet = objDestinationW SS.Item(iCounte r + 1)
    objDestinationS heetAFTER = objDestinationW SS.Item(iCounte r + 2)
    objDestinationW SS.Add(objDesti nationSheet, objDestinationS heetAFTER, 1, objSourceSheet)

    this code is creating work book with some excel sheets.The data is not copied to the sheets.is their any method to copy the data of .net report to a excel sheet?Please help me to solve this problem.IT is very urgent.Thanku in advance........ .........
  • MRGRIM
    New Member
    • Nov 2006
    • 4

    #2
    Hello,

    What are you generating the report in? I've done a few things with VB.net and then exported them to Excel.

    A quick cheat I found is to render a HTML table save the file locally and then open that file with excel (a quick work around but still useful)

    Comment

    • devolper
      New Member
      • Nov 2006
      • 3

      #3
      Originally posted by MRGRIM
      Hello,

      What are you generating the report in? I've done a few things with VB.net and then exported them to Excel.

      A quick cheat I found is to render a HTML table save the file locally and then open that file with excel (a quick work around but still useful)

      I am also doing so.here i am passing an array of html tables to this application.Can u give me code ........

      Comment

      • MRGRIM
        New Member
        • Nov 2006
        • 4

        #4
        Hi, this may not be 100% what your after as I am simply creating a webpage then loading that, however some of the macro's might be useful for you, prehaps you could do a copy and paste programmaticall y into Excel?

        Dim oExcel As Excel.Applicati onClass
        Dim oBook As Excel.WorkbookC lass
        Dim oBooks As Excel.Workbooks
        Dim thisMofo As Excel.Sheets

        'Start Excel and open the workbook.
        oExcel = CreateObject("E xcel.Applicatio n")
        oExcel.Visible = True
        Dim ObjW = oExcel.ActiveWo rkbook
        oBooks = oExcel.Workbook s

        'Tell excel to open my html webpage
        oBook = oBooks.Open(App lication.Startu pPath & "\WHAP Report.html")

        'Run the macros (format cells to display dates
        oExcel.Cells.Ra nge("B7:AA7").N umberFormat = "dd/mm"
        oExcel.Cells.Ra nge("B7:AA7").C olumnWidth = 4
        oExcel.Cells.Ra nge("B8:AA100") .NumberFormat = "[h]:mm"

        'format the page so its landscape (not sure if this actually works)
        oExcel.ActiveSh eet.PageSetup.P rintArea = ""
        With oBook.ActiveShe et.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = oExcel.Applicat ion.InchesToPoi nts(0.75)
        .RightMargin = oExcel.Applicat ion.InchesToPoi nts(0.75)
        .TopMargin = oExcel.Applicat ion.InchesToPoi nts(1)
        .BottomMargin = oExcel.Applicat ion.InchesToPoi nts(1)
        .HeaderMargin = oExcel.Applicat ion.InchesToPoi nts(0.5)
        .FooterMargin = oExcel.Applicat ion.InchesToPoi nts(0.5)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintQuality = 600
        .CenterHorizont ally = False
        .CenterVertical ly = False
        .Orientation = "xlLandscap e"
        .Draft = False
        .PaperSize = "xlPaperA4"
        .FirstPageNumbe r = "xlAutomati c"
        .Order = "xlDownThenOver "
        .BlackAndWhite = False
        .Zoom = False
        .FitToPagesWide = 1
        .FitToPagesTall = 1
        .PrintErrors = "xlPrintErrorsD isplayed"
        End With

        Comment

        Working...