473,769 Members | 2,148 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

exporting .net reports to excel

3 New Member
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........ .........
Nov 30 '06 #1
3 2240
MRGRIM
4 New Member
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
devolper
3 New Member
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
MRGRIM
4 New Member
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
Dec 1 '06 #4

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

Similar topics

0
3594
by: Ali Eghtebas | last post by:
Hi, I tried this demo application in here (watch for any line breaks in the URL): (http://support.crystaldecisions.com/communityCS/FilesAndUpdates/vbnet_win_a dodotnet.exe.asp When exporting to Excel there is an empty column after each actual column in the excel. Why? Is this a normal behaviour? Is it impossible to get rid of the empty columns when using the export funtion of the report?
0
1233
by: Amber | last post by:
I found a sample on dynamic reporting to a datagrid and exporting to excel. For those who are into reporting into Excel. This web tool allows for adhoc select statements and reports. http://www.dedicatedsolutions.co.uk/DesktopDefault.aspx?tabid=80
0
2011
by: George G. | last post by:
I am exporting a report to an Excel file. Whatever options I use for the formatting the results remain the same. I have set the ExcelTabHasColumnHeadings to true and false without any difference. I have set the ExcelUseConstantColumnWidth to true and thenset the width to different values and have seen no changes. The code I am using is shown below. private void ExportToExcel (CrystalDecisions.CrystalReports.Engine.ReportDocument Report,...
1
10525
by: Alex | last post by:
Hi all, I've seen this noted in many posts, but nothing I've checked out gives me any clue on how to do this. Basically as my topic says, I have a DTS and I simply need to export some data from a table in MS SQL 2000 to an Excel spreadsheet. I also need to automate this process so it can run nightly and each new day a new spreadsheet will be on a network share for us to pick-up.
5
3065
by: mik18 | last post by:
I'm having trouble with exporting reports to Word in the rtf format and I'm hoping someone has a solution. The reports are losing their formats. Not all the formating is lost but some is and of course it's the really important parts that are lost. In one report the grouping is lost and everything gets repeated. I've created several reports that pull data from various tables then they get exported to Word when they're run so the user can...
1
3167
by: Mustufa Baig | last post by:
I have an ASP.NET website where I am showing off crystal reports to users by exporting them to pdf format. Following is the code: ---------------- 1 Private Sub ExportReport() 2 Dim oStream As System.IO.MemoryStream = 3 myReport.ExportToStream( ExportFormatType.PortableDocFormat) 4 Response.Clear() 5 Response.Buffer() = True
2
3184
by: Snozz | last post by:
The short of it: If you needed to import a CSV file of a certain structure on a regular basis(say 32 csv files, each to one a table in 32 databases), what would be your first instinct on how to set this up so as to do it reliably and minimize overhead? There are currently no constraints on the destination table. Assume the user or some configuration specifies the database name, server name, and filename+fullpath. The server is SQL...
4
1820
by: deejayquai | last post by:
Hi First of all my level = basic! My question= I have a report containing student performance data with a sub-report showing the subjects they have taken that year. I run the report group by group, therefore returning many records, page by page, within the report. This works fine! BUT I have been unable to develop a dynamic crosstab query/report for the sub-report so I can't show the subjects in a table form as the subjcet columns...
3
2543
by: Tempalli | last post by:
I am exporting the data from ms access to excel where the error displays as Run-time error -2147467259(800004005) Method 'Copyfromrecordset' of object 'Range' faild. Ws.Range("A2").CopyFromRecordset rs One of my Field Name, DATATYPE is set to MEMO I am testing with DATATYPE As TEXT and the Characters within 255 then the report get's downloaded to Excel, if the DATATYPE is set to MEMO and the characters are more than 255 error...
0
9583
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10210
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9990
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9860
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8869
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6668
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5297
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3955
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.