Skip to content

Commit

Permalink
Add LINQ examples
Browse files Browse the repository at this point in the history
  • Loading branch information
naeem244 committed Feb 2, 2016
1 parent 993404d commit f05f2f2
Show file tree
Hide file tree
Showing 15 changed files with 158 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -19,6 +19,7 @@ obj/
classes/
generated/
bin/
*_out_*
* Out*
* out*
*.ldb
Expand Down
Expand Up @@ -19,7 +19,8 @@ public static void main(String[] args) throws Exception
ReportingEngine engine = new ReportingEngine();

// Execute the build report.
engine.buildReport(doc, Common.GetClients(), "clients");
// engine.getKnownTypes().add(DateUtil.class);
engine.buildReport(doc, Common.GetClients());

dataDir = dataDir + Utils.GetOutputFilePath(fileName);

Expand Down
58 changes: 51 additions & 7 deletions Examples/src/main/java/com/aspose/words/examples/linq/Common.java
Expand Up @@ -9,7 +9,10 @@
import com.aspose.words.net.System.Data.DataSet;
import com.aspose.words.net.System.Data.DataTable;

import java.sql.*;
import java.util.*;
import java.util.Date;

public class Common {
public static List<Manager> managers = new ArrayList<Manager>();

Expand All @@ -24,7 +27,7 @@ public static Manager GetManager(){
}

/// <summary>
/// Return an enumeration of instances of the Client class.
/// Return an dataset of the Client class.
/// </summary>
public static DataSet GetClients() throws Exception
{
Expand Down Expand Up @@ -53,7 +56,7 @@ public static DataSet GetClients() throws Exception
/// <summary>
/// Return an enumeration of instances of the Manager class.
/// </summary>
public static List<Manager> GetManagers() {
private static List<Manager> GetManagers() {

Manager manager = new Manager();
manager.setName("John Smith");
Expand Down Expand Up @@ -194,17 +197,58 @@ private static byte[] readContentIntoByteArray(File file)
return bFile;
}
/// <summary>
/// Return an enumeration of instances of the Contract class.
/// Return an dataset of the Contract class.
/// </summary>
public static List<Contract> GetContracts()
public static DataSet GetContracts() throws Exception
{
List<Contract> contracts = new ArrayList<Contract>();
// Create a new data set
DataSet dataSet = new DataSet("DS");

// Add a new table to store contracts
DataTable dt = new DataTable("contracts");

// Add columns
dt.getColumns().add("Price", float.class);
dt.getColumns().add("Date", Date.class);
dataSet.getTables().add(dt);

for (Manager manager : GetManagers()) {
for (Contract contract : manager.getContracts()) {
contracts.add(contract);
DataRow row = dt.newRow();
row.set("Price", contract.getPrice());
row.set("Date", contract.getDate());
dt.getRows().add(row);
}
}
return contracts;
return dataSet;
}
/// <summary>
/// Return an dataset of the Manager class.
/// </summary>
public static DataSet Managers() throws Exception
{
// Create a new data set
DataSet dataSet = new DataSet("DS");

// Add a new table to store contracts
DataTable dt = new DataTable("managers");

// Add columns
dt.getColumns().add("Name");
dt.getColumns().add("Age", int.class);
dt.getColumns().add("Photo", byte[].class);
dt.getColumns().add("Contracts", Contract.class);
dataSet.getTables().add(dt);

for (Manager manager : GetManagers()) {
DataRow row = dt.newRow();
row.set("Name", manager.getName());
row.set("Age", manager.getAge());
row.set("Photo", manager.getPhoto());
row.set("Contracts", manager.getContracts());
dt.getRows().add(row);
}
return dataSet;
}

}
@@ -1,33 +1,34 @@
package com.aspose.words.examples.linq;
import com.aspose.words.*;
import com.aspose.words.examples.Utils;
import java.util.Date;
public class BubbleChart {
import java.util.*;
public class CommonList {
/**
* The main entry point for the application.
*/
public static void main(String[] args) throws Exception
{
// The path to the documents directory.
String dataDir = Utils.getDataDir(BubbleChart.class);
String dataDir = Utils.getDataDir(CommonList.class);

String fileName = "BubbleChart.docx";
String fileName = "CommonList.doc";
// Load the template document.
Document doc = new Document(dataDir + fileName);

// Create a Reporting Engine.
ReportingEngine engine = new ReportingEngine();

// Execute the build report.
engine.buildReport(doc, Common.GetContracts(), "contracts");
// engine.getKnownTypes().add(DateUtil.class);
engine.buildReport(doc, Common.Managers());

dataDir = dataDir + Utils.GetOutputFilePath(fileName);

// Save the finished document to disk.
doc.save(dataDir);

System.out.println("\nBubble chart template document is populated with the data about contracts.\nFile saved at " + dataDir);

}
System.out.println("\nCommon list template document is populated with the data about managers.\nFile saved at " + dataDir);

}
}
@@ -0,0 +1,38 @@
package com.aspose.words.examples.linq;
import com.aspose.words.*;
import com.aspose.words.examples.Utils;
import java.util.*;
public class HelloWorld {
/**
* The main entry point for the application.
*/
public static void main(String[] args) throws Exception
{

// The path to the documents directory.
String dataDir = Utils.getDataDir(HelloWorld.class);

String fileName = "HelloWorld.doc";
// Load the template document.
Document doc = new Document(dataDir + fileName);

// Create an instance of sender class to set it's properties.
Sender sender = new Sender();
sender.setName("LINQ Reporting Engine");
sender.setMessage("Hello World");

// Create a Reporting Engine.
ReportingEngine engine = new ReportingEngine();

// Execute the build report.
engine.buildReport(doc, sender, "sender");

dataDir = dataDir + Utils.GetOutputFilePath(fileName);

// Save the finished document to disk.
doc.save(dataDir);

System.out.println("\nTemplate document is populated with the data about the sender.\nFile saved at " + dataDir);

}
}
@@ -0,0 +1,29 @@
package com.aspose.words.examples.linq;
import com.aspose.words.*;
import com.aspose.words.examples.Utils;
import java.util.*;
public class MulticoloredNumberedList {
/**
* The main entry point for the application.
*/
public static void main(String[] args) throws Exception {
// The path to the documents directory.
String dataDir = Utils.getDataDir(MulticoloredNumberedList.class);
String fileName = "MulticoloredNumberedList.doc";
// Load the template document.
Document doc = new Document(dataDir + fileName);

// Create a Reporting Engine.
ReportingEngine engine = new ReportingEngine();

// Execute the build report.
engine.buildReport(doc, Common.GetClients());

dataDir = dataDir + Utils.GetOutputFilePath(fileName);

// Save the finished document to disk.
doc.save(dataDir);

System.out.println("\nMulticolored numbered list template document is populated with the data about clients.\nFile saved at " + dataDir);
}
}
@@ -0,0 +1,29 @@
package com.aspose.words.examples.linq;
import com.aspose.words.*;
import com.aspose.words.examples.Utils;
import java.util.*;
public class NumberedList {
/**
* The main entry point for the application.
*/
public static void main(String[] args) throws Exception {
// The path to the documents directory.
String dataDir = Utils.getDataDir(NumberedList.class);
String fileName = "NumberedList.doc";
// Load the template document.
Document doc = new Document(dataDir + fileName);

// Create a Reporting Engine.
ReportingEngine engine = new ReportingEngine();

// Execute the build report.
engine.buildReport(doc, Common.GetClients());

dataDir = dataDir + Utils.GetOutputFilePath(fileName);

// Save the finished document to disk.
doc.save(dataDir);

System.out.println("\nNumbered list template document is populated with the data about clients.\nFile saved at " + dataDir);
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit f05f2f2

Please sign in to comment.