Export Report in doc Format at runtime!!!!

sohaib

Well-known member
Joined
Apr 30, 2005
Messages
64
Programming Experience
3-5
Hi Guyz!!!

I Came back with a new problem!! Which is very interesting though...

I want to export report in .doc format and that report should be saved at particular folder with the name of the report....

Then further i want to use it for attaching with my email message ....I already found out the attaching method but i want the report should be saved and exported at particular location at runtime!!!

I hope for the better response from you people soon...

ok
Bye
 
Well, i hope you are asking about Crystal Reports to be exported in winWord format ... otherwise tell us what kind of report you are asking for. Ok this is the code that will export existing .rpt file with .doc extension:

VB.NET:
 Dim[/color][/size][size=2] docTitleWORD [/size][size=2][color=#0000ff]As[/color][/size][size=2][color=#0000ff]String[/color][/size][size=2] = Application.StartupPath & "\targetFolder\" & [/size][size=2][color=#0000ff]Me[/color][/size][size=2].cmbInvoice.Text & ".doc"[/size][size=2][color=#008000]
 
[/color][/size]
[size=2][color=#0000ff]Dim[/color][/size][size=2] invoice [/size][size=2][color=#0000ff]As [/color][/size][size=2][color=#0000ff]String[/color][/size][size=2] = [/size][size=2][color=#0000ff]Me[/color][/size][size=2].cmbInvoice.Text
 
[/size][size=2][color=#0000ff]Dim[/color][/size][size=2] document [/size][size=2][color=#0000ff]As[/color][/size][size=2] ReportDocument
 
document = [/size][size=2][color=#0000ff]New[/color][/size][size=2] ReportDocument
 
document.Load(Application.StartupPath & "\..\reports\invoice.rpt") 'assuming that .rpt file is named invoice and is located in reports dir
 
document.SetParameterValue("InvoiceID", invoice)
 
document.ExportToDisk(ExportFormatType.WordForWindows, docTitleWORD)


Cheers ;)
 
Hi Kulrom and others!!

Ok, that is fine ; The Word File (.doc) Format is exported from the existing file in (.rpt) Report Format but i want ask about the report is generated at runtime by using Report Formula so every time report can be different i mean to say one report should be differ to another......

After getting that report it should be exported into the Word Format (.doc) and saved with the name of the report....

After that i will send it by emaill. anywaz i m just asking it to make into the file and save filename at some variable so that i will easily use it for further processing!!!!

ok

Bye
 
Hi Kulrom and others!!!

I m trying to solve my problem but never get an appropriate solution at yet...

Now i m trying to tell you once again...what i want to do!!!

Actually, Whenever i will move from one form to another form where the report lies then that report will be updated or you can say it will show only that particular record....right it is showing because i only show current page property so that only current page is displayed but i want only that particular record at export file and it should be saved at runtime not ask where i will export that file .... and that file should be exported into file with the name of record#.doc so that whenever it will export it should be updated from the previous file right....
then i will send that file by email or print... (Later Portion)
but later portion i have already done now i m facing problem to export that report (particular that record which i want only) ....

so any one who can help me in this regard plz help me because i have very less time to complete that project...

I hope for the positive response from you soon..

Best Regards,

Bye
 
hi Kulrom!!

No problem!!! Now u r here then i hope it will solve...anyways...

Yes, you are right to say that output file (Word Document) saved with the name of the clientName (Field) or any name like file1.doc, file2.doc and so on...

but the issue is not solved completely here the export file should contain only that particular record which is displayed in front of the screen.... not all of the others..... ( I mean only one record)

and all of the process should be done without defining where to put that export file... I think so you have understand my point...

ok

Have a nice Day

Bye
 
Now I'm really confused. Would you mind if you contact me via Yahoo messenger in order to clarify your question please? From all this i can only guess about the proper solution :( that is not good for both ... Maybe you want to save certain file through savefiledialog or you want to store a file in memory and just send via email and then just remove or something ... however, i'm waiting for your feedback (on yahoo msgr)

Cheers ;)
 
Well, you need to set a filter to only have user i.e. No. 1 visible, than export the whole document. I'm not real familiar on how to handle the filter in the version that comes with vs.NET but however you need to find RecordSelectionFormula property and set it with a string similar to: "{table.field} = filtervalue".

RecordSelectionFormula and Passing the selection formula through the viewer control
take a look at this MSDN article i hope it will help you out
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/crystlmn/html/crtskselectionformulasruntimecustomization.asp


Cheers ;)
 
Hi Kulrom!!!

Nice to hear from you!! I have already using Selection formula for getting one record...but here i want to ask you that how the file should be exported and that file should contain only one record (particular record)!!!

Can you plz help me out to solve this problem....

Have a nice day!!!

Bye
 
Hi Kulrom!!

Now i achieve my one goal by exporting the file it will only export one record but i want to ask you about how i can export that record at runtime i mean to say i dont want to select export option from dialog box.

As you know, I want file name with Reference#( Generated No.) and having a .doc extension the location can be set any...I think so you understand this problem...so plz help me in this regard and tell some method how i can export record at runtime actually i want that file for further processing (Sending Email via attachment) so it's necessary that file should be created at runtime and then i will send email with attachment that file after all.

I hope for the positive response from u soon..

take care,
Bye
 
Hi Kulrom & Others!!

There is no reply by uptil now about my problem so plz help me in my above problem...

As i told u that how i can export report in word document format at

runtime...Whatever the code given by Mr.Kulrom that was not loaded report

properly .so tell me is there an another way or make this code for implementation.

I am waiting your response soon.

Best Regards,

Sohaib
 
Ok take a look at the attached project and also note that you always export only data for one/selected member ... that's because i added ID parameter ... i hope this is enough to get sense for further development of your final version ... Cheers ;)
 

Attachments

  • ExportToWordFromCR.zip
    49.2 KB · Views: 55
Hi Kulrom!!

Thanx a lot for giving me a solution of my problem but i am still facing problem so then i am giving an attached file and tell me where i am going to make a mistake elsewhere ur logic is same and concept was very clear to the solution...

I hope for the positive reply from you soon.

Best Regards,
Sohaib
 

Attachments

  • ExportError.zip
    91.8 KB · Views: 36
Back
Top