473,324 Members | 2,473 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,324 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 2124

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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.