Sno Elector's Name Father'sName House No Age Sex Id
1 RAGHAVENDHAR LAXMANACHARI 1-1-*400/401 36 Male ZTS1298603
2 BHARATHA LAKSHMIARIGILA SAIKUMAR A 1-1-1 41 Female ZTS1083807
3 HMA BINDU SENAGASETI KRISHNA RAO S 1-1-1 37 Female ZTS1083815
4
5
6
7
.........i have more then 2000 rows .....
i would like display sql table date to MS word or pdf like below formate
plz help me...........
.
Megan Foster18 pointsPosted Feb 8, 2015, 11:55 PM EST
You first need to define a template file with the required layout and placeholders (in which you want to import the data later on).
Actually you don't have to create a template file, but creating a Word document from scratch in C# with the required layout and placeholders is a bit of an unnecessary hassle.
So for example here is a template file:
The template has the desired layout of the single record and has placeholders which names correspond to the DataTable's columns name. Also the area is wrapped around the range definition ("TableData").
Now you need to read the template Word document with C#:
// Set mail merge prefixes, I used different prefixes for defining range from the default ones. document.MailMerge.RangeStartPrefix = "S:"; document.MailMerge.RangeEndPrefix = "E:"; // Execute importing of DataTable's data in "TableData" named range. document.MailMerge.Execute(sourceTable, "TableData");Note that you can create a PDF file in same C# manner, you just need to replace the output file's extension from ".docx" to ".pdf".