VacationItinerary.cs
  1. //
  2. // This code is part of Document Solutions for Word demos.
  3. // Copyright (c) MESCIUS inc. All rights reserved.
  4. //
  5. using System;
  6. using System.IO;
  7. using System.Drawing;
  8. using System.Collections.Generic;
  9. using System.Text;
  10. using System.Data;
  11. using System.Linq;
  12. using System.Globalization;
  13. using GrapeCity.Documents.Word;
  14.  
  15. namespace DsWordWeb.Demos
  16. {
  17. // This data template sample generates a sample vacation itinerary.
  18. public class VacationItinerary
  19. {
  20. public GcWordDocument CreateDocx(int _ = 0)
  21. {
  22. // Sample data for the itinerary template:
  23. var data = new[]
  24. {
  25. new {
  26. clientName = "Mark Louis",
  27. clientPhoneNumber = "876-123-7546",
  28. ItineraryStartDate = "01/12/2019",
  29. ItineraryEndDate = "15/12/2019",
  30. flightDetails = new {
  31. arrivalDate = "01/12/2019",
  32. arrivalAirlineName = "British Airways",
  33. arrivalTime = "08:00 AM",
  34. arrivalTerminal = "T1",
  35. departureDate = "15/12/2019",
  36. departureAirlineName = "British Airways",
  37. departureArrivalTime = "10:00 PM",
  38. departureArrivalTerminal = "T2"
  39. },
  40. hotelDetails = new {
  41. checkinTime = "12:00 PM",
  42. hotelName = "Awasi Patagonia",
  43. hotelAddress = "12/13, Block Street",
  44. hotelInclusion = "Cab Service",
  45. checkOutTime = "11:00 AM"
  46. },
  47. activities = new [] {
  48. new { activityDate ="03/12/2019", activityDestination = "Jungle", activity = "Jungle Safari", remarks = "Make sure to carry woolens"},
  49. new { activityDate = "07/12/2019", activityDestination = "Spa Room", activity = "Spa Session", remarks = "Morning would be the best time"},
  50. new { activityDate = "11/12/2019", activityDestination = "Gym Area", activity = "Yoga Session", remarks = "Wear a comfortable attire"}
  51. }
  52. }
  53. };
  54.  
  55. // Load the template DOCX, add the data source and process the template:
  56. var doc = new GcWordDocument();
  57. doc.Load(Path.Combine("Resources", "WordDocs", "Vacation_Itinerary_Template.docx"));
  58. doc.DataTemplate.DataSources.Add("ds", data);
  59. doc.DataTemplate.Process(CultureInfo.GetCultureInfo("en-US"));
  60.  
  61. // Done:
  62. return doc;
  63. }
  64.  
  65. public static List<string[]> GetSampleParamsList()
  66. {
  67. return new List<string[]>()
  68. {
  69. new string[] { "@data-templates/Vacation Itinerary", "Generate a vacation itinerary from template", null },
  70. new string[] { "@use-data-tpl/Vacation Itinerary", "Generate a vacation itinerary from template", null },
  71. };
  72. }
  73. }
  74. }
  75.