| static void Main(string[] args) | static void Main(string[] args) | ||||
| { | { | ||||
| // In the development... | // In the development... | ||||
| ChartInTheDevelopment(); | |||||
| BarChartAlpha(); | |||||
| PieChartAlpha(); | |||||
| LineChartAlpha(); | |||||
| // Easy | // Easy | ||||
| Console.WriteLine("\nRunning Easy Examples"); | Console.WriteLine("\nRunning Easy Examples"); | ||||
| // Advanced | // Advanced | ||||
| Console.WriteLine("\nRunning Advanced Examples"); | Console.WriteLine("\nRunning Advanced Examples"); | ||||
| ProgrammaticallyManipulateImbeddedImage(); | ProgrammaticallyManipulateImbeddedImage(); | ||||
| ReplaceTextParallel(); | |||||
| ReplaceTextParallel(); | |||||
| Console.WriteLine("\nPress any key to exit."); | Console.WriteLine("\nPress any key to exit."); | ||||
| Console.ReadKey(); | Console.ReadKey(); | ||||
| { | { | ||||
| public String Mounth { get; set; } | public String Mounth { get; set; } | ||||
| public Double Money { get; set; } | public Double Money { get; set; } | ||||
| public static List<ChartData> CreateCompanyList1() | |||||
| { | |||||
| List<ChartData> company1 = new List<ChartData>(); | |||||
| company1.Add(new ChartData() { Mounth = "January", Money = 100 }); | |||||
| company1.Add(new ChartData() { Mounth = "February", Money = 120 }); | |||||
| company1.Add(new ChartData() { Mounth = "March", Money = 140 }); | |||||
| return company1; | |||||
| } | |||||
| public static List<ChartData> CreateCompanyList2() | |||||
| { | |||||
| List<ChartData> company2 = new List<ChartData>(); | |||||
| company2.Add(new ChartData() { Mounth = "January", Money = 80 }); | |||||
| company2.Add(new ChartData() { Mounth = "February", Money = 160 }); | |||||
| company2.Add(new ChartData() { Mounth = "March", Money = 130 }); | |||||
| return company2; | |||||
| } | |||||
| } | } | ||||
| private static void ChartInTheDevelopment() | |||||
| private static void BarChartAlpha() | |||||
| { | { | ||||
| // Create new document. | // Create new document. | ||||
| using (DocX document = DocX.Create(@"docs\Chart.docx")) | |||||
| using (DocX document = DocX.Create(@"docs\BarChart.docx")) | |||||
| { | { | ||||
| // Create chart. | // Create chart. | ||||
| BarChart c = new BarChart(); | BarChart c = new BarChart(); | ||||
| c.GapWidth = 400; | c.GapWidth = 400; | ||||
| c.AddLegend(ChartLegendPosition.Bottom, false); | c.AddLegend(ChartLegendPosition.Bottom, false); | ||||
| PieChart cc = new PieChart(); | |||||
| cc.AddLegend(ChartLegendPosition.Bottom, false); | |||||
| // Create data. | |||||
| List<ChartData> company1 = ChartData.CreateCompanyList1(); | |||||
| List<ChartData> company2 = ChartData.CreateCompanyList2(); | |||||
| LineChart ccc = new LineChart(); | |||||
| ccc.AddLegend(ChartLegendPosition.Bottom, false); | |||||
| // Create and add series | |||||
| Series s1 = new Series("Microsoft"); | |||||
| s1.Color = Color.GreenYellow; | |||||
| s1.Bind(company1, "Mounth", "Money"); | |||||
| c.AddSeries(s1); | |||||
| Series s2 = new Series("Apple"); | |||||
| s2.Bind(company2, "Mounth", "Money"); | |||||
| c.AddSeries(s2); | |||||
| // Insert chart into document | |||||
| document.InsertParagraph("Diagram").FontSize(20); | |||||
| document.InsertChartInTheDevelopment(c); | |||||
| document.Save(); | |||||
| } | |||||
| } | |||||
| private static void PieChartAlpha() | |||||
| { | |||||
| // Create new document. | |||||
| using (DocX document = DocX.Create(@"docs\PieChart.docx")) | |||||
| { | |||||
| // Create chart. | |||||
| PieChart c = new PieChart(); | |||||
| c.AddLegend(ChartLegendPosition.Bottom, false); | |||||
| // Create data. | // Create data. | ||||
| List<ChartData> company1 = new List<ChartData>(); | |||||
| company1.Add(new ChartData() { Mounth = "January", Money = 100 }); | |||||
| company1.Add(new ChartData() { Mounth = "February", Money = 120 }); | |||||
| company1.Add(new ChartData() { Mounth = "March", Money = 140 }); | |||||
| List<ChartData> company2 = new List<ChartData>(); | |||||
| company2.Add(new ChartData() { Mounth = "January", Money = 80 }); | |||||
| company2.Add(new ChartData() { Mounth = "February", Money = 160 }); | |||||
| company2.Add(new ChartData() { Mounth = "March", Money = 130 }); | |||||
| List<ChartData> company2 = ChartData.CreateCompanyList2(); | |||||
| // Create and add series | |||||
| Series s = new Series("Apple"); | |||||
| s.Bind(company2, "Mounth", "Money"); | |||||
| c.AddSeries(s); | |||||
| // Insert chart into document | |||||
| document.InsertParagraph("Diagram").FontSize(20); | |||||
| document.InsertChartInTheDevelopment(c); | |||||
| document.Save(); | |||||
| } | |||||
| } | |||||
| private static void LineChartAlpha() | |||||
| { | |||||
| // Create new document. | |||||
| using (DocX document = DocX.Create(@"docs\LineChart.docx")) | |||||
| { | |||||
| // Create chart. | |||||
| LineChart c = new LineChart(); | |||||
| c.AddLegend(ChartLegendPosition.Bottom, false); | |||||
| // Create data. | |||||
| List<ChartData> company1 = ChartData.CreateCompanyList1(); | |||||
| List<ChartData> company2 = ChartData.CreateCompanyList2(); | |||||
| // Create and add series | // Create and add series | ||||
| Series s1 = new Series("Microsoft"); | Series s1 = new Series("Microsoft"); | ||||
| s1.Color = Color.GreenYellow; | s1.Color = Color.GreenYellow; | ||||
| s1.Bind(company1, "Mounth", "Money"); | s1.Bind(company1, "Mounth", "Money"); | ||||
| c.AddSeries(s1); | c.AddSeries(s1); | ||||
| ccc.AddSeries(s1); | |||||
| Series s2 = new Series("Apple"); | Series s2 = new Series("Apple"); | ||||
| s2.Bind(company2, "Mounth", "Money"); | |||||
| s2.Bind(company2, "Mounth", "Money"); | |||||
| c.AddSeries(s2); | c.AddSeries(s2); | ||||
| cc.AddSeries(s2); | |||||
| ccc.AddSeries(s2); | |||||
| // Insert chart into document | // Insert chart into document | ||||
| document.InsertParagraph("Diagram").FontSize(20); | document.InsertParagraph("Diagram").FontSize(20); | ||||
| document.InsertParagraph("BeforeText"); | |||||
| document.InsertChartInTheDevelopment(c); | document.InsertChartInTheDevelopment(c); | ||||
| document.InsertChartInTheDevelopment(cc); | |||||
| document.InsertChartInTheDevelopment(ccc); | |||||
| document.InsertParagraph("AfterText"); | |||||
| document.Save(); | document.Save(); | ||||
| } | } | ||||
| } | } | ||||
| Paragraph pEquation1 = document.InsertEquation("x = y+z"); | Paragraph pEquation1 = document.InsertEquation("x = y+z"); | ||||
| // Insert second Equation in this document and add formatting. | // Insert second Equation in this document and add formatting. | ||||
| Paragraph pEquation2 = document.InsertEquation("x = (y+z)/t").FontSize(18).Color(Color.Blue); | |||||
| Paragraph pEquation2 = document.InsertEquation("x = (y+z)/t").FontSize(18).Color(Color.Blue); | |||||
| // Save this document to disk. | // Save this document to disk. | ||||
| document.Save(); | document.Save(); | ||||
| // Indent only the first line of the Paragraph. | // Indent only the first line of the Paragraph. | ||||
| p.IndentationFirstLine = 1.0f; | p.IndentationFirstLine = 1.0f; | ||||
| // Save all changes made to this document. | // Save all changes made to this document. | ||||
| document.Save(); | document.Save(); | ||||
| Console.WriteLine("\tCreated: docs\\Indentation.docx\n"); | Console.WriteLine("\tCreated: docs\\Indentation.docx\n"); |