Last active
March 5, 2020 16:16
-
-
Save aspose-com-gists/4f0e741d863333a8ea3874eadaf34372 to your computer and use it in GitHub Desktop.
Generate Word from Template in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
John Doe | 30 | 1989-04-01 4:00:00 pm | |
---|---|---|---|
Jane Doe | 27 | 1992-01-31 07:00:00 am | |
John Smith | 51 | 1968-03-08 1:00:00 pm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
Name: "John Smith", | |
Contract: | |
[ | |
{ | |
Client: | |
{ | |
Name: "A Company" | |
}, | |
Price: 1200000 | |
}, | |
{ | |
Client: | |
{ | |
Name: "B Ltd." | |
}, | |
Price: 750000 | |
}, | |
{ | |
Client: | |
{ | |
Name: "C & D" | |
}, | |
Price: 350000 | |
} | |
] | |
}, | |
{ | |
Name: "Tony Anderson", | |
Contract: | |
[ | |
{ | |
Client: | |
{ | |
Name: "E Corp." | |
}, | |
Price: 650000 | |
}, | |
{ | |
Client: | |
{ | |
Name: "F & Partners" | |
}, | |
Price: 550000 | |
} | |
] | |
}, | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Persons> | |
<Person> | |
<Name>John Doe</Name> | |
<Age>30</Age> | |
<Birth>1989-04-01 4:00:00 pm</Birth> | |
</Person> | |
<Person> | |
<Name>Jane Doe</Name> | |
<Age>27</Age> | |
<Birth>1992-01-31 07:00:00 am</Birth> | |
</Person> | |
<Person> | |
<Name>John Smith</Name> | |
<Age>51</Age> | |
<Birth>1968-03-08 1:00:00 pm</Birth> | |
</Person> | |
</Persons> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Document doc = new Document("template.docx"); | |
CsvDataSource dataSource = new CsvDataSource("datasource.csv"); | |
ReportingEngine engine = new ReportingEngine(); | |
engine.BuildReport(doc, dataSource, "persons"); | |
doc.Save("word.docx"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Document doc = new Document("template.docx"); | |
JsonDataSource dataSource = new JsonDataSource("datasource.json"); | |
ReportingEngine engine = new ReportingEngine(); | |
engine.BuildReport(doc, dataSource, "managers"); | |
doc.Save("word.docx"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Document doc = new Document("template.docx"); | |
Sender sender = new Sender("LINQ Reporting Engine", "Hello World"); | |
ReportingEngine engine = new ReportingEngine(); | |
engine.BuildReport(doc, sender, "sender"); | |
doc.Save("word.docx"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Document doc = new Document("template.docx"); | |
XmlDataSource dataSource = new XmlDataSource("datasource.xml"); | |
ReportingEngine engine = new ReportingEngine(); | |
engine.BuildReport(doc, dataSource, "persons"); | |
doc.Save("word.docx"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Sender | |
{ | |
public string Name { get; set; } | |
public string Message { get; set; } | |
public Sender (string _name, string _message) | |
{ | |
Name = _name; | |
Message = _message; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment