By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,277 Members | 1,255 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,277 IT Pros & Developers. It's quick & easy.

exporting .net reports to excel

P: 3
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 objDestinationExcel As New Excel.Application
Dim objDestinationWBS As Excel.Workbooks
objDestinationWBS = objDestinationExcel.Workbooks
objDestinationWBS.Open(TemplateFileName)
Dim objDestinationWB As Excel.Workbook
objDestinationWB = objDestinationWBS.Item(1)
Dim objDestinationWSS As Excel.Sheets
objDestinationWSS = objDestinationWB.Worksheets
'Dim objNewSheet As Excel.Worksheet
Dim a As Excel.Range = 2
Dim objDestinationSheet As Excel.Worksheet
'Dim objDestinationSheet As Excel.Workbook
'objDestinationSheet = objDestinationWSS.Item(Position)


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

Dim objDestinationSheetAFTER 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.Open(SourceFileName(iCounter))
objSourceWB = objSourceWBS.Item(1)
objSourceWSS = objSourceWB.Worksheets
objSourceSheet = CType(objSourceWSS.Item(1), Excel.Worksheet)
'oSheet = CType(oSheets.Item(iCount + 1), Excel.Worksheet)
objDestinationSheet = objDestinationWSS.Item(iCounter + 1)
objDestinationSheetAFTER = objDestinationWSS.Item(iCounter + 2)
objDestinationWSS.Add(objDestinationSheet, objDestinationSheetAFTER, 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.................
Nov 30 '06 #1
Share this Question
Share on Google+
3 Replies


P: 4
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)
Nov 30 '06 #2

P: 3
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 ........
Dec 1 '06 #3

P: 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 programmatically into Excel?

Dim oExcel As Excel.ApplicationClass
Dim oBook As Excel.WorkbookClass
Dim oBooks As Excel.Workbooks
Dim thisMofo As Excel.Sheets

'Start Excel and open the workbook.
oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
Dim ObjW = oExcel.ActiveWorkbook
oBooks = oExcel.Workbooks

'Tell excel to open my html webpage
oBook = oBooks.Open(Application.StartupPath & "\WHAP Report.html")

'Run the macros (format cells to display dates
oExcel.Cells.Range("B7:AA7").NumberFormat = "dd/mm"
oExcel.Cells.Range("B7:AA7").ColumnWidth = 4
oExcel.Cells.Range("B8:AA100").NumberFormat = "[h]:mm"

'format the page so its landscape (not sure if this actually works)
oExcel.ActiveSheet.PageSetup.PrintArea = ""
With oBook.ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = oExcel.Application.InchesToPoints(0.75)
.RightMargin = oExcel.Application.InchesToPoints(0.75)
.TopMargin = oExcel.Application.InchesToPoints(1)
.BottomMargin = oExcel.Application.InchesToPoints(1)
.HeaderMargin = oExcel.Application.InchesToPoints(0.5)
.FooterMargin = oExcel.Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = "xlLandscape"
.Draft = False
.PaperSize = "xlPaperA4"
.FirstPageNumber = "xlAutomatic"
.Order = "xlDownThenOver"
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintErrors = "xlPrintErrorsDisplayed"
End With
Dec 1 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.