static void InsertData(SnapDocumentServer server)
        {
            #region #InsertData
            server.LoadDocumentTemplate("Template.snx");
            SnapList list = server.Document.FindListByName("Data Source 11");
            server.Document.ParseField(list.Field);
            list.BeginUpdate();

            // Add a header to the Snap list.
            SnapDocument        listHeader      = list.ListHeader;
            Table               listHeaderTable = listHeader.Tables[0];
            TableCellCollection listHeaderCells = listHeaderTable.FirstRow.Cells;
            listHeader.InsertText(listHeaderCells.InsertAfter(2).ContentRange.End, "Quantity per Unit");



            // Add data to the row template:
            SnapDocument        listRow      = list.RowTemplate;
            Table               listRowTable = listRow.Tables[0];
            TableCellCollection listRowCells = listRowTable.FirstRow.Cells;
            listRow.CreateSnText(listRowCells.InsertAfter(2).ContentRange.End, @"QuantityPerUnit");
            list.EndUpdate();

            list.Field.Update();
            #endregion #InsertData
        }
        static void GroupData(SnapDocumentServer server)
        {
            #region #GroupData

            server.LoadDocumentTemplate("Template.snx");
            SnapList list = server.Document.FindListByName("Data Source 11");
            server.Document.ParseField(list.Field);
            list.BeginUpdate();
            list.EditorRowLimit = 100500;

            // Add a header to the Snap list.
            SnapDocument listHeader      = list.ListHeader;
            Table        listHeaderTable = listHeader.Tables[0];


            SnapListGroupInfo group = list.Groups.CreateSnapListGroupInfo(
                new SnapListGroupParam("CategoryID", ColumnSortOrder.Ascending));
            list.Groups.Add(group);

            // Add a group header.
            SnapDocument groupHeader = group.CreateHeader();
            Table        headerTable = groupHeader.Tables.Create(groupHeader.Range.End, 1, 1);
            headerTable.SetPreferredWidth(50 * 100, WidthType.FiftiethsOfPercent);
            TableCellCollection groupHeaderCells = headerTable.FirstRow.Cells;
            groupHeader.InsertText(groupHeaderCells[0].ContentRange.End, "Category ID: ");
            groupHeader.CreateSnText(groupHeaderCells[0].ContentRange.End, "CategoryID");

            // Customize the group header formatting.
            groupHeaderCells[0].BackgroundColor          = System.Drawing.Color.LightGray;
            groupHeaderCells[0].Borders.Bottom.LineColor = System.Drawing.Color.White;
            groupHeaderCells[0].Borders.Left.LineColor   = System.Drawing.Color.White;
            groupHeaderCells[0].Borders.Right.LineColor  = System.Drawing.Color.White;
            groupHeaderCells[0].Borders.Top.LineColor    = System.Drawing.Color.White;

            // Add a group footer.
            SnapDocument groupFooter = group.CreateFooter();
            Table        footerTable = groupFooter.Tables.Create(groupFooter.Range.End, 1, 1);
            footerTable.SetPreferredWidth(50 * 100, WidthType.FiftiethsOfPercent);
            TableCellCollection groupFooterCells = footerTable.FirstRow.Cells;
            groupFooter.InsertText(groupFooterCells[0].ContentRange.End, "Count = ");
            groupFooter.CreateSnText(groupFooterCells[0].ContentRange.End,
                                     @"CategoryID \sr Group \sf Count");

            // Customize the group footer formatting.
            groupFooterCells[0].BackgroundColor          = System.Drawing.Color.LightGray;
            groupFooterCells[0].Borders.Bottom.LineColor = System.Drawing.Color.White;
            groupFooterCells[0].Borders.Left.LineColor   = System.Drawing.Color.White;
            groupFooterCells[0].Borders.Right.LineColor  = System.Drawing.Color.White;
            groupFooterCells[0].Borders.Top.LineColor    = System.Drawing.Color.White;

            list.EndUpdate();
            //list.Field.Update();

            #endregion #GroupData
        }
コード例 #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Mail Merge Server");
            string templateFileName;
            string outputFileName;

            switch (args.Length)
            {
            case 0:
                templateFileName = defaultTemplateFileName;
                outputFileName   = defaultOutputFileName;
                break;

            case 1:
                templateFileName = defaultTemplateFileName;
                outputFileName   = args[0];
                break;

            case 2:
                templateFileName = args[0];
                outputFileName   = args[1];
                break;

            default:
                throw new ArgumentException();
            }

            if (!File.Exists(templateFileName))
            {
                throw new FileNotFoundException("Template file not found", templateFileName);
            }
            Console.WriteLine("Template file: {0}", new FileInfo(templateFileName).FullName);
            Console.WriteLine("Target file:   {0}", new FileInfo(outputFileName).FullName);
            #region #ServerCode
            SnapDocumentServer server = new SnapDocumentServer();

            server.SnapMailMergeRecordStarted  += server_SnapMailMergeRecordStarted;
            server.SnapMailMergeRecordFinished += server_SnapMailMergeRecordFinished;

            server.LoadDocument(templateFileName);
            object dataSource = CreateDataSource();

            SnapMailMergeExportOptions options = server.Document.CreateSnapMailMergeExportOptions();
            options.DataSource = dataSource;
            Console.Write("Performing mail merge... ");
            server.SnapMailMerge(options, outputFileName, DocumentFormat.Rtf);
            #endregion #ServerCode
            Console.WriteLine("Ok!");
            Console.Write("Press any key...");
            Console.ReadKey();
            System.Diagnostics.Process.Start(outputFileName);
        }
        static void FormatData(SnapDocumentServer server)
        {
            #region #FormatData
            server.LoadDocumentTemplate("Template.snx");
            SnapList list = server.Document.FindListByName("Data Source 11");
            server.Document.ParseField(list.Field);
            list.BeginUpdate();
            list.EditorRowLimit = 100500;

            SnapDocument header      = list.ListHeader;
            Table        headerTable = header.Tables[0];
            headerTable.SetPreferredWidth(50 * 100, WidthType.FiftiethsOfPercent);

            foreach (TableRow row in headerTable.Rows)
            {
                foreach (TableCell cell in row.Cells)
                {
                    // Apply cell formatting.
                    cell.Borders.Left.LineColor   = System.Drawing.Color.White;
                    cell.Borders.Right.LineColor  = System.Drawing.Color.White;
                    cell.Borders.Top.LineColor    = System.Drawing.Color.White;
                    cell.Borders.Bottom.LineColor = System.Drawing.Color.White;
                    cell.BackgroundColor          = System.Drawing.Color.SteelBlue;

                    // Apply text formatting.
                    CharacterProperties formatting = header.BeginUpdateCharacters(cell.ContentRange);
                    formatting.Bold      = true;
                    formatting.ForeColor = System.Drawing.Color.White;
                    header.EndUpdateCharacters(formatting);
                }
            }

            // Customize the row template.
            SnapDocument rowTemplate = list.RowTemplate;
            Table        rowTable    = rowTemplate.Tables[0];
            rowTable.SetPreferredWidth(50 * 100, WidthType.FiftiethsOfPercent);
            foreach (TableRow row in rowTable.Rows)
            {
                foreach (TableCell cell in row.Cells)
                {
                    cell.Borders.Left.LineColor   = System.Drawing.Color.Transparent;
                    cell.Borders.Right.LineColor  = System.Drawing.Color.Transparent;
                    cell.Borders.Top.LineColor    = System.Drawing.Color.Transparent;
                    cell.Borders.Bottom.LineColor = System.Drawing.Color.LightGray;
                }
            }

            list.EndUpdate();
            list.Field.Update();

            #endregion #FormatData
        }
        static void SortList(SnapDocumentServer server)
        {
            #region #SortData
            server.LoadDocumentTemplate("Template.snx");
            SnapList list = server.Document.FindListByName("Data Source 11");
            server.Document.ParseField(list.Field);
            list.BeginUpdate();
            list.Sorting.Add(new SnapListGroupParam("UnitPrice", ColumnSortOrder.Descending));
            list.EndUpdate();
            list.Field.Update();

            #endregion #SortData
        }
コード例 #6
0
 static void CreateCheckBox(SnapDocumentServer server)
 {
     #region #CreateCheckBox
     server.LoadDocumentTemplate("Template.snx");
     server.Document.BeginUpdate();
     SnapCheckBox checkbox = server.Document.CreateSnCheckBox(server.Document.Range.Start, "Discontinued");
     server.Document.ParseField(checkbox.Field);
     checkbox.BeginUpdate();
     checkbox.State = System.Windows.Forms.CheckState.Checked;
     checkbox.EndUpdate();
     checkbox.Field.Update();
     #endregion #CreateCheckBox
 }
コード例 #7
0
 static void CreateCalculatedField(SnapDocumentServer server)
 {
     #region #CreateCalculatedField
     server.LoadDocumentTemplate("Template.snx");
     server.Document.BeginUpdate();
     CalculatedField field = new CalculatedField("newField", "Products");
     field.FieldType      = DevExpress.XtraReports.UI.FieldType.Int32;
     field.Expression     = "[UnitsInStock]*[UnitPrice]";
     field.DataSourceName = "Data Source 1";
     server.Document.CalculatedFields.Add(field);
     server.Document.EndUpdate();
     server.Document.Fields.Update();
     #endregion #CreateCalculatedField
 }
コード例 #8
0
 static void CreateSparkline(SnapDocumentServer server)
 {
     #region #CreateSparkline
     server.LoadDocumentTemplate("Template.snx");
     server.Document.BeginUpdate();
     SnapSparkline sparkline = server.Document.CreateSnSparkline(server.Document.Range.End, "UnitsInStock");
     server.Document.ParseField(sparkline.Field);
     sparkline.BeginUpdate();
     sparkline.DataSourceName = "/Data Source 1.Products";
     sparkline.ViewType       = SparklineViewType.Line;
     sparkline.Color          = System.Drawing.Color.Teal;
     sparkline.EndUpdate();
     sparkline.Field.Update();
     #endregion #CreateSparkline
 }
コード例 #9
0
 static void CreateBarCode(SnapDocumentServer server)
 {
     #region #CreateBarcode
     server.LoadDocumentTemplate("Template.snx");
     server.Document.BeginUpdate();
     SnapBarCode barcode = server.Document.CreateSnBarCode(server.Document.Range.Start);
     server.Document.ParseField(barcode.Field);
     barcode.BeginUpdate();
     barcode.DataFieldName = "EAN13";
     barcode.Module        = 10;
     barcode.Orientation   = DevExpress.XtraPrinting.BarCode.BarCodeOrientation.Normal;
     barcode.AutoModule    = true;
     barcode.ShowData      = false;
     barcode.EndUpdate();
     barcode.Field.Update();
     #endregion #CreateBarcode
 }
        static void FilterData(SnapDocumentServer server)
        {
            #region #FilterData
            // Delete the document's content.
            server.LoadDocument("Template.snx");

            SnapList list = server.Document.FindListByName("Data Source 11");
            server.Document.ParseField(list.Field);
            list.BeginUpdate();
            // Apply filtering:
            const string filter = "[Discontinued] = False";
            if (!list.Filters.Contains(filter))
            {
                list.Filters.Add(filter);
            }

            list.EndUpdate();
            list.Field.Update();


            #endregion #FilterData
        }
コード例 #11
0
 static void Main(string[] args)
 {
     if (args.Length == 0)
     {
         #region #MainAction
         SnapDocumentServer snap     = new SnapDocumentServer();
         SnapDocument       document = snap.Document;
         XTemplateCreator.CreateMailMergeTemplate(document);
         snap.Options.SnapMailMergeVisualOptions.DataSource = XDataSourceHelper.GetData();
         snap.SnapMailMerge("test.pdf", SnapDocumentFormat.Pdf);
         #endregion #MainAction
         System.Diagnostics.Process.Start("test.pdf");
     }
     else if (args[0] == "UseListTemplate")
     {
         SnapDocumentServer snap     = new SnapDocumentServer();
         SnapDocument       document = snap.Document;
         XTemplateCreator.CreateSnListTemplate(document);
         document.DataSource = XDataSourceHelper.GetData();
         snap.ExportToPdf("test.pdf");
         System.Diagnostics.Process.Start("test.pdf");
     }
 }
コード例 #12
0
 public static void ShowPrintPreview(IDocumentData documentData, IObjectSpace objectSpace, CriteriaOperator inPlaceCriteria)
 {
     using (SnapDocumentServer server = new SnapDocumentServer()) {
         SnapDocumentHelper helper = new SnapDocumentHelper(documentData, objectSpace, null, inPlaceCriteria);
         helper.LoadDocument(server.Document);
         // Mail Merge
         if (server.Document.DataSources.Count == 1 && server.Options.SnapMailMergeVisualOptions.DataSource == server.Document.DataSources[0].DataSource)
         {
             using (MemoryStream stream = new MemoryStream()) {
                 server.SnapMailMerge(stream, SnapDocumentFormat.Snap);
                 stream.Flush();
                 stream.Seek(0, SeekOrigin.Begin);
                 server.LoadDocument(stream, SnapDocumentFormat.Snap);
             }
         }
         using (PrintingSystem ps = new PrintingSystem()) {
             PrintableComponentLink link = new PrintableComponentLink(ps);
             link.Component = server;
             link.CreateDocument();
             link.ShowPreviewDialog();
         }
     }
 }
コード例 #13
0
        static void Main(string[] args)
        {
            #region #Main
            //Create a new SnapDocumentServer instance.
            SnapDocumentServer server   = new SnapDocumentServer();
            SnapDocument       document = server.Document;

            //Specify the server datasource.
            object datasource = GetDataSource();
            document.DataSource = datasource;

            Console.Write("Generating Document... ");
            // Generate the report.
            GenerateLayout(document);

            Console.WriteLine("Ok!");
            Console.Write("Press any key...");
            Console.ReadKey();

            document.ExportDocument("SnapDocumentServerTest.rtf", DocumentFormat.Rtf);
            System.Diagnostics.Process.Start("SnapDocumentServerTest.rtf");
            #endregion #Main
        }
コード例 #14
0
 static void CreateParameter(SnapDocumentServer server)
 {
     #region #CreateParameter
     server.LoadDocumentTemplate("Template.snx");
     server.Document.BeginUpdate();
     //Create parameter:
     Parameter param1 = new Parameter();
     param1.Name  = "Region";
     param1.Type  = typeof(System.String);
     param1.Value = "NEW ENGLAND";
     server.Document.Parameters.Add(param1);
     //Insert parameter field in the document:
     SnapList list = server.Document.FindListByName("Data Source 11");
     server.Document.ParseField(list.Field);
     list.BeginUpdate();
     list.ListHeader.InsertText(list.ListHeader.Tables[0].FirstRow.Cells.InsertAfter(3).ContentRange.End, "Region");
     list.RowTemplate.CreateSnText(list.RowTemplate.Tables[0].FirstRow.Cells.InsertAfter(3).ContentRange.End, @"Region \p");
     list.Field.Update();
     list.EndUpdate();
     server.Document.EndUpdate();
     server.Document.Fields.Update();
     #endregion #CreateParameter
 }