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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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 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 fontStream = typeof(OpenTypeFont).GetTypeInfo().Assembly.GetManifestResourceStream("SampleBrowser.Samples.PDF.Assets.NotoSerif-Black.otf"); PdfFont font = new PdfTrueTypeFont(fontStream, 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); //Draw text. page.Graphics.DrawString(text, font, brush, rect); 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("OpenTypeFont.pdf", "application/pdf", stream, m_context); } }
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); } }
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); } }
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); } }
void OnButtonClicked(object sender, EventArgs e) { string resourcePath = "SampleBrowser.Samples.Presentation.Templates.HelloWorld.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 titleShape = slide1.Shapes[0] as IShape; titleShape.Left = 0.33 * 72; titleShape.Top = 0.58 * 72; titleShape.Width = 12.5 * 72; titleShape.Height = 1.75 * 72; ITextBody textFrame1 = (slide1.Shapes[0] as IShape).TextBody; IParagraphs paragraphs1 = textFrame1.Paragraphs; IParagraph paragraph = paragraphs1.Add(); paragraph.HorizontalAlignment = HorizontalAlignmentType.Center; ITextPart textPart1 = paragraph.AddTextPart(); textPart1.Text = "Essential Presentation"; textPart1.Font.CapsType = TextCapsType.All; textPart1.Font.FontName = "Arial"; textPart1.Font.Bold = true; textPart1.Font.FontSize = 40; IShape subtitle = slide1.Shapes[1] as IShape; subtitle.Left = 0.5 * 72; subtitle.Top = 3 * 72; subtitle.Width = 11.8 * 72; subtitle.Height = 1.7 * 72; ITextBody textFrame2 = (slide1.Shapes[1] as IShape).TextBody; textFrame2.VerticalAlignment = VerticalAlignmentType.Top; IParagraphs paragraphs2 = textFrame2.Paragraphs; IParagraph para = paragraphs2.Add(); para.HorizontalAlignment = HorizontalAlignmentType.Left; ITextPart textPart2 = para.AddTextPart(); textPart2.Text = "Lorem ipsum dolor sit amet, lacus amet amet ultricies. Quisque mi venenatis morbi libero, orci dis, mi ut et class porta, massa ligula magna enim, aliquam orci vestibulum tempus.Turpis facilisis vitae consequat, cum a a, turpis dui consequat massa in dolor per, felis non amet."; textPart2.Font.FontName = "Arial"; textPart2.Font.FontSize = 21; para = paragraphs2.Add(); para.HorizontalAlignment = HorizontalAlignmentType.Left; textPart2 = para.AddTextPart(); textPart2.Text = "Turpis facilisis vitae consequat, cum a a, turpis dui consequat massa in dolor per, felis non amet. Auctor eleifend in omnis elit vestibulum, donec non elementum tellus est mauris, id aliquam, at lacus, arcu pretium proin lacus dolor et. Eu tortor, vel ultrices amet dignissim mauris vehicula."; textPart2.Font.FontName = "Arial"; textPart2.Font.FontSize = 21; //Add hyperlink to the paragraph ITextPart textPart3 = para.AddTextPart(); textPart3.Text = "click here"; textPart3.Font.FontName = "Arial"; textPart3.SetHyperlink("https://msdn.microsoft.com/en-in/library/mt299001.aspx"); #endregion MemoryStream stream = new MemoryStream(); presentation.Save(stream); presentation.Close(); stream.Position = 0; if (stream != null) { SaveAndroid androidSave = new SaveAndroid(); androidSave.Save("GettingStarted.pptx", "application/powerpoint", stream, m_context); } }
void OnButtonClicked(object sender, EventArgs e) { string resourcePath = "SampleBrowser.Samples.Presentation.Templates.Images.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 = (IShape)slide1.Shapes[0]; shape1.Left = 1.27 * 72; shape1.Top = 0.56 * 72; shape1.Width = 9.55 * 72; shape1.Height = 5.4 * 72; ITextBody textFrame = shape1.TextBody; IParagraphs paragraphs = textFrame.Paragraphs; paragraphs.Add(); IParagraph paragraph = paragraphs[0]; paragraph.HorizontalAlignment = HorizontalAlignmentType.Left; ITextParts textParts = paragraph.TextParts; textParts.Add(); ITextPart textPart = textParts[0]; textPart.Text = "Essential Presentation "; textPart.Font.CapsType = TextCapsType.All; textPart.Font.FontName = "Calibri Light (Headings)"; textPart.Font.FontSize = 80; textPart.Font.Color = ColorObject.Black; #endregion #region Slide2 ISlide slide2 = presentation.Slides.Add(SlideLayoutType.ContentWithCaption); slide2.Background.Fill.FillType = FillType.Solid; slide2.Background.Fill.SolidFill.Color = ColorObject.White; //Adds shape in slide shape1 = (IShape)slide2.Shapes[0]; shape1.Left = 0.47 * 72; shape1.Top = 1.15 * 72; shape1.Width = 3.5 * 72; shape1.Height = 4.91 * 72; ITextBody textFrame1 = shape1.TextBody; //Instance to hold paragraphs in textframe IParagraphs paragraphs1 = textFrame1.Paragraphs; IParagraph paragraph1 = paragraphs1.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Left; ITextPart textpart1 = paragraph1.AddTextPart(); textpart1.Text = "Lorem ipsum dolor sit amet, lacus amet amet ultricies. Quisque mi venenatis morbi libero, orci dis, mi ut et class porta, massa ligula magna enim, aliquam orci vestibulum tempus."; textpart1.Font.Color = ColorObject.White; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; paragraphs1.Add(); IParagraph paragraph2 = paragraphs1.Add(); paragraph2.HorizontalAlignment = HorizontalAlignmentType.Left; textpart1 = paragraph2.AddTextPart(); textpart1.Text = "Turpis facilisis vitae consequat, cum a a, turpis dui consequat massa in dolor per, felis non amet."; textpart1.Font.Color = ColorObject.White; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; paragraphs1.Add(); IParagraph paragraph3 = paragraphs1.Add(); paragraph3.HorizontalAlignment = HorizontalAlignmentType.Left; textpart1 = paragraph3.AddTextPart(); textpart1.Text = "Auctor eleifend in omnis elit vestibulum, donec non elementum tellus est mauris, id aliquam, at lacus, arcu pretium proin lacus dolor et. Eu tortor, vel ultrices amet dignissim mauris vehicula."; textpart1.Font.Color = ColorObject.White; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; paragraphs1.Add(); IParagraph paragraph4 = paragraphs1.Add(); paragraph4.HorizontalAlignment = HorizontalAlignmentType.Left; textpart1 = paragraph4.AddTextPart(); textpart1.Text = "Lorem tortor neque, purus taciti quis id. Elementum integer orci accumsan minim phasellus vel."; textpart1.Font.Color = ColorObject.White; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; paragraphs1.Add(); slide2.Shapes.RemoveAt(1); slide2.Shapes.RemoveAt(1); //Adds picture in the shape resourcePath = "SampleBrowser.Samples.Presentation.Templates.tablet.jpg"; assembly = Assembly.GetExecutingAssembly(); fileStream = assembly.GetManifestResourceStream(resourcePath); slide2.Shapes.AddPicture(fileStream, 5.18 * 72, 1.15 * 72, 7.3 * 72, 5.31 * 72); fileStream.Close(); #endregion MemoryStream stream = new MemoryStream(); presentation.Save(stream); presentation.Close(); stream.Position = 0; if (stream != null) { SaveAndroid androidSave = new SaveAndroid(); androidSave.Save("Images.pptx", "application/powerpoint", stream, m_context); } }
private void Button1_Click(object sender, EventArgs e) { int rowCount = Convert.ToInt32(textBox1.Value); int colCount = Convert.ToInt32(textBox2.Value); //Step 1 : Instantiate the spreadsheet creation engine. ExcelEngine excelEngine = new ExcelEngine(); //Step 2 : Instantiate the excel application object. IApplication application = excelEngine.Excel; IWorkbook workbook; workbook = application.Workbooks.Create(1); IWorksheet sheet = workbook.Worksheets[0]; if (chkImport.Checked) { workbook.Version = ExcelVersion.Excel2013; DataTable dataTable = new DataTable(); for (int column = 1; column <= colCount; column++) { dataTable.Columns.Add("Column: " + column.ToString(), typeof(int)); } //Adding data into data table for (int row = 1; row < rowCount; row++) { dataTable.Rows.Add(); for (int column = 1; column <= colCount; column++) { dataTable.Rows[row - 1][column - 1] = row * column; } } sheet.ImportDataTable(dataTable, 1, 1, true, true); } else { IMigrantRange migrantRange = sheet.MigrantRange; for (int column = 1; column <= colCount; column++) { migrantRange.ResetRowColumn(1, column); migrantRange.SetValue("Column: " + column.ToString()); } //Writing Data using normal interface for (int row = 2; row <= rowCount; row++) { //double columnSum = 0.0; for (int column = 1; column <= colCount; column++) { //Writing number migrantRange.ResetRowColumn(row, column); migrantRange.SetValue(row * column); } } } 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) { doc = new PdfDocument(); doc.PageSettings.Margins.All = 0; page = doc.Pages.Add(); PdfGraphics g = page.Graphics; PdfFont headerFont = new PdfStandardFont(PdfFontFamily.TimesRoman, 35); PdfFont subHeadingFont = new PdfStandardFont(PdfFontFamily.TimesRoman, 16); g.DrawRectangle(new PdfSolidBrush(gray), new RectangleF(0, 0, page.Graphics.ClientSize.Width, page.Graphics.ClientSize.Height)); g.DrawRectangle(new PdfSolidBrush(black), new RectangleF(0, 0, page.Graphics.ClientSize.Width, 130)); g.DrawRectangle(new PdfSolidBrush(white), new RectangleF(0, 400, page.Graphics.ClientSize.Width, page.Graphics.ClientSize.Height - 450)); g.DrawString("Syncfusion", headerFont, new PdfSolidBrush(violet), new PointF(10, 20)); g.DrawRectangle(new PdfSolidBrush(violet), new RectangleF(10, 63, 155, 35)); g.DrawString("File Formats", subHeadingFont, new PdfSolidBrush(black), new PointF(45, 70)); PdfLayoutResult result = HeaderPoints("Optimized for usage in a server environment where spread and low memory usage in critical.", 15); result = HeaderPoints("Proven, reliable platform thousands of users over the past 10 years.", result.Bounds.Bottom + 15); result = HeaderPoints("Microsoft Excel, Word, Presentation, PDF and PDF Viewer.", result.Bounds.Bottom + 15); result = HeaderPoints("Why start from scratch? Rely on our dependable solution frameworks.", result.Bounds.Bottom + 15); result = BodyContent("Deployment-ready framework tailored to your needs.", result.Bounds.Bottom + 45); result = BodyContent("Enable your applications to read and write file formats documents easily.", result.Bounds.Bottom + 25); result = BodyContent("Solutions available for web, desktop, and mobile applications.", result.Bounds.Bottom + 25); result = BodyContent("Backed by our end-to-end product maintenance infrastructure.", result.Bounds.Bottom + 25); result = BodyContent("The quickest path from concept to delivery.", result.Bounds.Bottom + 25); PdfPen redPen = new PdfPen(PdfBrushes.Red, 2); g.DrawLine(redPen, new PointF(40, result.Bounds.Bottom + 92), new PointF(40, result.Bounds.Bottom + 145)); float headerBulletsXposition = 40; PdfTextElement txtElement = new PdfTextElement("The Experts"); txtElement.Font = new PdfStandardFont(PdfFontFamily.TimesRoman, 20); txtElement.Draw(page, new RectangleF(headerBulletsXposition + 5, result.Bounds.Bottom + 90, 450, 200)); PdfPen violetPen = new PdfPen(PdfBrushes.Violet, 2); g.DrawLine(violetPen, new PointF(headerBulletsXposition + 280, result.Bounds.Bottom + 92), new PointF(headerBulletsXposition + 280, result.Bounds.Bottom + 145)); txtElement = new PdfTextElement("Accurate Estimates"); txtElement.Font = new PdfStandardFont(PdfFontFamily.TimesRoman, 20); result = txtElement.Draw(page, new RectangleF(headerBulletsXposition + 290, result.Bounds.Bottom + 90, 450, 200)); txtElement = new PdfTextElement("A substantial number of .NET reporting applications use our frameworks."); txtElement.Font = new PdfStandardFont(PdfFontFamily.TimesRoman, 11, PdfFontStyle.Regular); result = txtElement.Draw(page, new RectangleF(headerBulletsXposition + 5, result.Bounds.Bottom + 5, 250, 200)); txtElement = new PdfTextElement("Given our expertise, you can expect estimates to be accurate."); txtElement.Font = new PdfStandardFont(PdfFontFamily.TimesRoman, 11, PdfFontStyle.Regular); result = txtElement.Draw(page, new RectangleF(headerBulletsXposition + 290, result.Bounds.Y, 250, 200)); PdfPen greenPen = new PdfPen(PdfBrushes.Green, 2); g.DrawLine(greenPen, new PointF(40, result.Bounds.Bottom + 32), new PointF(40, result.Bounds.Bottom + 85)); txtElement = new PdfTextElement("No-Hassle Licensing"); txtElement.Font = new PdfStandardFont(PdfFontFamily.TimesRoman, 20); txtElement.Draw(page, new RectangleF(headerBulletsXposition + 5, result.Bounds.Bottom + 30, 450, 200)); PdfPen bluePen = new PdfPen(PdfBrushes.Blue, 2); g.DrawLine(bluePen, new PointF(headerBulletsXposition + 280, result.Bounds.Bottom + 32), new PointF(headerBulletsXposition + 280, result.Bounds.Bottom + 85)); txtElement = new PdfTextElement("About Syncfusion"); txtElement.Font = new PdfStandardFont(PdfFontFamily.TimesRoman, 20); result = txtElement.Draw(page, new RectangleF(headerBulletsXposition + 290, result.Bounds.Bottom + 30, 450, 200)); txtElement = new PdfTextElement("No royalties, run time, or server deployment fees means no surprises."); txtElement.Font = new PdfStandardFont(PdfFontFamily.TimesRoman, 11, PdfFontStyle.Regular); result = txtElement.Draw(page, new RectangleF(headerBulletsXposition + 5, result.Bounds.Bottom + 5, 250, 200)); txtElement = new PdfTextElement("Syncfusion is the enterprise technology partner of choice for software development, delivering a board range of web, mobile, and desktop controls."); txtElement.Font = new PdfStandardFont(PdfFontFamily.TimesRoman, 11, PdfFontStyle.Regular); result = txtElement.Draw(page, new RectangleF(headerBulletsXposition + 290, result.Bounds.Y, 250, 200)); Stream imgStream = typeof(GettingStartedPDF).GetTypeInfo().Assembly.GetManifestResourceStream("SampleBrowser.Samples.PDF.Assets.Xamarin_bannerEdit.jpg"); g.DrawImage(PdfImage.FromStream(imgStream), 180, 630, 280, 150); g.DrawString("All trademarks mentioned belong to their owners.", new PdfStandardFont(PdfFontFamily.TimesRoman, 8, PdfFontStyle.Italic), PdfBrushes.White, new PointF(10, g.ClientSize.Height - 30)); PdfTextWebLink linkAnnot = new PdfTextWebLink(); linkAnnot.Url = "http://www.syncfusion.com"; linkAnnot.Text = "www.syncfusion.com"; linkAnnot.Font = new PdfStandardFont(PdfFontFamily.TimesRoman, 8, PdfFontStyle.Italic); linkAnnot.Brush = PdfBrushes.White; linkAnnot.DrawTextWebLink(page, new PointF(g.ClientSize.Width - 100, g.ClientSize.Height - 30)); MemoryStream stream = new MemoryStream(); doc.Save(stream); doc.Close(true); if (stream != null) { SaveAndroid androidSave = new SaveAndroid(); androidSave.Save("GettingStarted.pdf", "application/pdf", stream, m_context); } }
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); } }
void OnButtonClicked(object sender, EventArgs e) { string resourcePath = "SampleBrowser.Samples.Presentation.Templates.Images.pptx"; Assembly assembly = Assembly.GetExecutingAssembly(); Stream fileStream = assembly.GetManifestResourceStream(resourcePath); IPresentation presentation = Syncfusion.Presentation.Presentation.Open(fileStream); #region Slide 1 ISlide slide1 = presentation.Slides[0]; IShape shape1 = (IShape)slide1.Shapes[0]; shape1.Left = 1.27 * 72; shape1.Top = 0.85 * 72; shape1.Width = 10.86 * 72; shape1.Height = 3.74 * 72; ITextBody textFrame = shape1.TextBody; IParagraphs paragraphs = textFrame.Paragraphs; paragraphs.Add(); IParagraph paragraph = paragraphs[0]; paragraph.HorizontalAlignment = HorizontalAlignmentType.Left; ITextParts textParts = paragraph.TextParts; textParts.Add(); ITextPart textPart = textParts[0]; textPart.Text = "Essential Presentation "; textPart.Font.CapsType = TextCapsType.All; textPart.Font.FontName = "Calibri Light (Headings)"; textPart.Font.FontSize = 80; textPart.Font.Color = ColorObject.Black; IComment comment = slide1.Comments.Add(0.35, 0.04, "Author1", "A1", "Essential Presentation is available from 13.1 versions of Essential Studio", DateTime.Now); #endregion #region Slide2 ISlide slide2 = presentation.Slides.Add(SlideLayoutType.Blank); IPresentationChart chart = slide2.Shapes.AddChart(230, 80, 500, 400); //Specifies the chart title chart.ChartTitle = "Sales Analysis"; //Sets chart data - Row1 chart.ChartData.SetValue(1, 2, "Jan"); chart.ChartData.SetValue(1, 3, "Feb"); chart.ChartData.SetValue(1, 4, "March"); //Sets chart data - Row2 chart.ChartData.SetValue(2, 1, 2010); chart.ChartData.SetValue(2, 2, 60); chart.ChartData.SetValue(2, 3, 70); chart.ChartData.SetValue(2, 4, 80); //Sets chart data - Row3 chart.ChartData.SetValue(3, 1, 2011); chart.ChartData.SetValue(3, 2, 80); chart.ChartData.SetValue(3, 3, 70); chart.ChartData.SetValue(3, 4, 60); //Sets chart data - Row4 chart.ChartData.SetValue(4, 1, 2012); chart.ChartData.SetValue(4, 2, 60); chart.ChartData.SetValue(4, 3, 70); chart.ChartData.SetValue(4, 4, 80); //Creates a new chart series with the name IOfficeChartSerie serieJan = chart.Series.Add("Jan"); //Sets the data range of chart serie � start row, start column, end row, end column serieJan.Values = chart.ChartData[2, 2, 4, 2]; //Creates a new chart series with the name IOfficeChartSerie serieFeb = chart.Series.Add("Feb"); //Sets the data range of chart serie � start row, start column, end row, end column serieFeb.Values = chart.ChartData[2, 3, 4, 3]; //Creates a new chart series with the name IOfficeChartSerie serieMarch = chart.Series.Add("March"); //Sets the data range of chart series � start row, start column, end row, end column serieMarch.Values = chart.ChartData[2, 4, 4, 4]; //Sets the data range of the category axis chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 4, 1]; //Specifies the chart type chart.ChartType = OfficeChartType.Column_Clustered_3D; slide2.Comments.Add(0.35, 0.04, "Author2", "A2", "All 3D-chart types are supported in Presentation library.", DateTime.Now); #endregion #region Slide3 ISlide slide3 = presentation.Slides.Add(SlideLayoutType.ContentWithCaption); slide3.Background.Fill.FillType = FillType.Solid; slide3.Background.Fill.SolidFill.Color = ColorObject.White; //Adds shape in slide IShape shape2 = (IShape)slide3.Shapes[0]; shape2.Left = 0.47 * 72; shape2.Top = 1.15 * 72; shape2.Width = 3.5 * 72; shape2.Height = 4.91 * 72; ITextBody textFrame1 = shape2.TextBody; //Instance to hold paragraphs in textframe IParagraphs paragraphs1 = textFrame1.Paragraphs; IParagraph paragraph1 = paragraphs1.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Left; ITextPart textpart1 = paragraph1.AddTextPart(); textpart1.Text = "Lorem ipsum dolor sit amet, lacus amet amet ultricies. Quisque mi venenatis morbi libero, orci dis, mi ut et class porta, massa ligula magna enim, aliquam orci vestibulum tempus."; textpart1.Font.Color = ColorObject.White; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; paragraphs1.Add(); IParagraph paragraph2 = paragraphs1.Add(); paragraph2.HorizontalAlignment = HorizontalAlignmentType.Left; textpart1 = paragraph2.AddTextPart(); textpart1.Text = "Turpis facilisis vitae consequat, cum a a, turpis dui consequat massa in dolor per, felis non amet."; textpart1.Font.Color = ColorObject.White; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; paragraphs1.Add(); IParagraph paragraph3 = paragraphs1.Add(); paragraph3.HorizontalAlignment = HorizontalAlignmentType.Left; textpart1 = paragraph3.AddTextPart(); textpart1.Text = "Auctor eleifend in omnis elit vestibulum, donec non elementum tellus est mauris, id aliquam, at lacus, arcu pretium proin lacus dolor et. Eu tortor, vel ultrices amet dignissim mauris vehicula."; textpart1.Font.Color = ColorObject.White; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; paragraphs1.Add(); IParagraph paragraph4 = paragraphs1.Add(); paragraph4.HorizontalAlignment = HorizontalAlignmentType.Left; textpart1 = paragraph4.AddTextPart(); textpart1.Text = "Lorem tortor neque, purus taciti quis id. Elementum integer orci accumsan minim phasellus vel."; textpart1.Font.Color = ColorObject.White; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; paragraphs1.Add(); slide3.Shapes.RemoveAt(1); slide3.Shapes.RemoveAt(1); //Adds picture in the shape resourcePath = "SampleBrowser.Samples.Presentation.Templates.tablet.jpg"; fileStream = assembly.GetManifestResourceStream(resourcePath); IPicture picture1 = slide3.Shapes.AddPicture(fileStream, 5.18 * 72, 1.15 * 72, 7.3 * 72, 5.31 * 72); fileStream.Dispose(); slide3.Comments.Add(0.14, 0.04, "Author3", "A3", "Can we use a different font family for this text?", DateTime.Now); #endregion MemoryStream stream = new MemoryStream(); presentation.Save(stream); presentation.Close(); stream.Position = 0; if (stream != null) { SaveAndroid androidSave = new SaveAndroid(); androidSave.Save("Comments.pptx", "application/powerpoint", stream, m_context); } }
void OnButtonClicked(object sender, EventArgs e) { //Create an instance for PowerPoint IPresentation presentation = Syncfusion.Presentation.Presentation.Create(); //Add a blank slide to Presentation ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank); //Add header shape IShape headerTextBox = slide.Shapes.AddTextBox(58.44, 53.85, 221.93, 81.20); //Add a paragraph into the text box IParagraph paragraph = headerTextBox.TextBody.AddParagraph("Flow chart with "); //Add a textPart ITextPart textPart = paragraph.AddTextPart("Connector"); //Change the color of the font textPart.Font.Color = ColorObject.FromArgb(44, 115, 230); //Make the textpart bold textPart.Font.Bold = true; //Set the font size of the paragraph paragraph.Font.FontSize = 28; //Add start shape to slide IShape startShape = slide.Shapes.AddShape(AutoShapeType.FlowChartTerminator, 420.45, 36.35, 133.93, 50.39); //Add a paragraph into the start shape text body AddParagraph(startShape, "Start", ColorObject.FromArgb(255, 149, 34)); //Add alarm shape to slide IShape alarmShape = slide.Shapes.AddShape(AutoShapeType.FlowChartProcess, 420.45, 126.72, 133.93, 50.39); //Add a paragraph into the alarm shape text body AddParagraph(alarmShape, "Alarm Rings", ColorObject.FromArgb(255, 149, 34)); //Add condition shape to slide IShape conditionShape = slide.Shapes.AddShape(AutoShapeType.FlowChartDecision, 420.45, 222.42, 133.93, 97.77); //Add a paragraph into the condition shape text body AddParagraph(conditionShape, "Ready to Get Up ?", ColorObject.FromArgb(44, 115, 213)); //Add wake up shape to slide IShape wakeUpShape = slide.Shapes.AddShape(AutoShapeType.FlowChartProcess, 420.45, 361.52, 133.93, 50.39); //Add a paragraph into the wake up shape text body AddParagraph(wakeUpShape, "Wake Up", ColorObject.FromArgb(44, 115, 213)); //Add end shape to slide IShape endShape = slide.Shapes.AddShape(AutoShapeType.FlowChartTerminator, 420.45, 453.27, 133.93, 50.39); //Add a paragraph into the end shape text body AddParagraph(endShape, "End", ColorObject.FromArgb(44, 115, 213)); //Add snooze shape to slide IShape snoozeShape = slide.Shapes.AddShape(AutoShapeType.FlowChartProcess, 624.85, 245.79, 159.76, 50.02); //Add a paragraph into the snooze shape text body AddParagraph(snoozeShape, "Hit Snooze button", ColorObject.FromArgb(255, 149, 34)); //Add relay shape to slide IShape relayShape = slide.Shapes.AddShape(AutoShapeType.FlowChartDelay, 624.85, 127.12, 159.76, 49.59); //Add a paragraph into the relay shape text body AddParagraph(relayShape, "Relay", ColorObject.FromArgb(255, 149, 34)); //Connect the start shape with alarm shape using connector IConnector connector1 = slide.Shapes.AddConnector(ConnectorType.Straight, startShape, 2, alarmShape, 0); //Set the arrow style for the connector connector1.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow; //Connect the alarm shape with condition shape using connector IConnector connector2 = slide.Shapes.AddConnector(ConnectorType.Straight, alarmShape, 2, conditionShape, 0); //Set the arrow style for the connector connector2.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow; //Connect the condition shape with snooze shape using connector IConnector connector3 = slide.Shapes.AddConnector(ConnectorType.Straight, conditionShape, 3, snoozeShape, 1); //Set the arrow style for the connector connector3.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow; //Connect the snooze shape with relay shape using connector IConnector connector4 = slide.Shapes.AddConnector(ConnectorType.Straight, snoozeShape, 0, relayShape, 2); //Set the arrow style for the connector connector4.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow; //Connect the relay shape with alarm shape using connector IConnector connector5 = slide.Shapes.AddConnector(ConnectorType.Straight, relayShape, 1, alarmShape, 3); //Set the arrow style for the connector connector5.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow; //Connect the condition shape with wake up shape using connector IConnector connector6 = slide.Shapes.AddConnector(ConnectorType.Straight, conditionShape, 2, wakeUpShape, 0); //Set the arrow style for the connector connector6.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow; //Connect the wake up shape with end shape using connector IConnector connector7 = slide.Shapes.AddConnector(ConnectorType.Straight, wakeUpShape, 2, endShape, 0); //Set the arrow style for the connector connector7.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow; //Add No textbox to slide IShape noTextBox = slide.Shapes.AddTextBox(564.02, 245.43, 51.32, 26.22); //Add a paragraph into the text box noTextBox.TextBody.AddParagraph("No"); //Add Yes textbox to slide IShape yesTextBox = slide.Shapes.AddTextBox(487.21, 327.99, 50.09, 26.23); //Add a paragraph into the text box yesTextBox.TextBody.AddParagraph("Yes"); MemoryStream stream = new MemoryStream(); presentation.Save(stream); presentation.Close(); stream.Position = 0; if (stream != null) { SaveAndroid androidSave = new SaveAndroid(); androidSave.Save("Connectors.pptx", "application/powerpoint", stream, m_context); } }
void OnButtonClicked(object sender, EventArgs e) { ExcelEngine excelEngine = new ExcelEngine(); IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Excel2013; int index = spinner.SelectedItemPosition; #region Initializing Workbook 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); //The first worksheet object in the worksheets collection is accessed. IWorksheet sheet = workbook.Worksheets[0]; sheet["A60"].Activate(); #endregion if (index != 6) { sheet.AutoFilters.FilterRange = sheet.Range[1, 1, 49, 3]; } string fileName = ""; switch (index) { case 0: fileName = "CustomFilter.xlsx"; IAutoFilter filter1 = sheet.AutoFilters[0]; filter1.IsAnd = false; filter1.FirstCondition.ConditionOperator = ExcelFilterCondition.Equal; filter1.FirstCondition.DataType = ExcelFilterDataType.String; filter1.FirstCondition.String = "Owner"; filter1.SecondCondition.ConditionOperator = ExcelFilterCondition.Equal; filter1.SecondCondition.DataType = ExcelFilterDataType.String; filter1.SecondCondition.String = "Sales Representative"; break; case 1: fileName = "TextFilter.xlsx"; IAutoFilter filter2 = sheet.AutoFilters[0]; filter2.AddTextFilter(new string[] { "Owner", "Sales Representative", "Sales Associate" }); break; case 2: fileName = "DateTimeFilter.xlsx"; IAutoFilter filter3 = sheet.AutoFilters[1]; filter3.AddDateFilter(new DateTime(2004, 9, 1, 1, 0, 0, 0), DateTimeGroupingType.month); filter3.AddDateFilter(new DateTime(2011, 1, 1, 1, 0, 0, 0), DateTimeGroupingType.year); break; case 3: fileName = "DynamicFilter.xlsx"; IAutoFilter filter4 = sheet.AutoFilters[1]; filter4.AddDynamicFilter(DynamicFilterType.Quarter1); break; case 4: fileName = "Color Filter.xlsx"; #region ColorFilter sheet.AutoFilters.FilterRange = sheet["A1:C49"]; Syncfusion.Drawing.Color color = Syncfusion.Drawing.Color.Empty; switch (spinner3.SelectedItemPosition) { case 0: color = Syncfusion.Drawing.Color.Red; break; case 1: color = Syncfusion.Drawing.Color.Blue; break; case 2: color = Syncfusion.Drawing.Color.Green; break; case 3: color = Syncfusion.Drawing.Color.Yellow; break; case 4: color = Syncfusion.Drawing.Color.Empty; break; } if (spinner2.SelectedItemPosition == 0) { IAutoFilter filter = sheet.AutoFilters[2]; filter.AddColorFilter(color, ExcelColorFilterType.FontColor); } else { IAutoFilter filter = sheet.AutoFilters[0]; filter.AddColorFilter(color, ExcelColorFilterType.CellColor); } #endregion break; case 5: fileName = "IconFilter.xlsx"; #region IconFilter sheet.AutoFilters.FilterRange = sheet["A4:D44"]; ExcelIconSetType iconSet = ExcelIconSetType.FiveArrows; int filterIndex = 0; int iconId = 0; switch (spinner4.SelectedItemPosition) { case 0: filterIndex = 3; iconSet = ExcelIconSetType.ThreeSymbols; break; case 1: filterIndex = 1; iconSet = ExcelIconSetType.FourRating; break; case 2: filterIndex = 2; iconSet = ExcelIconSetType.FiveArrows; break; } switch (spinner5.SelectedItemPosition) { case 0: iconId = 0; break; case 1: iconId = 1; break; case 2: iconId = 2; break; case 3: if (spinner4.SelectedItemPosition == 0) { iconSet = (ExcelIconSetType)(-1); } else { iconId = 3; } break; case 4: if (spinner4.SelectedItemPosition == 1) { iconSet = (ExcelIconSetType)(-1); } else { iconId = 4; } break; case 5: iconSet = (ExcelIconSetType)(-1); break; } IAutoFilter filter5 = sheet.AutoFilters[filterIndex]; filter5.AddIconFilter(iconSet, iconId); #endregion break; case 6: #region AdvancedFilter fileName = "AdvancedFilter.xlsx"; IRange filterRange = sheet.Range["A8:G51"]; IRange criteriaRange = sheet.Range["A2:B5"]; if (spinner1.SelectedItemPosition == 0) { sheet.AdvancedFilter(ExcelFilterAction.FilterInPlace, filterRange, criteriaRange, null, switch1.Checked); } else { IRange range = sheet.Range["I7:O7"]; range.Merge(); range.Text = "FilterCopy"; range.CellStyle.Font.RGBColor = Syncfusion.Drawing.Color.FromArgb(0, 112, 192); range.HorizontalAlignment = ExcelHAlign.HAlignCenter; range.CellStyle.Font.Bold = true; IRange copyRange = sheet.Range["I8"]; sheet.AdvancedFilter(ExcelFilterAction.FilterCopy, filterRange, criteriaRange, copyRange, switch1.Checked); } #endregion break; } workbook.Version = ExcelVersion.Excel2013; MemoryStream stream = new MemoryStream(); workbook.SaveAs(stream); workbook.Close(); excelEngine.Dispose(); if (stream != null) { SaveAndroid androidSave = new SaveAndroid(); androidSave.Save(fileName, "application/msexcel", stream, m_context); } }
void ButtonExportClicked(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.BusinessObjects.xml"); //IEnumerable<BusinessObject> customers = GetBusinessObjectsData(fileStream); sheet.ImportData((List <CustomerObject>)sfGrid.ItemsSource, 5, 1, false); #region Define Styles IStyle pageHeader = workbook.Styles.Add("PageHeaderStyle"); IStyle tableHeader = workbook.Styles.Add("TableHeaderStyle"); pageHeader.Font.RGBColor = COLOR.Color.FromArgb(255, 83, 141, 213); pageHeader.Font.FontName = "Calibri"; pageHeader.Font.Size = 18; pageHeader.Font.Bold = true; pageHeader.HorizontalAlignment = ExcelHAlign.HAlignCenter; pageHeader.VerticalAlignment = ExcelVAlign.VAlignCenter; tableHeader.Font.Color = ExcelKnownColors.Black; tableHeader.Font.Bold = true; tableHeader.Font.Size = 11; tableHeader.Font.FontName = "Calibri"; tableHeader.HorizontalAlignment = ExcelHAlign.HAlignCenter; tableHeader.VerticalAlignment = ExcelVAlign.VAlignCenter; tableHeader.Color = COLOR.Color.FromArgb(255, 118, 147, 60); tableHeader.Borders[ExcelBordersIndex.EdgeLeft].LineStyle = ExcelLineStyle.Thin; tableHeader.Borders[ExcelBordersIndex.EdgeRight].LineStyle = ExcelLineStyle.Thin; tableHeader.Borders[ExcelBordersIndex.EdgeTop].LineStyle = ExcelLineStyle.Thin; tableHeader.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin; #endregion #region Apply Styles // Apply style for header sheet["A1:D1"].Merge(); sheet["A1"].Text = "Yearly Sales Report"; sheet["A1"].CellStyle = pageHeader; sheet["A1"].RowHeight = 20; sheet["A2:D2"].Merge(); sheet["A2"].Text = "Namewise Sales Comparison Report"; sheet["A2"].CellStyle = pageHeader; sheet["A2"].CellStyle.Font.Bold = false; sheet["A2"].CellStyle.Font.Size = 16; sheet["A2"].RowHeight = 20; sheet["A3:A4"].Merge(); sheet["D3:D4"].Merge(); sheet["B3:C3"].Merge(); sheet["B3"].Text = "Sales"; sheet["A3:D4"].CellStyle = tableHeader; sheet["A3"].Text = "Sales Person"; sheet["B4"].Text = "Jan - Jun"; sheet["C4"].Text = "Jul - Dec"; sheet["D3"].Text = "Change (%)"; sheet.Columns[0].ColumnWidth = 19; sheet.Columns[1].ColumnWidth = 10; sheet.Columns[2].ColumnWidth = 10; sheet.Columns[3].ColumnWidth = 11; #endregion #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("BusinessObjects.xlsx", "application/msexcel", stream, m_context); } #endregion }
void OnButtonClicked(object sender, EventArgs e) { Assembly assembly = Assembly.GetExecutingAssembly(); //Creates an empty Word document instance. WordDocument document = new WordDocument(); Stream inputStream = assembly.GetManifestResourceStream("SampleBrowser.Samples.DocIO.Templates.ContentControlTemplate.docx"); //Opens template document. document.Open(inputStream, FormatType.Word2013); IWTextRange textRange; //Gets table from the template document. IWTable table = document.LastSection.Tables[0]; WTableRow row = table.Rows[1]; #region Inserting content controls #region Calendar content control IWParagraph cellPara = row.Cells[0].Paragraphs[0]; //Accesses the date picker content control. IInlineContentControl inlineControl = (cellPara.ChildEntities[2] as IInlineContentControl); textRange = inlineControl.ParagraphItems[0] as WTextRange; //Sets today's date to display. textRange.Text = DateTime.Now.ToShortDateString(); textRange.CharacterFormat.FontSize = 14; //Protects the content control. inlineControl.ContentControlProperties.LockContents = true; #endregion #region Plain text content controls table = document.LastSection.Tables[1]; row = table.Rows[0]; cellPara = row.Cells[0].LastParagraph; //Accesses the plain text content control. inlineControl = (cellPara.ChildEntities[1] as IInlineContentControl); //Protects the content control. inlineControl.ContentControlProperties.LockContents = true; textRange = inlineControl.ParagraphItems[0] as WTextRange; //Sets text in plain text content control. textRange.Text = "Northwind Analytics"; textRange.CharacterFormat.FontSize = 14; cellPara = row.Cells[1].LastParagraph; //Accesses the plain text content control. inlineControl = (cellPara.ChildEntities[1] as IInlineContentControl); //Protects the content control. inlineControl.ContentControlProperties.LockContents = true; textRange = inlineControl.ParagraphItems[0] as WTextRange; //Sets text in plain text content control. textRange.Text = "Northwind"; textRange.CharacterFormat.FontSize = 14; row = table.Rows[1]; cellPara = row.Cells[0].LastParagraph; //Accesses the plain text content control. inlineControl = (cellPara.ChildEntities[1] as IInlineContentControl); //Protects the content control. inlineControl.ContentControlProperties.LockContents = true; //Sets text in plain text content control. textRange = inlineControl.ParagraphItems[0] as WTextRange; textRange.Text = "10"; textRange.CharacterFormat.FontSize = 14; cellPara = row.Cells[1].LastParagraph; //Accesses the plain text content control. inlineControl = (cellPara.ChildEntities[1] as IInlineContentControl); //Protects the content control. inlineControl.ContentControlProperties.LockContents = true; //Sets text in plain text content control. textRange = inlineControl.ParagraphItems[0] as WTextRange; textRange.Text = "Nancy Davolio"; textRange.CharacterFormat.FontSize = 14; #endregion #region CheckBox Content control row = table.Rows[2]; cellPara = row.Cells[0].LastParagraph; //Inserts checkbox content control. inlineControl = cellPara.AppendInlineContentControl(ContentControlType.CheckBox); inlineControl.ContentControlProperties.LockContents = true; //Sets checkbox as checked state. inlineControl.ContentControlProperties.IsChecked = true; textRange = cellPara.AppendText("C#, "); textRange.CharacterFormat.FontSize = 14; //Inserts checkbox content control. inlineControl = cellPara.AppendInlineContentControl(ContentControlType.CheckBox); inlineControl.ContentControlProperties.LockContents = true; //Sets checkbox as checked state. inlineControl.ContentControlProperties.IsChecked = true; textRange = cellPara.AppendText("VB"); textRange.CharacterFormat.FontSize = 14; #endregion #region Drop down list content control cellPara = row.Cells[1].LastParagraph; //Accesses the dropdown list content control. inlineControl = (cellPara.ChildEntities[1] as IInlineContentControl); inlineControl.ContentControlProperties.LockContents = true; //Sets default option to display. textRange = inlineControl.ParagraphItems[0] as WTextRange; textRange.Text = "ASP.NET"; textRange.CharacterFormat.FontSize = 14; inlineControl.ParagraphItems.Add(textRange); //Adds items to the dropdown list. ContentControlListItem item; item = new ContentControlListItem(); item.DisplayText = "ASP.NET MVC"; item.Value = "2"; inlineControl.ContentControlProperties.ContentControlListItems.Add(item); item = new ContentControlListItem(); item.DisplayText = "Windows Forms"; item.Value = "3"; inlineControl.ContentControlProperties.ContentControlListItems.Add(item); item = new ContentControlListItem(); item.DisplayText = "WPF"; item.Value = "4"; inlineControl.ContentControlProperties.ContentControlListItems.Add(item); item = new ContentControlListItem(); item.DisplayText = "Xamarin"; item.Value = "5"; inlineControl.ContentControlProperties.ContentControlListItems.Add(item); #endregion #region Calendar content control row = table.Rows[3]; cellPara = row.Cells[0].LastParagraph; //Accesses the date picker content control. inlineControl = (cellPara.ChildEntities[1] as IInlineContentControl); inlineControl.ContentControlProperties.LockContents = true; //Sets default date to display. textRange = inlineControl.ParagraphItems[0] as WTextRange; textRange.Text = DateTime.Now.AddDays(-5).ToShortDateString(); textRange.CharacterFormat.FontSize = 14; cellPara = row.Cells[1].LastParagraph; //Inserts date picker content control. inlineControl = (cellPara.ChildEntities[1] as IInlineContentControl); inlineControl.ContentControlProperties.LockContents = true; //Sets default date to display. textRange = inlineControl.ParagraphItems[0] as WTextRange; textRange.Text = DateTime.Now.AddDays(10).ToShortDateString(); textRange.CharacterFormat.FontSize = 14; #endregion #endregion #region Block content control //Accesses the block content control. BlockContentControl blockContentControl = ((document.ChildEntities[0] as WSection).Body.ChildEntities[2] as BlockContentControl); //Protects the block content control blockContentControl.ContentControlProperties.LockContents = true; #endregion MemoryStream stream = new MemoryStream(); document.Save(stream, FormatType.Word2013); document.Close(); if (stream != null) { SaveAndroid androidSave = new SaveAndroid(); androidSave.Save("FormFillingAndProtection.docx", "application/msword", 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 }
void ButtonExportClicked(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]; sheet.ImportData((List <Brand>)sfGrid.ItemsSource, 4, 1, true); #region Define Styles IStyle pageHeader = workbook.Styles.Add("PageHeaderStyle"); IStyle tableHeader = workbook.Styles.Add("TableHeaderStyle"); pageHeader.Font.FontName = "Calibri"; pageHeader.Font.Size = 16; pageHeader.Font.Bold = true; pageHeader.Color = Syncfusion.Drawing.Color.FromArgb(0, 146, 208, 80); pageHeader.HorizontalAlignment = ExcelHAlign.HAlignCenter; pageHeader.VerticalAlignment = ExcelVAlign.VAlignCenter; tableHeader.Font.Bold = true; tableHeader.Font.FontName = "Calibri"; tableHeader.Color = Syncfusion.Drawing.Color.FromArgb(0, 146, 208, 80); #endregion #region Apply Styles // Apply style for header sheet["A1:C2"].Merge(); sheet["A1"].Text = "Automobile Brands in the US"; sheet["A1"].CellStyle = pageHeader; sheet["A4:C4"].CellStyle = tableHeader; sheet["A1:C1"].CellStyle.Font.Bold = true; sheet.UsedRange.AutofitColumns(); #endregion #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("CLRObjects.xlsx", "application/msexcel", stream, m_context); } #endregion }
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) { // Create a new document. WordDocument document = new WordDocument(); // Adding a new section to the document. IWSection section = document.AddSection(); section.PageSetup.Margins.All = 50; section.PageSetup.DifferentFirstPage = true; IWTextRange textRange; IWParagraph paragraph = section.AddParagraph(); #region Table Cell Spacing. // -------------------------------------------- // Table Cell Spacing. // -------------------------------------------- paragraph.AppendText("Table Cell spacing...").CharacterFormat.FontSize = 14; section.AddParagraph(); paragraph = section.AddParagraph(); WTextBody textBody = section.Body; // Adding a new Table to the textbody. IWTable table = textBody.AddTable(); table.TableFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.Single; table.TableFormat.Paddings.All = 5.4f; RowFormat format = new RowFormat(); format.Paddings.All = 5; format.CellSpacing = 2; format.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.DotDash; format.IsBreakAcrossPages = true; table.ResetCells(25, 5, format, 90); IWTextRange text; table.Rows[0].IsHeader = true; for (int i = 0; i < table.Rows[0].Cells.Count; i++) { paragraph = table[0, i].AddParagraph() as WParagraph; paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center; text = paragraph.AppendText(string.Format("Header {0}", i + 1)); text.CharacterFormat.FontName = "Calibri"; text.CharacterFormat.FontSize = 10; text.CharacterFormat.Bold = true; text.CharacterFormat.TextColor = Syncfusion.Drawing.Color.FromArgb(0, 21, 84); table[0, i].CellFormat.BackColor = Syncfusion.Drawing.Color.FromArgb(203, 211, 226); } for (int i = 1; i < table.Rows.Count; i++) { for (int j = 0; j < 5; j++) { paragraph = table[i, j].AddParagraph() as WParagraph; paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center; text = paragraph.AppendText(string.Format("Cell {0} , {1}", i, j + 1)); text.CharacterFormat.TextColor = Syncfusion.Drawing.Color.FromArgb(242, 151, 50); text.CharacterFormat.Bold = true; if (i % 2 != 1) { table[i, j].CellFormat.BackColor = Syncfusion.Drawing.Color.FromArgb(231, 235, 245); } else { table[i, j].CellFormat.BackColor = Syncfusion.Drawing.Color.FromArgb(246, 249, 255); } } } //table.TableFormat.IsAutoResized = true; (table as WTable).AutoFit(AutoFitType.FitToContent); #endregion Table Cell Spacing. #region Nested Table // -------------------------------------------- // Nested Table. // -------------------------------------------- section.AddParagraph(); paragraph = section.AddParagraph(); paragraph.ParagraphFormat.PageBreakBefore = true; paragraph.AppendText("Nested Table...").CharacterFormat.FontSize = 14; section.AddParagraph(); paragraph = section.AddParagraph(); textBody = section.Body; // Adding a new Table to the textbody. table = textBody.AddTable(); format = new RowFormat(); format.Paddings.All = 5; format.CellSpacing = 2.5f; format.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.DotDash; table.ResetCells(5, 3, format, 100); for (int i = 0; i < table.Rows[0].Cells.Count; i++) { paragraph = table[0, i].AddParagraph() as WParagraph; paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center; text = paragraph.AppendText(string.Format("Header {0}", i + 1)); text.CharacterFormat.FontName = "Calibri"; text.CharacterFormat.FontSize = 10; text.CharacterFormat.Bold = true; text.CharacterFormat.TextColor = Syncfusion.Drawing.Color.FromArgb(0, 21, 84); table[0, i].CellFormat.BackColor = Syncfusion.Drawing.Color.FromArgb(242, 151, 50); } table[0, 2].Width = 200; for (int i = 1; i < table.Rows.Count; i++) { for (int j = 0; j < 3; j++) { paragraph = table[i, j].AddParagraph() as WParagraph; paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center; if ((i == 2) && (j == 2)) { text = paragraph.AppendText("Nested Table"); } else { text = paragraph.AppendText(string.Format("Cell {0} , {1}", i, j + 1)); } if ((j == 2)) { table[i, j].Width = 200; } text.CharacterFormat.TextColor = Syncfusion.Drawing.Color.FromArgb(242, 151, 50); text.CharacterFormat.Bold = true; } } // Adding a nested Table. IWTable nestTable = table[2, 2].AddTable(); format = new RowFormat(); format.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.DotDash; format.HorizontalAlignment = RowAlignment.Center; nestTable.ResetCells(3, 3, format, 45); for (int i = 0; i < nestTable.Rows.Count; i++) { for (int j = 0; j < 3; j++) { paragraph = nestTable[i, j].AddParagraph() as WParagraph; paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center; nestTable[i, j].CellFormat.BackColor = Syncfusion.Drawing.Color.FromArgb(231, 235, 245); text = paragraph.AppendText(string.Format("Cell {0} , {1}", i, j + 1)); text.CharacterFormat.TextColor = Syncfusion.Drawing.Color.Black; text.CharacterFormat.Bold = true; } } (nestTable as WTable).AutoFit(AutoFitType.FitToContent); (table as WTable).AutoFit(AutoFitType.FitToWindow); #endregion Nested Table MemoryStream stream = new MemoryStream(); document.Save(stream, FormatType.Docx); document.Close(); if (stream != null) { SaveAndroid androidSave = new SaveAndroid(); androidSave.Save("FormatTable.docx", "application/msword", stream, m_context); } }
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); } }
void OnButtonClicked(object sender, EventArgs e) { Assembly assembly = Assembly.GetExecutingAssembly(); WordDocument document = null; if (encryptDocument.Checked == true) { //create worddocument instances document = new WordDocument(); document.EnsureMinimal(); // Getting last section of the document. IWSection section = document.LastSection; // Adding a paragraph to the section. IWParagraph paragraph = section.AddParagraph(); // Writing text IWTextRange text = paragraph.AppendText("This document was encrypted with password"); text.CharacterFormat.FontSize = 16f; text.CharacterFormat.FontName = "Bitstream Vera Serif"; // Encrypt the document by giving password document.EncryptDocument("syncfusion"); } else { // Open an existing template document with single section. document = new WordDocument(); Stream inputStream = assembly.GetManifestResourceStream("SampleBrowser.Samples.DocIO.Templates.Security Settings.docx"); // Open an existing template document. document.Open(inputStream, FormatType.Docx, "syncfusion"); inputStream.Dispose(); // Getting last section of the document. IWSection section = document.LastSection; // Adding a paragraph to the section. IWParagraph paragraph = section.AddParagraph(); // Writing text IWTextRange text = paragraph.AppendText("\nDemo For Document Decryption with Essential DocIO"); text.CharacterFormat.FontSize = 16f; text.CharacterFormat.FontName = "Bitstream Vera Serif"; text = paragraph.AppendText("\nThis document is Decrypted"); text.CharacterFormat.FontSize = 16f; text.CharacterFormat.FontName = "Bitstream Vera Serif"; } MemoryStream ms = new MemoryStream(); //Set file content type string contentType = null; string fileName = null; //Save the document as docx fileName = "Encrypt and Decrypt.docx"; contentType = "application/msword"; document.Save(ms, FormatType.Docx); document.Dispose(); if (ms != null) { SaveAndroid androidSave = new SaveAndroid(); androidSave.Save(fileName, contentType, ms, m_context); } }