Exemplo n.º 1
0
 void SaveAndView(MemoryStream stream, string contentType)
 {
     if (stream != null)
     {
         stream.Position = 0;
         SaveAndroid androidSave = new SaveAndroid();
         if (contentType == "application/pdf")
         {
             androidSave.Save("ExcelToPDF.pdf", contentType, stream, m_context);
         }
         else
         {
             androidSave.Save("Input Template.xlsx", contentType, stream, m_context);
         }
     }
 }
Exemplo n.º 2
0
 void SaveAndView(MemoryStream stream, string contentType, bool image)
 {
     if (stream != null)
     {
         stream.Position = 0;
         SaveAndroid androidSave = new SaveAndroid();
         if (image)
         {
             androidSave.Save("Image." + contentType.Split('/').ToArray()[1], contentType, stream, m_context);
         }
         else
         {
             androidSave.Save("InputTemplate.pptx", contentType, stream, m_context);
         }
     }
 }
Exemplo n.º 3
0
        void OnInsertOleButtonClicked(object sender, EventArgs e)
        {
            Assembly assembly = Assembly.GetExecutingAssembly();

            //New Instance of PowerPoint is Created.[Equivalent to launching MS PowerPoint with no slides].
            IPresentation presentation = Syncfusion.Presentation.Presentation.Create();

            ISlide slide = presentation.Slides.Add(SlideLayoutType.TitleOnly);

            IShape titleShape = slide.Shapes[0] as IShape;

            titleShape.Left   = 0.65 * 72;
            titleShape.Top    = 0.24 * 72;
            titleShape.Width  = 11.5 * 72;
            titleShape.Height = 1.45 * 72;
            titleShape.TextBody.AddParagraph("Ole Object");
            titleShape.TextBody.Paragraphs[0].Font.Bold           = true;
            titleShape.TextBody.Paragraphs[0].HorizontalAlignment = HorizontalAlignmentType.Left;

            IShape heading = slide.Shapes.AddTextBox(100, 100, 100, 100);

            heading.Left   = 0.84 * 72;
            heading.Top    = 1.65 * 72;
            heading.Width  = 2.23 * 72;
            heading.Height = 0.51 * 72;
            heading.TextBody.AddParagraph("MS Word Object");
            heading.TextBody.Paragraphs[0].Font.Italic   = true;
            heading.TextBody.Paragraphs[0].Font.Bold     = true;
            heading.TextBody.Paragraphs[0].Font.FontSize = 18;

            string mswordPath = "SampleBrowser.Samples.Presentation.Templates.OleTemplate.docx";

            //Get the word file as stream
            Stream wordStream = assembly.GetManifestResourceStream(mswordPath);
            string imagePath  = "SampleBrowser.Samples.Presentation.Templates.OlePicture.png";

            //Image to be displayed, This can be any image
            Stream imageStream = assembly.GetManifestResourceStream(imagePath);

            IOleObject oleObject = slide.Shapes.AddOleObject(imageStream, "Word.Document.12", wordStream);

            //Set size and position of the ole object
            oleObject.Left   = 4.53 * 72;
            oleObject.Top    = 0.79 * 72;
            oleObject.Width  = 4.26 * 72;
            oleObject.Height = 5.92 * 72;
            //Set DisplayAsIcon as true, to open the embedded document in separate (default) application.
            oleObject.DisplayAsIcon = true;
            MemoryStream stream = new MemoryStream();

            presentation.Save(stream);
            presentation.Close();
            stream.Position = 0;
            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("InsertOLEObject.pptx", "application/powerpoint", stream, m_context);
            }
        }
        void OnButtonClicked(object sender, EventArgs e)
        {
            ExcelEngine  excelEngine = new ExcelEngine();
            IApplication application = excelEngine.Excel;

            application.DefaultVersion = ExcelVersion.Excel2013;

            #region Initializing Workbook
            //A new workbook is created.[Equivalent to creating a new workbook in MS Excel]
            //The new workbook will have 1 worksheets
            IWorkbook workbook = application.Workbooks.Create(1);
            //The first worksheet object in the worksheets collection is accessed.
            IWorksheet sheet = workbook.Worksheets[0];

            Assembly assembly   = Assembly.GetExecutingAssembly();
            Stream   fileStream = assembly.GetManifestResourceStream("SampleBrowser.Samples.XlsIO.Template.customers.xml");

            // Import the XML contents to worksheet
            XlsIOExtensions exten = new XlsIOExtensions();
            exten.ImportXML(fileStream, sheet, 1, 1, true);

            // Apply style for header
            IStyle headerStyle = sheet[1, 1, 1, sheet.UsedRange.LastColumn].CellStyle;
            headerStyle.Font.Bold  = true;
            headerStyle.Font.Color = ExcelKnownColors.Brown;
            headerStyle.Font.Size  = 10;

            // Resize columns
            sheet.Columns[0].ColumnWidth = 11;
            sheet.Columns[1].ColumnWidth = 30.5;
            sheet.Columns[2].ColumnWidth = 20;
            sheet.Columns[3].ColumnWidth = 25.6;
            sheet.Columns[6].ColumnWidth = 10.5;
            sheet.Columns[4].ColumnWidth = 40;
            sheet.Columns[5].ColumnWidth = 25.5;
            sheet.Columns[7].ColumnWidth = 9.6;
            sheet.Columns[8].ColumnWidth = 15;
            sheet.Columns[9].ColumnWidth = 15;
            #endregion

            #region Saving workbook and disposing objects
            workbook.Version = ExcelVersion.Excel2013;

            MemoryStream stream = new MemoryStream();
            workbook.SaveAs(stream);
            workbook.Close();
            excelEngine.Dispose();


            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("ImportXML.xlsx", "application/msexcel", stream, m_context);
            }
            #endregion
        }
Exemplo n.º 5
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            PdfDocument doc = new PdfDocument();

            //Add a page
            PdfPage page = doc.Pages.Add();

            PdfSolidBrush brush = new PdfSolidBrush(Syncfusion.Drawing.Color.Black);

            PdfPen pen = new PdfPen(Syncfusion.Drawing.Color.Black, 1f);

            //Create font
            PdfStandardFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 11.5f);

            PdfFont heading = new PdfStandardFont(PdfFontFamily.TimesRoman, 12, PdfFontStyle.Bold);

            font = new PdfStandardFont(PdfFontFamily.Helvetica, 10f);

            page.Graphics.DrawString("Create, Read, and Edit PDF Files from C#, VB.NET", heading, PdfBrushes.Black, new RectangleF(0, 0, page.GetClientSize().Width, 20), new PdfStringFormat(PdfTextAlignment.Center));

            string longText = "The <b> Syncfusion Essential PDF </b> is a feature-rich and high-performance .NET PDF library that allows you to add robust PDF functionalities to any .NET application." +
                              "It allows you to create, read, and edit PDF documents programmatically without Adobe dependencies. This library also offers functionality to <font color='#0000F8'> merge, split, stamp, form-fill, compress, and secure PDF files.</font>" +
                              "<br/><br/><font color='#FF3440'><b>1. Secure your PDF with advanced encryption, digital signatures, and redaction.</b></font>" +
                              "<br/><br/><font color='#FF9E4D'><b>2. Extract text and images from your PDF files.</b></font>" +
                              "<br/><br/><font color='#4F6200'><b>3. Top features: forms, tables, barcodes; stamp, split, and merge PDFs.</b></font>";

            //Rendering HtmlText
            PdfHTMLTextElement richTextElement = new PdfHTMLTextElement(longText, font, brush);

            // Formatting Layout
            PdfLayoutFormat format = new PdfLayoutFormat();

            format.Layout = PdfLayoutType.OnePage;

            //Drawing htmlString
            richTextElement.Draw(page, new RectangleF(0, 20, page.GetClientSize().Width, page.GetClientSize().Height), format);


            MemoryStream stream = new MemoryStream();

            //Save the PDF dcoument.
            doc.Save(stream);

            //Close the PDF document.
            doc.Close();

            stream.Position = 0;

            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("HtmlTextElement.pdf", "application/pdf", stream, m_context);
            }
        }
Exemplo n.º 6
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            // Create a new instance of PdfDocument class.
            PdfDocument document = new PdfDocument();

            // Add a new page to the newly created document.
            PdfPage page = document.Pages.Add();

            PdfStandardFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Bold);

            PdfGraphics g = page.Graphics;

            g.DrawString("JPEG Image", font, PdfBrushes.Blue, new Syncfusion.Drawing.PointF(0, 40));

            //Load JPEG image to stream.
            Stream jpgImageStream = typeof(ImageInsertion).GetTypeInfo().Assembly.GetManifestResourceStream("SampleBrowser.Samples.PDF.Assets.Xamarin_JPEG.jpg");

            //Load the JPEG image
            PdfImage jpgImage = new PdfBitmap(jpgImageStream);

            //Draw the JPEG image
            g.DrawImage(jpgImage, new Syncfusion.Drawing.RectangleF(0, 70, 515, 215));

            g.DrawString("PNG Image", font, PdfBrushes.Blue, new Syncfusion.Drawing.PointF(0, 355));

            //Load PNG image to stream.
            Stream pngImageStream = typeof(ImageInsertion).GetTypeInfo().Assembly.GetManifestResourceStream("SampleBrowser.Samples.PDF.Assets.Xamarin_PNG.png");

            //Load the PNG image
            PdfImage pngImage = new PdfBitmap(pngImageStream);

            //Draw the PNG image
            g.DrawImage(pngImage, new Syncfusion.Drawing.RectangleF(0, 365, 199, 300));

            MemoryStream stream = new MemoryStream();

            //Save the PDF document
            document.Save(stream);

            stream.Position = 0;

            //Close the PDF document
            document.Close(true);

            if (stream != null)
            {
                stream.Position = 0;
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("ImageInsertion.pdf", "application/pdf", stream, m_context);
            }
        }
Exemplo n.º 7
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            //Create a new PDF document
            PdfDocument document = new PdfDocument();

            //Add a page
            PdfPage page = document.Pages.Add();

            //Create font
            Stream  arialFontStream = typeof(RTLSupport).GetTypeInfo().Assembly.GetManifestResourceStream("SampleBrowser.Samples.PDF.Assets.arial.ttf");
            PdfFont font            = new PdfTrueTypeFont(arialFontStream, 14);

            //Read the text from text file
            Stream       rtlText = typeof(RTLSupport).GetTypeInfo().Assembly.GetManifestResourceStream("SampleBrowser.Samples.PDF.Assets.arabic.txt");
            StreamReader reader  = new StreamReader(rtlText, System.Text.Encoding.Unicode);
            string       text    = reader.ReadToEnd();

            reader.Dispose();

            //Create a brush
            PdfBrush   brush      = new PdfSolidBrush(new PdfColor(0, 0, 0));
            PdfPen     pen        = new PdfPen(new PdfColor(0, 0, 0));
            SizeF      clipBounds = page.Graphics.ClientSize;
            RectangleF rect       = new RectangleF(0, 0, clipBounds.Width, clipBounds.Height);

            //Set the property for RTL text
            PdfStringFormat format = new PdfStringFormat();

            format.TextDirection   = PdfTextDirection.RightToLeft;
            format.Alignment       = PdfTextAlignment.Right;
            format.ParagraphIndent = 35f;

            //Draw text.
            page.Graphics.DrawString(text, font, brush, rect, format);

            MemoryStream stream = new MemoryStream();

            //Save the PDF dcoument.
            document.Save(stream);

            //Close the PDF document.
            document.Close();

            stream.Position = 0;

            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("RTLText.pdf", "application/pdf", stream, m_context);
            }
        }
Exemplo n.º 8
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            MemoryStream stream = new MemoryStream();

            //Opens the existing presentation stream.
            using (IPresentation presentation = Syncfusion.Presentation.Presentation.Create())
            {
                ISlide     slide     = presentation.Slides.Add(SlideLayoutType.TitleOnly);
                IParagraph paragraph = ((IShape)slide.Shapes[0]).TextBody.Paragraphs.Add();
                //Apply center alignment to the paragraph
                paragraph.HorizontalAlignment = HorizontalAlignmentType.Center;
                //Add slide title
                ITextPart textPart = paragraph.AddTextPart("Northwind Management Report");
                textPart.Font.Color = ColorObject.FromArgb(46, 116, 181);
                //Get chart data from xml file
                List <ProductDetails> Products = LoadXMLData();
                //Add a new chart to the presentation slide
                IPresentationChart chart = slide.Charts.AddChart(44.64, 133.2, 870.48, 380.16);
                //Set chart type
                chart.ChartType = OfficeChartType.Pie;
                //Set chart title
                chart.ChartTitle = "Best Selling Products";
                //Set chart properties font name and size
                chart.ChartTitleArea.FontName = "Calibri (Body)";
                chart.ChartTitleArea.Size     = 14;
                for (int i = 0; i < Products.Count; i++)
                {
                    ProductDetails product = Products[i];
                    chart.ChartData.SetValue(i + 2, 1, product.ProductName);
                    chart.ChartData.SetValue(i + 2, 2, product.Sum);
                }
                //Create a new chart series with the name “Sales”
                AddSeriesForChart(chart);
                //Setting the font size of the legend.
                chart.Legend.TextArea.Size = 14;
                //Setting background color
                chart.ChartArea.Fill.ForeColor           = Syncfusion.Drawing.Color.FromArgb(242, 242, 242);
                chart.PlotArea.Fill.ForeColor            = Syncfusion.Drawing.Color.FromArgb(242, 242, 242);
                chart.ChartArea.Border.LinePattern       = OfficeChartLinePattern.None;
                chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 11, 1];
                //Saves the presentation instance to the stream.
                presentation.Save(stream);
            }
            stream.Position = 0;
            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("Charts.pptx", "application/powerpoint", stream, m_context);
            }
        }
        void OnButtonClicked(object sender, EventArgs e)
        {
            Assembly assembly   = Assembly.GetExecutingAssembly();
            Stream   filestream = assembly.GetManifestResourceStream("SampleBrowser.Samples.XlsIO.Template.NorthwindTemplate.xlsx");

            MemoryStream stream = new MemoryStream();

            filestream.CopyTo(stream);

            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("Template.xlsx", "application/msexcel", stream, m_context);
            }
        }
Exemplo n.º 10
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            Assembly assembly = Assembly.GetExecutingAssembly();
            // Creating a new document.
            WordDocument document    = new WordDocument();
            Stream       inputStream = assembly.GetManifestResourceStream("SampleBrowser.Samples.DocIO.Templates.Template_Letter.doc");

            //Open Template document
            document.Open(inputStream, FormatType.Word2013);
            inputStream.Dispose();

            inputStream = assembly.GetManifestResourceStream("SampleBrowser.Samples.DocIO.Templates.Employees.xml");
            DataSet ds = new DataSet();

            ds.ReadXml(inputStream);
            ArrayList commands = new ArrayList();

            //DictionaryEntry contain "Source table" (KEY) and "Command" (VALUE)
            DictionaryEntry entry = new DictionaryEntry("Employees", string.Empty);

            commands.Add(entry);

            // To retrive customer details
            DataTable table    = ds.Tables["Customers"];
            string    relation = table.ParentRelations[0].ChildColumns[0].ColumnName + " = %Employees." + table.ParentRelations[0].ParentColumns[0].ColumnName + "%";

            entry = new DictionaryEntry("Customers", relation);
            commands.Add(entry);

            // To retrieve order details
            table    = ds.Tables["Orders"];
            relation = table.ParentRelations[0].ChildColumns[0].ColumnName + " = %Customers." + table.ParentRelations[0].ParentColumns[0].ColumnName + "%";
            entry    = new DictionaryEntry("Orders", relation);
            commands.Add(entry);

            //Executes nested Mail merge using explicit relational data.
            document.MailMerge.ExecuteNestedGroup(ds, commands);

            MemoryStream stream = new MemoryStream();

            document.Save(stream, FormatType.Word2013);
            document.Close();
            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("NestedMailMerge.docx", "application/msword", stream, m_context);
            }
        }
Exemplo n.º 11
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            //Create a new PDF document
            PdfDocument document = new PdfDocument(PdfConformanceLevel.Pdf_A1B);

            //Add a page
            PdfPage page = document.Pages.Add();

            //Create font
            Stream  arialFontStream = typeof(Conformance).GetTypeInfo().Assembly.GetManifestResourceStream("SampleBrowser.Samples.PDF.Assets.arial.ttf");
            PdfFont font            = new PdfTrueTypeFont(arialFontStream, 14);

            //Text to draw

            string text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";


            //Create a brush
            PdfBrush   brush      = new PdfSolidBrush(new PdfColor(0, 0, 0));
            PdfPen     pen        = new PdfPen(new PdfColor(0, 0, 0));
            SizeF      clipBounds = page.Graphics.ClientSize;
            RectangleF rect       = new RectangleF(0, 0, clipBounds.Width, clipBounds.Height);

            //Set the property for the text
            PdfStringFormat format = new PdfStringFormat();

            format.Alignment       = PdfTextAlignment.Justify;
            format.ParagraphIndent = 35f;

            //Draw text.
            page.Graphics.DrawString(text, font, brush, rect, format);

            MemoryStream stream = new MemoryStream();

            //Save the PDF dcoument.
            document.Save(stream);

            //Close the PDF document.
            document.Close();

            stream.Position = 0;

            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("PDF_A1b.pdf", "application/pdf", stream, m_context);
            }
        }
Exemplo n.º 12
0
        void ButtonInputClicked(object sender, EventArgs e)
        {
            string   resourcePath = "SampleBrowser.Samples.XlsIO.Template.ExportSales.xlsx";
            Assembly assembly     = Assembly.GetExecutingAssembly();
            Stream   fileStream   = assembly.GetManifestResourceStream(resourcePath);

            MemoryStream stream = new MemoryStream();

            fileStream.CopyTo(stream);

            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("Input Template.xlsx", "application/msexcel", stream, m_context);
            }
        }
Exemplo n.º 13
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            //Stream to save the created PowerPoint presnetation
            MemoryStream stream = new MemoryStream();

            //Creates a new instance of the presentation.
            using (IPresentation presentation = Syncfusion.Presentation.Presentation.Create())
            {
                #region Slide1
                //To add a slide to PowerPoint presentation
                ISlide slide = presentation.Slides.Add(SlideLayoutType.TitleOnly);
                //To set the table title in a slide
                SetTableTitle(slide);
                //To get the table data from an XML file
                Dictionary <string, Dictionary <string, string> > products = LoadXMLData();
                int columnCount = products.Keys.Count + 1;
                int rowCount    = products[products.Keys.ToArray()[0]].Count + 1;
                //To add a new table in slide.
                ITable table = slide.Shapes.AddTable(rowCount, columnCount, 61.92, 95.76, 856.8, 378.72);
                //To set the style for the table.
                table.BuiltInStyle = BuiltInTableStyle.MediumStyle2Accent6;
                //To set category title
                SetCategoryTitle(table);
                //Iterates and sets the values to the table cells.
                for (int rowIndex = 0; rowIndex < table.Rows.Count; rowIndex++)
                {
                    IRow row = table.Rows[rowIndex];
                    Dictionary <string, string> months = products[products.Keys.ToArray()[0]];
                    string[] monthName = months.Keys.ToArray();
                    for (int cellIndex = 0; cellIndex < row.Cells.Count - 1; cellIndex++)
                    {
                        months = products[products.Keys.ToArray()[cellIndex]];
                        AddHeaderRowAndColumn(row, cellIndex, products.Keys.ToArray(), rowIndex, monthName);
                        AddCellContent(row, rowIndex, monthName, months, cellIndex);
                    }
                }
                #endregion
                //Save the presentation instance to the memory stream.
                presentation.Save(stream);
            }
            stream.Position = 0;
            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("Tables.pptx", "application/powerpoint", stream, m_context);
            }
        }
Exemplo n.º 14
0
        void OnInpTemplateButtonClicked(object sender, EventArgs e)
        {
            string   resourcePath = "SampleBrowser.Samples.Presentation.Templates.ShapeWithAnimation.pptx";
            Assembly assembly     = Assembly.GetExecutingAssembly();
            Stream   fileStream   = assembly.GetManifestResourceStream(resourcePath);

            MemoryStream stream = new MemoryStream();

            fileStream.CopyTo(stream);
            fileStream.Dispose();
            stream.Position = 0;
            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("InputTemplate.pptx", "application/powerpoint", stream, m_context);
            }
        }
Exemplo n.º 15
0
        void OnButtonClicked1(object sender, EventArgs e)
        {
            ExcelEngine  excelEngine = new ExcelEngine();
            IApplication application = excelEngine.Excel;

            application.DefaultVersion = ExcelVersion.Excel2013;
            int index = spinner.SelectedItemPosition;

            string resourcePath = "";

            if (index == 6)
            {
                resourcePath = "SampleBrowser.Samples.XlsIO.Template.AdvancedFilterData.xlsx";
            }
            else if (index == 5)
            {
                resourcePath = "SampleBrowser.Samples.XlsIO.Template.IconFilterData.xlsx";
            }
            else if (index == 4)
            {
                resourcePath = "SampleBrowser.Samples.XlsIO.Template.FilterData_Color.xlsx";
            }
            else
            {
                resourcePath = "SampleBrowser.Samples.XlsIO.Template.FilterData.xlsx";
            }
            Assembly assembly   = Assembly.GetExecutingAssembly();
            Stream   fileStream = assembly.GetManifestResourceStream(resourcePath);

            IWorkbook  workbook = application.Workbooks.Open(fileStream);
            IWorksheet sheet    = workbook.Worksheets[0];

            workbook.Version = ExcelVersion.Excel2013;

            MemoryStream stream = new MemoryStream();

            workbook.SaveAs(stream);
            workbook.Close();
            excelEngine.Dispose();

            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("Input Template.xlsx", "application/msexcel", stream, m_context);
            }
        }
Exemplo n.º 16
0
        void OnInpTemplateButtonClicked(object sender, EventArgs e)
        {
            string   resourcePath = "SampleBrowser.Samples.DocIO.Templates.WordtoPDF.docx";
            Assembly assembly     = Assembly.GetExecutingAssembly();
            Stream   fileStream   = assembly.GetManifestResourceStream(resourcePath);

            MemoryStream stream = new MemoryStream();

            fileStream.CopyTo(stream);
            fileStream.Dispose();
            stream.Position = 0;
            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("WordtoPDF.docx", "application/msword", stream, m_context);
            }
        }
Exemplo n.º 17
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            string   resourcePath = "SampleBrowser.Samples.DocIO.Templates.WordtoPDF.docx";
            Assembly assembly     = Assembly.GetExecutingAssembly();
            Stream   fileStream   = assembly.GetManifestResourceStream(resourcePath);

            // Loads the stream into Word Document.
            WordDocument wordDocument = new WordDocument(fileStream, Syncfusion.DocIO.FormatType.Automatic);

            //Instantiation of DocIORenderer for Word to PDF conversion
            DocIORenderer render = new DocIORenderer();

            //Sets Chart rendering Options.
            render.Settings.ChartRenderingOptions.ImageFormat = ExportImageFormat.Jpeg;

            //Sets ShowInBalloons to render a document comments in converted PDF document.
            wordDocument.RevisionOptions.CommentDisplayMode = CommentDisplayMode.ShowInBalloons;
            //Sets the color to be used for Comment Balloon
            wordDocument.RevisionOptions.CommentColor = RevisionColor.Blue;

            //Converts Word document into PDF document
            PdfDocument pdfDocument = render.ConvertToPDF(wordDocument);

            //Releases all resources used by the Word document and DocIO Renderer objects
            render.Dispose();

            wordDocument.Dispose();

            MemoryStream pdfStream = new MemoryStream();

            //Save the converted PDF document into MemoryStream.
            pdfDocument.Save(pdfStream);
            pdfStream.Position = 0;

            //Close the PDF document.
            pdfDocument.Close(true);

            if (pdfStream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("WordtoPDF.pdf", "application/pdf", pdfStream, m_context);
            }
        }
Exemplo n.º 18
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            Stream            docStream = typeof(Booklet).GetTypeInfo().Assembly.GetManifestResourceStream("SampleBrowser.Samples.PDF.Assets.JavaScript Succinctly.pdf");
            PdfLoadedDocument ldoc      = new PdfLoadedDocument(docStream);
            float             width     = 1224;
            float             height    = 792;

            PdfDocument  document = PdfBookletCreator.CreateBooklet(ldoc, new Syncfusion.Drawing.SizeF(width, height), true);
            MemoryStream stream   = new MemoryStream();

            document.Save(stream);
            document.Close(true);

            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("Booklet.pdf", "application/pdf", stream, m_context);
            }
        }
Exemplo n.º 19
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            string   resourcePath = "SampleBrowser.Samples.Presentation.Templates.HeaderFooter.pptx";
            Assembly assembly     = Assembly.GetExecutingAssembly();
            Stream   fileStream   = assembly.GetManifestResourceStream(resourcePath);

            //Open a existing PowerPoint presentation
            IPresentation presentation = Syncfusion.Presentation.Presentation.Open(fileStream);

            //Add footers into all the PowerPoint slides.
            foreach (ISlide slide in presentation.Slides)
            {
                //Enable a date and time footer in slide.
                slide.HeadersFooters.DateAndTime.Visible = true;
                //Enable a footer in slide.
                slide.HeadersFooters.Footer.Visible = true;
                //Sets the footer text.
                slide.HeadersFooters.Footer.Text = "Footer";
                //Enable a slide number footer in slide.
                slide.HeadersFooters.SlideNumber.Visible = true;
            }

            //Add header into first slide notes page.
            //Add a notes slide to the slide.
            INotesSlide notesSlide = presentation.Slides[0].AddNotesSlide();

            //Enable a header in notes slide.
            notesSlide.HeadersFooters.Header.Visible = true;
            //Sets the header text.
            notesSlide.HeadersFooters.Header.Text = "Header";

            MemoryStream stream = new MemoryStream();

            presentation.Save(stream);
            presentation.Close();
            stream.Position = 0;
            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("HeaderFooter.pptx", "application/powerpoint", stream, m_context);
            }
        }
Exemplo n.º 20
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            //Create ZugFerd invoice PDF
            PdfDocument document = new PdfDocument(PdfConformanceLevel.Pdf_A3B);

            document.ZugferdVersion          = ZugferdVersion.ZugferdVersion2_0;
            document.ZugferdConformanceLevel = ZugferdConformanceLevel.Extended;

            CreateZugFerdInvoicePDF(document);

            //Create ZugFerd Xml attachment file
            Stream zugferdXmlStream = CreateZugFerdXML();

            //Creates an attachment.
            PdfAttachment attachment = new PdfAttachment("ZUGFeRD-invoice.xml", zugferdXmlStream);

            attachment.Relationship     = PdfAttachmentRelationship.Alternative;
            attachment.ModificationDate = DateTime.Now;

            attachment.Description = "Adventure Invoice";

            attachment.MimeType = "application/xml";

            document.Attachments.Add(attachment);

            MemoryStream stream = new MemoryStream();

            //Save the PDF document.
            document.Save(stream);

            //Close the PDF document.
            document.Close();

            stream.Position = 0;

            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("ZugFerd.pdf", "application/pdf", stream, m_context);
            }
        }
Exemplo n.º 21
0
        void OnButtonClicked_1(object sender, EventArgs e)
        {
            ExcelEngine  excelEngine = new ExcelEngine();
            IApplication application = excelEngine.Excel;

            application.DefaultVersion = ExcelVersion.Excel2013;

            #region Initializing Workbook
            string   resourcePath = "SampleBrowser.Samples.XlsIO.Template.ReplaceOptions.xlsx";
            Assembly assembly     = Assembly.GetExecutingAssembly();
            Stream   fileStream   = assembly.GetManifestResourceStream(resourcePath);

            IWorkbook workbook = application.Workbooks.Open(fileStream);

            //The first worksheet object in the worksheets collection is accessed.
            IWorksheet sheet = workbook.Worksheets[0];
            sheet["A60"].Activate();
            #endregion

            string replaceText = "Berlin";

            ExcelFindOptions option = ExcelFindOptions.None;
            option |= ExcelFindOptions.MatchCase;
            option |= ExcelFindOptions.MatchEntireCellContent;

            sheet.Replace(replaceText, "Rome", option);

            workbook.Version = ExcelVersion.Excel2013;


            MemoryStream stream = new MemoryStream();
            workbook.SaveAs(stream);
            workbook.Close();
            excelEngine.Dispose();

            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("ReplacedFile.xlsx", "application/msexcel", stream, m_context);
            }
        }
Exemplo n.º 22
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            ExcelEngine  excelEngine = new ExcelEngine();
            IApplication application = excelEngine.Excel;

            application.DefaultVersion = ExcelVersion.Excel2013;

            #region Initializing Workbook
            string   resourcePath = "SampleBrowser.Samples.XlsIO.Template.ChartData.xlsx";
            Assembly assembly     = Assembly.GetExecutingAssembly();
            Stream   fileStream   = assembly.GetManifestResourceStream(resourcePath);

            IWorkbook  workbook = application.Workbooks.Open(fileStream);
            IWorksheet sheet    = workbook.Worksheets[0];
            #endregion

            #region Generate Chart
            IChartShape chart = sheet.Charts.Add();

            chart.DataRange   = sheet["A16:E26"];
            chart.ChartTitle  = sheet["A15"].Text;
            chart.HasLegend   = false;
            chart.TopRow      = 3;
            chart.LeftColumn  = 1;
            chart.RightColumn = 6;
            chart.BottomRow   = 15;
            #endregion

            workbook.Version = ExcelVersion.Excel2013;

            MemoryStream stream = new MemoryStream();
            workbook.SaveAs(stream);
            workbook.Close();
            excelEngine.Dispose();

            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("Charts.xlsx", "application/msexcel", stream, m_context);
            }
        }
Exemplo n.º 23
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            string resourcePath = "SampleBrowser.Samples.Presentation.Templates.Animation.pptx";
			Assembly assembly = Assembly.GetExecutingAssembly();
            Stream fileStream = assembly.GetManifestResourceStream(resourcePath);

            IPresentation presentation = Syncfusion.Presentation.Presentation.Open(fileStream);
			
           //Modify the existing animation
            CreateAnimationWithShape(presentation);

            MemoryStream stream = new MemoryStream();
            presentation.Save(stream);
            presentation.Close();
            stream.Position = 0;
			if (stream != null)
			{
				SaveAndroid androidSave = new SaveAndroid ();
				androidSave.Save ("CreateAnimationSample.pptx", "application/powerpoint", stream, m_context);
			}
        }
        void OnButtonClicked1(object sender, EventArgs e)
        {
            Assembly     assembly    = Assembly.GetExecutingAssembly();
            Stream       inputStream = assembly.GetManifestResourceStream("SampleBrowser.Samples.DocIO.Templates.Bookmark_Template.docx");
            MemoryStream stream      = new MemoryStream();

            inputStream.CopyTo(stream);
            stream.Position = 0;
            inputStream.Dispose();
            //Set file content type
            string contentType = null;
            string fileName    = null;

            //Save the document as docx
            fileName    = "Bookmark_Template.docx";
            contentType = "application/msword";
            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save(fileName, contentType, stream, m_context);
            }
        }
Exemplo n.º 25
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            string   resourcePath = "SampleBrowser.Samples.Presentation.Templates.Transition.pptx";
            Assembly assembly     = Assembly.GetExecutingAssembly();
            Stream   fileStream   = assembly.GetManifestResourceStream(resourcePath);

            IPresentation presentation = Syncfusion.Presentation.Presentation.Open(fileStream);

            //Set the write protection for presentation instance
            presentation.SetWriteProtection("syncfusion");

            MemoryStream stream = new MemoryStream();

            presentation.Save(stream);
            presentation.Close();
            stream.Position = 0;
            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("WriteProtection.pptx", "application/powerpoint", stream, m_context);
            }
        }
Exemplo n.º 26
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            ExcelEngine  excelEngine = new ExcelEngine();
            IApplication application = excelEngine.Excel;

            application.DefaultVersion = ExcelVersion.Excel2013;

            string   resourcePath = "SampleBrowser.Samples.XlsIO.Template.ReplaceOptions.xlsx";
            Assembly assembly     = Assembly.GetExecutingAssembly();
            Stream   fileStream   = assembly.GetManifestResourceStream(resourcePath);

            IWorkbook    workbook = application.Workbooks.Open(fileStream);
            MemoryStream stream   = new MemoryStream();

            workbook.SaveAs(stream);
            workbook.Close();
            excelEngine.Dispose();

            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("InputTemplate.xlsx", "application/msexcel", stream, m_context);
            }
        }
Exemplo n.º 27
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            string   resourcePath = "SampleBrowser.Samples.Presentation.Templates.Slides.pptx";
            Assembly assembly     = Assembly.GetExecutingAssembly();
            Stream   fileStream   = assembly.GetManifestResourceStream(resourcePath);

            IPresentation presentation = Syncfusion.Presentation.Presentation.Open(fileStream);

            #region Slide1
            ISlide slide1 = presentation.Slides[0];
            IShape shape1 = slide1.Shapes[0] as IShape;
            shape1.Left   = 108;
            shape1.Top    = 139.68;
            shape1.Width  = 743.04;
            shape1.Height = 144;

            ITextBody   textFrame1  = shape1.TextBody;
            IParagraphs paragraphs1 = textFrame1.Paragraphs;
            IParagraph  paragraph1  = paragraphs1.Add();
            paragraphs1[0].IndentLevelNumber = 0;

            AddParagraphData(paragraph1, "ESSENTIAL PRESENTATION", "Calibri", 48, true);
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            slide1.Shapes.RemoveAt(1);
            #endregion

            #region Slide2
            ISlide slide2 = presentation.Slides.Add(SlideLayoutType.SectionHeader);
            shape1        = slide2.Shapes[0] as IShape;
            shape1.Left   = 55;
            shape1.Top    = 23;
            shape1.Width  = 573;
            shape1.Height = 71;
            textFrame1    = shape1.TextBody;

            //Instance to hold paragraphs in textframe
            paragraphs1 = textFrame1.Paragraphs;
            paragraph1  = paragraphs1.Add();
            AddParagraphData(paragraph1, "Slide with simple text", "Calibri", 40, false);
            paragraphs1[0].HorizontalAlignment = HorizontalAlignmentType.Left;

            IShape shape2 = slide2.Shapes[1] as IShape;
            shape2.Left   = 87;
            shape2.Top    = 119;
            shape2.Width  = 725;
            shape2.Height = 355;
            ITextBody textFrame2 = shape2.TextBody;

            //Instance to hold paragraphs in textframe
            IParagraphs paragraphs2 = textFrame2.Paragraphs;

            //Add paragrpah text
            IParagraph paragraph_1 = paragraphs2.Add();
            AddParagraphData(paragraph_1, "Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Bothell, Washington with 290 employees, several regional sales teams are located throughout their market base.", "Calibri", 15, false);

            IParagraph paragraph_2 = paragraphs2.Add();
            AddParagraphData(paragraph_2, "In 2000, Adventure Works Cycles bought a small manufacturing plant, Importadores Neptuno, located in Mexico. Importadores Neptuno manufactures several critical subcomponents for the Adventure Works Cycles product line. These subcomponents are shipped to the Bothell location for final product assembly. In 2001, Importadores Neptuno, became the sole manufacturer and distributor of the touring bicycle product group.", "Calibri", 15, false);
            #endregion

            #region Slide3
            slide2        = presentation.Slides.Add(SlideLayoutType.TwoContent);
            shape1        = slide2.Shapes[0] as IShape;
            shape1.Left   = 26;
            shape1.Top    = 37;
            shape1.Width  = 815;
            shape1.Height = 76;

            //Adds textframe in shape
            textFrame1 = shape1.TextBody;

            //Instance to hold paragraphs in textframe
            paragraphs1 = textFrame1.Paragraphs;
            paragraphs1.Add();
            paragraph1 = paragraphs1[0];
            AddParagraphData(paragraph1, "Slide with Image", "Calibri", 44, false);

            //Adds shape in slide
            shape2        = slide2.Shapes[1] as IShape;
            shape2.Left   = 578;
            shape2.Top    = 141;
            shape2.Width  = 316;
            shape2.Height = 326;
            textFrame2    = shape2.TextBody;

            //Instance to hold paragraphs in textframe
            paragraphs2 = textFrame2.Paragraphs;
            IParagraph paragraph2 = paragraphs2.Add();

            AddParagraphData(paragraph2, "The Northwind sample database (Northwind.mdb) is included with all versions of Access. It provides data you can experiment with and database objects that demonstrate features you might want to implement in your own databases.", "Calibri", 16, false);
            IParagraph paragraph3 = paragraphs2.Add();

            AddParagraphData(paragraph3, "Using Northwind, you can become familiar with how a relational database is structured and how the database objects work together to help you enter, store, manipulate, and print your data.", "Calibri", 16, false);
            IParagraph paragraph4 = paragraphs2.Add();

            //           AddParagraphData(paragraph4, ref textpart1, "While its base operation is located in Bothell, Washington with 290 employees, several regional sales teams are located throughout their market base.", "Calibri", 16);
            IShape shape3 = (IShape)slide2.Shapes[2];
            slide2.Shapes.RemoveAt(2);


            //Adds picture in the shape
            resourcePath = "SampleBrowser.Samples.Presentation.Templates.tablet.jpg";
            assembly     = Assembly.GetExecutingAssembly();
            fileStream   = assembly.GetManifestResourceStream(resourcePath);
            IPicture picture1 = slide2.Shapes.AddPicture(fileStream, 58, 141, 477, 318);
            fileStream.Close();
            #endregion

            #region Slide4
            ISlide slide4 = presentation.Slides.Add(SlideLayoutType.TwoContent);
            shape1        = slide4.Shapes[0] as IShape;
            shape1.Left   = 37;
            shape1.Top    = 24;
            shape1.Width  = 815;
            shape1.Height = 76;
            textFrame1    = shape1.TextBody;

            //Instance to hold paragraphs in textframe
            paragraphs1 = textFrame1.Paragraphs;
            paragraphs1.Add();
            paragraph1 = paragraphs1[0];

            AddParagraphData(paragraph1, "Slide with Table", "Calibri", 44, false);
            shape2 = slide4.Shapes[1] as IShape;
            slide4.Shapes.Remove(shape2);

            ITable table = (ITable)slide4.Shapes.AddTable(6, 6, 58, 154, 823, 273);
            table.Rows[0].Height   = 61.2;
            table.Rows[1].Height   = 30;
            table.Rows[2].Height   = 61;
            table.Rows[3].Height   = 61;
            table.Rows[4].Height   = 61;
            table.Rows[5].Height   = 61;
            table.HasBandedRows    = true;
            table.HasHeaderRow     = true;
            table.HasBandedColumns = false;
            table.BuiltInStyle     = BuiltInTableStyle.MediumStyle2Accent1;

            ICell cell1 = table.Rows[0].Cells[0];
            textFrame2 = cell1.TextBody;
            paragraph2 = textFrame2.Paragraphs.Add();
            paragraph2.HorizontalAlignment = HorizontalAlignmentType.Center;
            ITextPart textPart2 = paragraph2.AddTextPart();
            textPart2.Text = "ID";

            ICell     cell2      = table.Rows[0].Cells[1];
            ITextBody textFrame3 = cell2.TextBody;
            paragraph3 = textFrame3.Paragraphs.Add();
            paragraph3.HorizontalAlignment = HorizontalAlignmentType.Center;
            ITextPart textPart3 = paragraph3.AddTextPart();
            textPart3.Text = "Company Name";

            ICell     cell3      = table.Rows[0].Cells[2];
            ITextBody textFrame4 = cell3.TextBody;
            paragraph4 = textFrame4.Paragraphs.Add();
            paragraph4.HorizontalAlignment = HorizontalAlignmentType.Center;
            ITextPart textPart4 = paragraph4.AddTextPart();
            textPart4.Text = "Contact Name";

            ICell      cell4      = table.Rows[0].Cells[3];
            ITextBody  textFrame5 = cell4.TextBody;
            IParagraph paragraph5 = textFrame5.Paragraphs.Add();
            paragraph5.HorizontalAlignment = HorizontalAlignmentType.Center;
            ITextPart textPart5 = paragraph5.AddTextPart();
            textPart5.Text = "Address";

            ICell      cell5      = table.Rows[0].Cells[4];
            ITextBody  textFrame6 = cell5.TextBody;
            IParagraph paragraph6 = textFrame6.Paragraphs.Add();
            paragraph6.HorizontalAlignment = HorizontalAlignmentType.Center;
            ITextPart textPart6 = paragraph6.AddTextPart();
            textPart6.Text = "City";

            ICell      cell6      = table.Rows[0].Cells[5];
            ITextBody  textFrame7 = cell6.TextBody;
            IParagraph paragraph7 = textFrame7.Paragraphs.Add();
            paragraph7.HorizontalAlignment = HorizontalAlignmentType.Center;
            ITextPart textPart7 = paragraph7.AddTextPart();
            textPart7.Text = "Country";

            //Add data in table
            AddTableData(cell1, table, textFrame1, paragraph1);
            slide4.Shapes.RemoveAt(1);
            #endregion

            MemoryStream stream = new MemoryStream();
            presentation.Save(stream);
            presentation.Close();
            stream.Position = 0;
            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("Charts.pptx", "application/powerpoint", stream, m_context);
            }
        }
Exemplo n.º 28
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            string   resourcePath = "SampleBrowser.Samples.DocIO.Templates.CreateEquation.docx";
            Assembly assembly     = Assembly.GetExecutingAssembly();
            Stream   fileStream   = assembly.GetManifestResourceStream(resourcePath);

            // Loads the stream into Word Document.
            WordDocument document = new WordDocument(fileStream, Syncfusion.DocIO.FormatType.Automatic);
            //Gets the last section in the document
            WSection section = document.LastSection;

            //Sets page margins
            document.LastSection.PageSetup.Margins.All = 72;
            //Adds new paragraph to the section
            IWParagraph paragraph = section.AddParagraph();

            //Appends text to paragraph
            IWTextRange textRange = paragraph.AppendText("Mathematical equations");

            textRange.CharacterFormat.FontSize            = 28;
            paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
            paragraph.ParagraphFormat.AfterSpacing        = 12;

            #region Sum to the power of n
            //Adds new paragraph to the section
            paragraph = AddParagraph(section, "This is an expansion of the sum (1+X) to the power of n.");
            //Creates an equation with sum to the power of N
            CreateSumToThePowerOfN(paragraph);
            #endregion

            #region Fourier series
            //Adds new paragraph to the section
            paragraph = AddParagraph(section, "This is a Fourier series for the function of period 2L");
            //Creates a Fourier series equation
            CreateFourierseries(paragraph);
            #endregion

            #region Triple scalar product
            //Adds new paragraph to the section
            paragraph = AddParagraph(section, "This is an expansion of triple scalar product");
            //Creates a triple scalar product equation
            CreateTripleScalarProduct(paragraph);
            #endregion

            #region Gamma function
            //Adds new paragraph to the section
            paragraph = AddParagraph(section, "This is an expansion of gamma function");
            //Creates a gamma function equation
            CreateGammaFunction(paragraph);
            #endregion

            #region Vector relation
            //Adds new paragraph to the section
            paragraph = AddParagraph(section, "This is an expansion of vector relation ");
            //Creates a vector relation equation
            CreateVectorRelation(paragraph);
            #endregion

            MemoryStream stream = new MemoryStream();
            //Set file content type
            string contentType = null;
            string fileName    = null;
            if (docxButton.Checked)
            {
                fileName    = "CreateEquation.docx";
                contentType = "application/msword";
                document.Save(stream, FormatType.Docx);
            }
            else
            {
                fileName    = "CreateEquation.pdf";
                contentType = "application/pdf";
                DocIORenderer renderer = new DocIORenderer();
                PdfDocument   pdfDoc   = renderer.ConvertToPDF(document);
                pdfDoc.Save(stream);

                pdfDoc.Close();
            }

            document.Dispose();
            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save(fileName, contentType, stream, m_context);
            }
        }
Exemplo n.º 29
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            //Instantiate excel engine
            ExcelEngine excelEngine = new ExcelEngine();
            //Excel application
            IApplication application = excelEngine.Excel;

            application.DefaultVersion = ExcelVersion.Excel2013;

            #region Initializing Workbook
            //A new workbook is created.[Equivalent to creating a new workbook in MS Excel]
            //The new workbook will have 1 worksheet
            IWorkbook workbook = application.Workbooks.Create(1);

            //The first worksheet object in the worksheets collection is accessed.
            IWorksheet sheet = workbook.Worksheets[0];
            #endregion

            #region Generate Excel

            sheet.EnableSheetCalculations();

            sheet.Range["A2"].ColumnWidth = 20;
            sheet.Range["B2"].ColumnWidth = 13;
            sheet.Range["C2"].ColumnWidth = 13;
            sheet.Range["D2"].ColumnWidth = 13;

            sheet.Range["A2:D2"].Merge(true);

            //Inserting sample text into the first cell of the first worksheet.
            sheet.Range["A2"].Text = "EXPENSE REPORT";
            sheet.Range["A2"].CellStyle.Font.FontName = "Verdana";
            sheet.Range["A2"].CellStyle.Font.Bold     = true;
            sheet.Range["A2"].CellStyle.Font.Size     = 28;
            sheet.Range["A2"].CellStyle.Font.RGBColor = COLOR.Color.FromArgb(255, 0, 112, 192);
            sheet.Range["A2"].HorizontalAlignment     = ExcelHAlign.HAlignCenter;
            sheet.Range["A2"].RowHeight = 34;

            sheet.Range["A4"].Text = "Employee";
            sheet.Range["B4"].Text = "Roger Federer";
            sheet.Range["A4:B7"].CellStyle.Font.FontName = "Verdana";
            sheet.Range["A4:B7"].CellStyle.Font.Bold     = true;
            sheet.Range["A4:B7"].CellStyle.Font.Size     = 11;
            sheet.Range["A4:A7"].CellStyle.Font.RGBColor = COLOR.Color.FromArgb(255, 128, 128, 128);
            sheet.Range["A4:A7"].HorizontalAlignment     = ExcelHAlign.HAlignLeft;
            sheet.Range["B4:B7"].CellStyle.Font.RGBColor = COLOR.Color.FromArgb(255, 174, 170, 170);
            sheet.Range["B4:B7"].HorizontalAlignment     = ExcelHAlign.HAlignRight;
            sheet.Range["B4:D4"].Merge(true);

            sheet.Range["A9:D20"].CellStyle.Font.FontName = "Verdana";
            sheet.Range["A9:D20"].CellStyle.Font.Size     = 11;

            sheet.Range["A5"].Text = "Department";
            sheet.Range["B5"].Text = "Administration";
            sheet.Range["B5:D5"].Merge(true);

            sheet.Range["A6"].Text         = "Week Ending";
            sheet.Range["B6"].NumberFormat = "m/d/yyyy";
            sheet.Range["B6"].DateTime     = DateTime.Parse("10/10/2012");
            sheet.Range["B6:D6"].Merge(true);

            sheet.Range["A7"].Text         = "Mileage Rate";
            sheet.Range["B7"].NumberFormat = "$#,##0.00";
            sheet.Range["B7"].Number       = 0.70;
            sheet.Range["B7:D7"].Merge(true);

            sheet.Range["A10"].Text = "Miles Driven";
            sheet.Range["A11"].Text = "Reimbursement";
            sheet.Range["A12"].Text = "Parking/Tolls";
            sheet.Range["A13"].Text = "Auto Rental";
            sheet.Range["A14"].Text = "Lodging";
            sheet.Range["A15"].Text = "Breakfast";
            sheet.Range["A16"].Text = "Lunch";
            sheet.Range["A17"].Text = "Dinner";
            sheet.Range["A18"].Text = "Snacks";
            sheet.Range["A19"].Text = "Others";
            sheet.Range["A20"].Text = "Total";
            sheet.Range["A20:D20"].CellStyle.Color      = COLOR.Color.FromArgb(255, 0, 112, 192);
            sheet.Range["A20:D20"].CellStyle.Font.Color = ExcelKnownColors.Black;
            sheet.Range["A20:D20"].CellStyle.Font.Bold  = true;

            IStyle style = sheet["B9:D9"].CellStyle;
            style.VerticalAlignment   = ExcelVAlign.VAlignCenter;
            style.HorizontalAlignment = ExcelHAlign.HAlignRight;
            style.Color      = COLOR.Color.FromArgb(255, 0, 112, 192);
            style.Font.Bold  = true;
            style.Font.Color = ExcelKnownColors.Black;

            sheet.Range["A9"].Text                 = "Expenses";
            sheet.Range["A9"].CellStyle.Color      = COLOR.Color.FromArgb(255, 0, 112, 192);
            sheet.Range["A9"].CellStyle.Font.Color = ExcelKnownColors.White;
            sheet.Range["A9"].CellStyle.Font.Bold  = true;
            sheet.Range["B9"].Text                 = "Day 1";
            sheet.Range["B10"].Number              = 100;
            sheet.Range["B11"].NumberFormat        = "$#,##0.00";
            sheet.Range["B11"].Formula             = "=(B7*B10)";
            sheet.Range["B12"].NumberFormat        = "$#,##0.00";
            sheet.Range["B12"].Number              = 0;
            sheet.Range["B13"].NumberFormat        = "$#,##0.00";
            sheet.Range["B13"].Number              = 0;
            sheet.Range["B14"].NumberFormat        = "$#,##0.00";
            sheet.Range["B14"].Number              = 0;
            sheet.Range["B15"].NumberFormat        = "$#,##0.00";
            sheet.Range["B15"].Number              = 9;
            sheet.Range["B16"].NumberFormat        = "$#,##0.00";
            sheet.Range["B16"].Number              = 12;
            sheet.Range["B17"].NumberFormat        = "$#,##0.00";
            sheet.Range["B17"].Number              = 13;
            sheet.Range["B18"].NumberFormat        = "$#,##0.00";
            sheet.Range["B18"].Number              = 9.5;
            sheet.Range["B19"].NumberFormat        = "$#,##0.00";
            sheet.Range["B19"].Number              = 0;
            sheet.Range["B20"].NumberFormat        = "$#,##0.00";
            sheet.Range["B20"].Formula             = "=SUM(B11:B19)";

            sheet.Range["C9"].Text          = "Day 2";
            sheet.Range["C10"].Number       = 145;
            sheet.Range["C11"].NumberFormat = "$#,##0.00";
            sheet.Range["C11"].Formula      = "=(B7*C10)";
            sheet.Range["C12"].NumberFormat = "$#,##0.00";
            sheet.Range["C12"].Number       = 15;
            sheet.Range["C13"].NumberFormat = "$#,##0.00";
            sheet.Range["C13"].Number       = 0;
            sheet.Range["C14"].NumberFormat = "$#,##0.00";
            sheet.Range["C14"].Number       = 45;
            sheet.Range["C15"].NumberFormat = "$#,##0.00";
            sheet.Range["C15"].Number       = 9;
            sheet.Range["C16"].NumberFormat = "$#,##0.00";
            sheet.Range["C16"].Number       = 12;
            sheet.Range["C17"].NumberFormat = "$#,##0.00";
            sheet.Range["C17"].Number       = 15;
            sheet.Range["C18"].NumberFormat = "$#,##0.00";
            sheet.Range["C18"].Number       = 7;
            sheet.Range["C19"].NumberFormat = "$#,##0.00";
            sheet.Range["C19"].Number       = 0;
            sheet.Range["C20"].NumberFormat = "$#,##0.00";
            sheet.Range["C20"].Formula      = "=SUM(C11:C19)";

            sheet.Range["D9"].Text          = "Day 3";
            sheet.Range["D10"].Number       = 113;
            sheet.Range["D11"].NumberFormat = "$#,##0.00";
            sheet.Range["D11"].Formula      = "=(B7*D10)";
            sheet.Range["D12"].NumberFormat = "$#,##0.00";
            sheet.Range["D12"].Number       = 17;
            sheet.Range["D13"].NumberFormat = "$#,##0.00";
            sheet.Range["D13"].Number       = 8;
            sheet.Range["D14"].NumberFormat = "$#,##0.00";
            sheet.Range["D14"].Number       = 45;
            sheet.Range["D15"].NumberFormat = "$#,##0.00";
            sheet.Range["D15"].Number       = 7;
            sheet.Range["D16"].NumberFormat = "$#,##0.00";
            sheet.Range["D16"].Number       = 11;
            sheet.Range["D17"].NumberFormat = "$#,##0.00";
            sheet.Range["D17"].Number       = 16;
            sheet.Range["D18"].NumberFormat = "$#,##0.00";
            sheet.Range["D18"].Number       = 7;
            sheet.Range["D19"].NumberFormat = "$#,##0.00";
            sheet.Range["D19"].Number       = 5;
            sheet.Range["D20"].NumberFormat = "$#,##0.00";
            sheet.Range["D20"].Formula      = "=SUM(D11:D19)";

            sheet.Range["A10:D10"].CellStyle.Font.RGBColor = COLOR.Color.FromArgb(255, 174, 170, 170);
            #endregion

            workbook.Version = ExcelVersion.Excel2013;

            MemoryStream stream = new MemoryStream();
            workbook.SaveAs(stream);
            workbook.Close();
            excelEngine.Dispose();


            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("CreateSheet.xlsx", "application/msexcel", stream, m_context);
            }
        }
        void OnButtonClicked(object sender, EventArgs e)
        {
            Assembly assembly = Assembly.GetExecutingAssembly();
            // Creating a new document.
            WordDocument document = new WordDocument();

            //Adds section with one empty paragraph to the Word document
            document.EnsureMinimal();
            //sets the page margins
            document.LastSection.PageSetup.Margins.All = 72f;
            //Appends bookmark to the paragraph
            document.LastParagraph.AppendBookmarkStart("NorthwindDatabase");
            document.LastParagraph.AppendText("Northwind database with relational data");
            document.LastParagraph.AppendBookmarkEnd("NorthwindDatabase");
            // Open an existing template document with single section.
            WordDocument nwdInformation = new WordDocument();
            Stream       inputStream    = assembly.GetManifestResourceStream("SampleBrowser.Samples.DocIO.Templates.Bookmark_Template.docx");

            // Open an existing template document.
            nwdInformation.Open(inputStream, FormatType.Doc);
            inputStream.Dispose();
            // Open an existing template document with multiple section.
            WordDocument templateDocument = new WordDocument();

            inputStream = assembly.GetManifestResourceStream("SampleBrowser.Samples.DocIO.Templates.BkmkDocumentPart_Template.docx");
            // Open an existing template document.
            templateDocument.Open(inputStream, FormatType.Doc);
            inputStream.Dispose();
            // Creating a bookmark navigator. Which help us to navigate through the
            // bookmarks in the template document.
            BookmarksNavigator bk = new BookmarksNavigator(templateDocument);

            // Move to the NorthWind bookmark in template document
            bk.MoveToBookmark("NorthWind");
            //Gets the bookmark content as WordDocumentPart
            WordDocumentPart documentPart = bk.GetContent();

            // Creating a bookmark navigator. Which help us to navigate through the
            // bookmarks in the Northwind information document.
            bk = new BookmarksNavigator(nwdInformation);
            // Move to the information bookmark
            bk.MoveToBookmark("Information");
            // Get the content of information bookmark.
            TextBodyPart bodyPart = bk.GetBookmarkContent();

            // Creating a bookmark navigator. Which help us to navigate through the
            // bookmarks in the destination document.
            bk = new BookmarksNavigator(document);
            // Move to the NorthWind database in the destination document
            bk.MoveToBookmark("NorthwindDatabase");
            //Replace the bookmark content using word document parts
            bk.ReplaceContent(documentPart);
            // Move to the Northwind_Information in the destination document
            bk.MoveToBookmark("Northwind_Information");
            // Replacing content of Northwind_Information bookmark.
            bk.ReplaceBookmarkContent(bodyPart);
            #region Bookmark selection for table
            // Creating a bookmark navigator. Which help us to navigate through the
            // bookmarks in the Northwind information document.
            bk = new BookmarksNavigator(nwdInformation);
            bk.MoveToBookmark("SuppliersTable");
            //Sets the column index where the bookmark starts within the table
            bk.CurrentBookmark.FirstColumn = 1;
            //Sets the column index where the bookmark ends within the table
            bk.CurrentBookmark.LastColumn = 5;
            // Get the content of suppliers table bookmark.
            bodyPart = bk.GetBookmarkContent();
            // Creating a bookmark navigator. Which help us to navigate through the
            // bookmarks in the destination document.
            bk = new BookmarksNavigator(document);
            bk.MoveToBookmark("Table");
            bk.ReplaceBookmarkContent(bodyPart);
            #endregion
            // Move to the text bookmark
            bk.MoveToBookmark("Text");
            //Deletes the bookmark content
            bk.DeleteBookmarkContent(true);
            // Inserting text inside the bookmark. This will preserve the source formatting
            bk.InsertText("Northwind Database contains the following table:");
            #region tableinsertion
            WTable tbl = new WTable(document);
            tbl.TableFormat.Borders.BorderType = BorderStyle.None;
            tbl.TableFormat.IsAutoResized      = true;
            tbl.ResetCells(8, 2);
            IWParagraph paragraph;
            tbl.Rows[0].IsHeader = true;
            paragraph            = tbl[0, 0].AddParagraph();
            paragraph.AppendText("Suppliers");
            paragraph.BreakCharacterFormat.FontName = "Calibri";
            paragraph.BreakCharacterFormat.FontSize = 10;

            paragraph = tbl[0, 1].AddParagraph();
            paragraph.AppendText("1");
            paragraph.BreakCharacterFormat.FontName = "Calibri";
            paragraph.BreakCharacterFormat.FontSize = 10;

            paragraph = tbl[1, 0].AddParagraph();
            paragraph.AppendText("Customers");
            paragraph.BreakCharacterFormat.FontName = "Calibri";
            paragraph.BreakCharacterFormat.FontSize = 10;

            paragraph = tbl[1, 1].AddParagraph();
            paragraph.AppendText("1");
            paragraph.BreakCharacterFormat.FontName = "Calibri";
            paragraph.BreakCharacterFormat.FontSize = 10;

            paragraph = tbl[2, 0].AddParagraph();
            paragraph.AppendText("Employees");
            paragraph.BreakCharacterFormat.FontName = "Calibri";
            paragraph.BreakCharacterFormat.FontSize = 10;

            paragraph = tbl[2, 1].AddParagraph();
            paragraph.AppendText("3");
            paragraph.BreakCharacterFormat.FontName = "Calibri";
            paragraph.BreakCharacterFormat.FontSize = 10;

            paragraph = tbl[3, 0].AddParagraph();
            paragraph.AppendText("Products");
            paragraph.BreakCharacterFormat.FontName = "Calibri";
            paragraph.BreakCharacterFormat.FontSize = 10;

            paragraph = tbl[3, 1].AddParagraph();
            paragraph.AppendText("1");
            paragraph.BreakCharacterFormat.FontName = "Calibri";
            paragraph.BreakCharacterFormat.FontSize = 10;

            paragraph = tbl[4, 0].AddParagraph();
            paragraph.AppendText("Inventory");
            paragraph.BreakCharacterFormat.FontName = "Calibri";
            paragraph.BreakCharacterFormat.FontSize = 10;

            paragraph = tbl[4, 1].AddParagraph();
            paragraph.AppendText("2");
            paragraph.BreakCharacterFormat.FontName = "Calibri";
            paragraph.BreakCharacterFormat.FontSize = 10;

            paragraph = tbl[5, 0].AddParagraph();
            paragraph.AppendText("Shippers");
            paragraph.BreakCharacterFormat.FontName = "Calibri";
            paragraph.BreakCharacterFormat.FontSize = 10;

            paragraph = tbl[5, 1].AddParagraph();
            paragraph.AppendText("1");
            paragraph.BreakCharacterFormat.FontName = "Calibri";
            paragraph.BreakCharacterFormat.FontSize = 10;

            paragraph = tbl[6, 0].AddParagraph();
            paragraph.AppendText("PO Transactions");
            paragraph.BreakCharacterFormat.FontName = "Calibri";
            paragraph.BreakCharacterFormat.FontSize = 10;

            paragraph = tbl[6, 1].AddParagraph();
            paragraph.AppendText("3");
            paragraph.BreakCharacterFormat.FontName = "Calibri";
            paragraph.BreakCharacterFormat.FontSize = 10;

            paragraph = tbl[7, 0].AddParagraph();
            paragraph.AppendText("Sales Transactions");
            paragraph.BreakCharacterFormat.FontName = "Calibri";
            paragraph.BreakCharacterFormat.FontSize = 10;

            paragraph = tbl[7, 1].AddParagraph();
            paragraph.AppendText("7");
            paragraph.BreakCharacterFormat.FontName = "Calibri";
            paragraph.BreakCharacterFormat.FontSize = 10;


            bk.InsertTable(tbl);
            #endregion
            bk.MoveToBookmark("Image");
            bk.DeleteBookmarkContent(true);
            // Inserting image to the bookmark.
            IWPicture pic = bk.InsertParagraphItem(ParagraphItemType.Picture) as WPicture;
            inputStream = assembly.GetManifestResourceStream("SampleBrowser.Samples.DocIO.Templates.Northwind.png");
            pic.LoadImage(inputStream);
            inputStream.Dispose();
            pic.WidthScale  = 50f; // It reduce the image size because it don't fit
            pic.HeightScale = 75f; // in document page.


            #region Saving Document
            MemoryStream stream = new MemoryStream();
            document.Save(stream, FormatType.Word2013);
            document.Close();
            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("BookmarkNavigation.docx", "application/msword", stream, m_context);
            }

            #endregion
        }