473,394 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

how to export data from datagrid to word??

I am having one grid..i want to export that grid to word..after doing only
two fields r coming ie serial no: and total..product name, quantity and
unitcost r not coming into the word...those three r from databasee...How can
i bring those three to the word...

the code looks like this...
object fileName = "C:\\Inetpub\\wwwroot\\eBilling\\jijo.doc";
object readOnly = false;
object isVisible = true;
object missing = System.Reflection.Missing.Value;
object oEndOfDoc = "\\StartOfDoc";
object oCurrentCell="\\Cell" ;
Word.ApplicationClass oWordApp = new Word.ApplicationClass();
try
{

Word.Document oWordDoc = oWordApp.Documents.Open(ref fileName,ref
missing,ref readOnly,ref missing, ref missing, ref missing,ref missing, ref
missing, ref missing,ref missing, ref missing, ref isVisible, ref missing,ref
missing,ref missing);
oWordDoc.Activate();

oWordApp.Selection.TypeParagraph();
oWordDoc.Content.Delete(ref missing,ref missing);
Word.Table oTable;
Word.Range wrdRng =oWordDoc.Bookmarks.Item(ref oEndOfDoc).Range;

oTable = oWordDoc.Tables.Add(wrdRng, DataGrid1.Items.Count, 5, ref missing,
ref missing);
oTable.Range.ParagraphFormat.SpaceAfter = 6;

int i,j;
for(i=0;i {
for(j=0;j<5;j++)
{

oTable.Cell(i+1,j+1).Range.Text=DataGrid1.Items[i].Cells[j].Text;
}
}

oWordDoc.DisableFeatures=true;
oWordDoc.Save();
oWordDoc.Close(ref missing,ref missing,ref missing);

Response.Redirect("C:\\Inetpub\\wwwroot\\eBilling\ \jijo.doc");

}
catch(Exception ex)
{

oWordApp.Application.Quit(ref missing, ref missing, ref missing);
}
Response.Redirect("C:\\Inetpub\\wwwroot\\eBilling\ \jijo.doc");

--
Jijo kuruvila
trivandrum,Kerala,India
Nov 16 '05 #1
0 2128

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Paolo | last post by:
Hello, I am trying to create a procedure to export my Access data to a word template. I would like to export data from two tables to a word file at the same time. My two tables are named CASES...
2
by: PerryC | last post by:
Is there a way to export an MS Access Report to Word/Excel that looks EXACTLY like it appears in Access? When I export to Excel, only certain data appears, titles, headings... all missing. The...
0
by: jijo kuruvila | last post by:
I am having one grid..i want to export that grid to word..after doing only two fields r coming ie serial no: and total..product name, quantity and unitcost r not coming into the word...those three...
8
by: Arvind P Rangan | last post by:
Hi all, Have you worked on any project or example where in we can export data to Word Format with Page Brakes and Header & Footer Template. This is very important for my assignment. Thanks...
6
by: Eric | last post by:
Dear All, I want to export datagrid content to a Excel file, the code just like below: Response.ContentType = "application/vnd.ms-excel" Response.Charset = "" Me.EnableViewState = False Dim...
1
by: | last post by:
The following code: Private Sub ClearControls(ByVal ctrl As Control) Dim i As Int32 For i = ctrl.Controls.Count - 1 To 0 Step -1 ClearControls(ctrl.Controls(i))
0
by: Pranav | last post by:
I've a web page that displays report data in a data grid an a chart ( I'm using Chart Fx for .Net which creates .PNG files on Server) I've a requirement to export the datagrid and chart both to...
2
by: Bidarkota | last post by:
Hi, I have a DataGrid in which there are some images and Data are displayed and in the webform.asp page i am using some stylesheets. when i export the datagrid all the images are also exported...
1
by: johnlim20088 | last post by:
Hi All, I does have a question about export datagrid data to csv. Well, I know the common solution is 1) select the data again and put in the datatable, then export to csv. BUT I don't want...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...

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.