473,320 Members | 1,950 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,320 software developers and data experts.

How can i Export grid 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 1174

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...
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...
0
by: sunilkumar Reddy via DotNetMonster.com | last post by:
hai all first we can take binded grid Export to excel data from ultrawebgrid (or) datagrid rows, Each row data Expoting to one worksheet in excel workbook, like as grid row1 data contain sheet1...
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...
0
by: sonali | last post by:
when i export grid to word i got whole data but on that grid i have some run time created images that gives some problem images come blank (there is grid inside table) Dim str As String...
2
by: Jyoti Khalap | last post by:
Hi, I am new to Visual Basics. Can anybody help me out to get the data in MSFlexGrid to be written to word file or a text file I have succesfully ran my visual Basic form to get the output in...
4
by: coolminded | last post by:
hi there, i have a little problem with export to word. i just export the data from the grid to the word in the tabular form, but now i want to show it in the lines. i.e. all the data one by one in...
0
by: coolminded | last post by:
hi all i have to export the value of grid from vb to word. i just exported all the grid value to word. but what i want is i just want to export the value of grid one by one. that means when i...
15
by: News | last post by:
Am having a problem usink AK2 exporting a report to an RTF file. The Access report has most fields and sections set to CanShrink and CanGrow. The report looks fine, but the ends of a number of...
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...
1
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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

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.