Last post Jan 18, 2017 08:33 PM by UpravGlav
Dec 10, 2016 11:25 AM|csajad|LINK
hi my friend
working on printing (group or
individual) school's academic record.
the best way to do this ?
want to save all the output in
Word, and then I print
Word files How should I
this is a sample of work book.
tnx a lot
Dec 10, 2016 12:21 PM|mgebhard|LINK
You need MS Office support. This is an ASP forum.
Dec 14, 2016 02:03 AM|Cathy Zou|LINK
For your problem, I suggest you could binds the table to a dummy GridView, Then you could export the dummy GridView to Word document.
Following code for your reference,
protected void Page_Load(object sender, EventArgs e)
DataTable table = new DataTable();
// Here we add five DataRows.
table.Rows.Add(25, "Indocin", "David", DateTime.Now);
table.Rows.Add(50, "Enebrel", "Sam", DateTime.Now);
table.Rows.Add(10, "Hydralazine", "Christoff", DateTime.Now);
table.Rows.Add(21, "Combivent", "Janet", DateTime.Now);
table.Rows.Add(100, "Dilantin", "Melanie", DateTime.Now);
GridView GridView1 = new GridView();
GridView1.AllowPaging = false;
GridView1.DataSource = table;
Response.Buffer = true;
Response.Charset = "";
Response.ContentType = "application/vnd.ms-word ";
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
Output screenshot as below:
Jan 18, 2017 08:33 PM|UpravGlav|LINK
The easiest way to do this is to create a template in MS Word, where you can prepare exact layout of the report and put placeholders which will get populated/replaced with your application data at runtime. Then just bring in the data.
I am using a 3rd party toolkit for this. Similar example is described here (http://www.docentric.com/documentation/examples/nested-tables). You (or your users) can then
change the template to their needs by themselves, if they want to. Result can be in docx, pdf of xps format. You can also print directly to the printer if you want.