void OnButtonClicked(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 (this.importCheck.IsChecked.Value) { workbook.Version = ExcelVersion.Excel2013; System.Data.DataTable dataTable = new System.Data.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) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("CreateSheet.xlsx", "application/msexcel", stream); } }
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 offers over 1,000 components and frameworks for mobile, web, and desktop development."); 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) { SaveiOS iosSave = new SaveiOS(); iosSave.Save("GettingStarted.pdf", "application/pdf", stream); } }
void OnButtonClicked(object sender, EventArgs e) { Assembly assembly = Assembly.GetExecutingAssembly(); // Creating a new document. // Creating a new document. WordDocument document = new WordDocument(); //Adding a new section to the document. WSection section = document.AddSection() as WSection; //Set Margin of the section section.PageSetup.Margins.All = 72; //Set page size of the section section.PageSetup.PageSize = new Syncfusion.Drawing.SizeF(612, 792); //Create Paragraph styles WParagraphStyle style = document.AddParagraphStyle("Normal") as WParagraphStyle; style.CharacterFormat.FontName = "Calibri"; style.CharacterFormat.FontSize = 11f; style.ParagraphFormat.BeforeSpacing = 0; style.ParagraphFormat.AfterSpacing = 8; style.ParagraphFormat.LineSpacing = 13.8f; style = document.AddParagraphStyle("Heading 1") as WParagraphStyle; style.ApplyBaseStyle("Normal"); style.CharacterFormat.FontName = "Calibri Light"; style.CharacterFormat.FontSize = 16f; style.CharacterFormat.TextColor = Syncfusion.Drawing.Color.FromArgb(46, 116, 181); style.ParagraphFormat.BeforeSpacing = 12; style.ParagraphFormat.AfterSpacing = 0; style.ParagraphFormat.Keep = true; style.ParagraphFormat.KeepFollow = true; style.ParagraphFormat.OutlineLevel = OutlineLevel.Level1; IWParagraph paragraph = section.HeadersFooters.Header.AddParagraph(); Stream imageStream = assembly.GetManifestResourceStream("SampleBrowser.Samples.DocIO.Templates.AdventureCycle.jpg"); WPicture picture = paragraph.AppendPicture(imageStream) as WPicture; picture.TextWrappingStyle = TextWrappingStyle.InFrontOfText; picture.VerticalOrigin = VerticalOrigin.Margin; picture.VerticalPosition = -24; picture.HorizontalOrigin = HorizontalOrigin.Column; picture.HorizontalPosition = 263.5f; picture.WidthScale = 20; picture.HeightScale = 15; paragraph.ApplyStyle("Normal"); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Left; WTextRange textRange = paragraph.AppendText("Adventure Works Cycles") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Calibri"; textRange.CharacterFormat.TextColor = Syncfusion.Drawing.Color.Red; //Appends paragraph. paragraph = section.AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center; textRange = paragraph.AppendText("Adventure Works Cycles") as WTextRange; textRange.CharacterFormat.FontSize = 18f; textRange.CharacterFormat.FontName = "Calibri"; //Appends paragraph. paragraph = section.AddParagraph(); paragraph.ParagraphFormat.FirstLineIndent = 36; paragraph.BreakCharacterFormat.FontSize = 12f; textRange = paragraph.AppendText("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.") as WTextRange; textRange.CharacterFormat.FontSize = 12f; paragraph = section.AddParagraph(); paragraph.ParagraphFormat.FirstLineIndent = 36; paragraph.BreakCharacterFormat.FontSize = 12f; textRange = paragraph.AppendText("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.") as WTextRange; textRange.CharacterFormat.FontSize = 12f; paragraph = section.AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Left; textRange = paragraph.AppendText("Product Overview") as WTextRange; textRange.CharacterFormat.FontSize = 16f; textRange.CharacterFormat.FontName = "Calibri"; //Appends table. IWTable table = section.AddTable(); table.ResetCells(3, 2); table.TableFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.None; table.TableFormat.IsAutoResized = true; //Appends paragraph. paragraph = table[0, 0].AddParagraph(); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.BreakCharacterFormat.FontSize = 12f; imageStream = assembly.GetManifestResourceStream("SampleBrowser.Samples.DocIO.Templates.Mountain-200.jpg"); //Appends picture to the paragraph. picture = paragraph.AppendPicture(imageStream) as WPicture; picture.TextWrappingStyle = TextWrappingStyle.TopAndBottom; picture.VerticalOrigin = VerticalOrigin.Paragraph; picture.VerticalPosition = 0; picture.HorizontalOrigin = HorizontalOrigin.Column; picture.HorizontalPosition = -5.15f; picture.WidthScale = 79; picture.HeightScale = 79; //Appends paragraph. paragraph = table[0, 1].AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.AppendText("Mountain-200"); //Appends paragraph. paragraph = table[0, 1].AddParagraph(); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.BreakCharacterFormat.FontSize = 12f; paragraph.BreakCharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Product No: BK-M68B-38\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Size: 38\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Weight: 25\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Price: $2,294.99\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; //Appends paragraph. paragraph = table[0, 1].AddParagraph(); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.BreakCharacterFormat.FontSize = 12f; //Appends paragraph. paragraph = table[1, 0].AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.AppendText("Mountain-300 "); //Appends paragraph. paragraph = table[1, 0].AddParagraph(); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.BreakCharacterFormat.FontSize = 12f; paragraph.BreakCharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Product No: BK-M47B-38\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Size: 35\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Weight: 22\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Price: $1,079.99\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; //Appends paragraph. paragraph = table[1, 0].AddParagraph(); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.BreakCharacterFormat.FontSize = 12f; //Appends paragraph. paragraph = table[1, 1].AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.LineSpacing = 12f; imageStream = assembly.GetManifestResourceStream("SampleBrowser.Samples.DocIO.Templates.Mountain-300.jpg"); //Appends picture to the paragraph. picture = paragraph.AppendPicture(imageStream) as WPicture; picture.TextWrappingStyle = TextWrappingStyle.TopAndBottom; picture.VerticalOrigin = VerticalOrigin.Paragraph; picture.VerticalPosition = 8.2f; picture.HorizontalOrigin = HorizontalOrigin.Column; picture.HorizontalPosition = -14.95f; picture.WidthScale = 75; picture.HeightScale = 75; //Appends paragraph. paragraph = table[2, 0].AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.LineSpacing = 12f; imageStream = assembly.GetManifestResourceStream("SampleBrowser.Samples.DocIO.Templates.Road-550-W.jpg"); //Appends picture to the paragraph. picture = paragraph.AppendPicture(imageStream) as WPicture; picture.TextWrappingStyle = TextWrappingStyle.TopAndBottom; picture.VerticalOrigin = VerticalOrigin.Paragraph; picture.VerticalPosition = 0; picture.HorizontalOrigin = HorizontalOrigin.Column; picture.HorizontalPosition = -4.9f; picture.WidthScale = 92; picture.HeightScale = 92; //Appends paragraph. paragraph = table[2, 1].AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.AppendText("Road-150 "); //Appends paragraph. paragraph = table[2, 1].AddParagraph(); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.BreakCharacterFormat.FontSize = 12f; paragraph.BreakCharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Product No: BK-R93R-44\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Size: 44\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Weight: 14\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Price: $3,578.27\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; //Appends paragraph. paragraph = table[2, 1].AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.LineSpacing = 12f; //Appends paragraph. section.AddParagraph(); MemoryStream stream = new MemoryStream(); document.Save(stream, FormatType.Word2013); document.Close(); if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("GettingStarted.docx", "application/msword", stream); } }
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.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) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("FormatTable.docx", "application/msword", stream); } }
void OnConvertClicked(object sender, EventArgs e) { WordDocument document = null; if (encryptButton != null && (bool)encryptButton.IsChecked) { //Creates a new Word document 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 { Assembly assembly = Assembly.GetExecutingAssembly(); document = new WordDocument(); // Open an existing template document. Stream inputStream = assembly.GetManifestResourceStream("SampleBrowser.Samples.DocIO.Templates.Security Settings.docx"); 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"; } string fileName = null; string ContentType = null; MemoryStream ms = new MemoryStream(); fileName = "Encrypt and Decrypt.docx"; ContentType = "application/msword"; document.Save(ms, FormatType.Docx); //Reset the stream position ms.Position = 0; //Close the document instance. document.Close(); if (ms != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save(fileName, ContentType, ms as MemoryStream); } }
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 = 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 = "Adobe Garamond Pro"; 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 = "Adobe Garamond Pro"; 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 = "Adobe Garamond Pro"; textPart2.Font.FontSize = 21; #endregion MemoryStream stream = new MemoryStream(); presentation.Save(stream); presentation.Close(); stream.Position = 0; if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("GettingStartedPresentation.pptx", "application/mspowerpoint", stream); } }
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.doc"); // 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.doc"); // 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); // 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) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("BookmarksNavigation.docx", "application/msword", stream); } #endregion }
void OnConvertClicked(object sender, EventArgs e) { WordDocument doc = new WordDocument(); doc.EnsureMinimal(); WParagraph para = doc.LastParagraph; para.AppendText("Essential DocIO - Table of Contents"); para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center; para.ApplyStyle(BuiltinStyle.Heading4); para = doc.LastSection.AddParagraph() as WParagraph; para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center; para.ApplyStyle(BuiltinStyle.Heading4); para = doc.LastSection.AddParagraph() as WParagraph; //Insert TOC TableOfContent toc = para.AppendTOC(1, 3); para.ApplyStyle(BuiltinStyle.Heading4); //Apply built-in paragraph formatting WSection section = doc.LastSection; #region Default Styles WParagraph newPara = section.AddParagraph() as WParagraph; newPara = section.AddParagraph() as WParagraph; newPara.AppendBreak(BreakType.PageBreak); WTextRange text = newPara.AppendText("Document with Default styles") as WTextRange; newPara.ApplyStyle(BuiltinStyle.Heading1); newPara = section.AddParagraph() as WParagraph; newPara.AppendText("This is the heading1 of built in style. This sample demonstrates the TOC insertion in a word document. Note that DocIO can only insert TOC field in a word document. It can not refresh or create TOC field. MS Word refreshes the TOC field after insertion. Please update the field or press F9 key to refresh the TOC."); section.AddParagraph(); newPara = section.AddParagraph() as WParagraph; text = newPara.AppendText("Section1") as WTextRange; newPara.ApplyStyle(BuiltinStyle.Heading2); newPara = section.AddParagraph() as WParagraph; newPara.AppendText("This is the heading2 of built in style. A document can contain any number of sections. Sections are used to apply same formatting for a group of paragraphs. You can insert sections by inserting section breaks."); section.AddParagraph(); newPara = section.AddParagraph() as WParagraph; text = newPara.AppendText("Paragraph1") as WTextRange; newPara.ApplyStyle(BuiltinStyle.Heading3); newPara = section.AddParagraph() as WParagraph; newPara.AppendText("This is the heading3 of built in style. Each section contains any number of paragraphs. A paragraph is a set of statements that gives a meaning for the text."); section.AddParagraph(); newPara = section.AddParagraph() as WParagraph; text = newPara.AppendText("Paragraph2") as WTextRange; newPara.ApplyStyle(BuiltinStyle.Heading3); newPara = section.AddParagraph() as WParagraph; newPara.AppendText("This is the heading3 of built in style. This demonstrates the paragraphs at the same level and style as that of the previous one. A paragraph can have any number formatting. This can be attained by formatting each text range in the paragraph."); section.AddParagraph(); section = doc.AddSection() as WSection; section.BreakCode = SectionBreakCode.NewPage; newPara = section.AddParagraph() as WParagraph; text = newPara.AppendText("Section2") as WTextRange; newPara.ApplyStyle(BuiltinStyle.Heading2); newPara = section.AddParagraph() as WParagraph; newPara.AppendText("This is the heading2 of built in style. A document can contain any number of sections. Sections are used to apply same formatting for a group of paragraphs. You can insert sections by inserting section breaks."); section.AddParagraph(); newPara = section.AddParagraph() as WParagraph; text = newPara.AppendText("Paragraph1") as WTextRange; newPara.ApplyStyle(BuiltinStyle.Heading3); newPara = section.AddParagraph() as WParagraph; newPara.AppendText("This is the heading3 of built in style. Each section contains any number of paragraphs. A paragraph is a set of statements that gives a meaning for the text."); section.AddParagraph(); newPara = section.AddParagraph() as WParagraph; text = newPara.AppendText("Paragraph2") as WTextRange; newPara.ApplyStyle(BuiltinStyle.Heading3); newPara = section.AddParagraph() as WParagraph; newPara.AppendText("This is the heading3 of built in style. This demonstrates the paragraphs at the same level and style as that of the previous one. A paragraph can have any number formatting. This can be attained by formatting each text range in the paragraph."); #endregion toc.IncludePageNumbers = true; toc.RightAlignPageNumbers = true; toc.UseHyperlinks = true; toc.LowerHeadingLevel = 1; toc.UpperHeadingLevel = 3; toc.UseOutlineLevels = true; //Updates the table of contents. doc.UpdateTableOfContents(); string fileName = null; string ContentType = null; MemoryStream ms = new MemoryStream(); if (pdfButton != null && (bool)pdfButton.IsChecked) { fileName = "Table of Contents.pdf"; ContentType = "application/pdf"; DocIORenderer renderer = new DocIORenderer(); PdfDocument pdfDoc = renderer.ConvertToPDF(doc); pdfDoc.Save(ms); pdfDoc.Close(); } else { fileName = "Table of Contents.docx"; ContentType = "application/msword"; doc.Save(ms, FormatType.Docx); } //Reset the stream position ms.Position = 0; //Close the document instance. doc.Close(); if (ms != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save(fileName, ContentType, ms as MemoryStream); } }
void OnConvertClicked(object sender, EventArgs e) { //Creates a new Word document WordDocument document = new WordDocument(); //Adds new section to the document IWSection section = document.AddSection(); //Sets page setup options section.PageSetup.Orientation = PageOrientation.Landscape; section.PageSetup.Margins.All = 72; section.PageSetup.PageSize = new SizeF(792f, 612f); //Adds new paragraph to the section WParagraph paragraph = section.AddParagraph() as WParagraph; //Creates new group shape GroupShape groupShape = new GroupShape(document); //Adds group shape to the paragraph. paragraph.ChildEntities.Add(groupShape); //Create a RoundedRectangle shape with "Management" text CreateChildShape(AutoShapeType.RoundedRectangle, new RectangleF(324f, 107.7f, 144f, 45f), 0, false, false, Syncfusion.Drawing.Color.FromArgb(50, 48, 142), "Management", groupShape, document); //Create a BentUpArrow shape to connect with "Development" shape CreateChildShape(AutoShapeType.BentUpArrow, new RectangleF(177.75f, 176.25f, 210f, 50f), 180, false, false, Syncfusion.Drawing.Color.White, null, groupShape, document); //Create a BentUpArrow shape to connect with "Sales" shape CreateChildShape(AutoShapeType.BentUpArrow, new RectangleF(403.5f, 175.5f, 210f, 50f), 180, true, false, Syncfusion.Drawing.Color.White, null, groupShape, document); //Create a DownArrow shape to connect with "Production" shape CreateChildShape(AutoShapeType.DownArrow, new RectangleF(381f, 153f, 29.25f, 72.5f), 0, false, false, Syncfusion.Drawing.Color.White, null, groupShape, document); //Create a RoundedRectangle shape with "Development" text CreateChildShape(AutoShapeType.RoundedRectangle, new RectangleF(135f, 226.45f, 110f, 40f), 0, false, false, Syncfusion.Drawing.Color.FromArgb(104, 57, 157), "Development", groupShape, document); //Create a RoundedRectangle shape with "Production" text CreateChildShape(AutoShapeType.RoundedRectangle, new RectangleF(341f, 226.5f, 110f, 40f), 0, false, false, Syncfusion.Drawing.Color.FromArgb(149, 50, 118), "Production", groupShape, document); //Create a RoundedRectangle shape with "Sales" text CreateChildShape(AutoShapeType.RoundedRectangle, new RectangleF(546.75f, 226.5f, 110f, 40f), 0, false, false, Syncfusion.Drawing.Color.FromArgb(179, 63, 62), "Sales", groupShape, document); //Create a DownArrow shape to connect with "Software" and "Hardware" shape CreateChildShape(AutoShapeType.DownArrow, new RectangleF(177f, 265.5f, 25.5f, 20.25f), 0, false, false, Syncfusion.Drawing.Color.White, null, groupShape, document); //Create a DownArrow shape to connect with "Series" and "Parts" shape CreateChildShape(AutoShapeType.DownArrow, new RectangleF(383.25f, 265.5f, 25.5f, 20.25f), 0, false, false, Syncfusion.Drawing.Color.White, null, groupShape, document); //Create a DownArrow shape to connect with "North" and "South" shape CreateChildShape(AutoShapeType.DownArrow, new RectangleF(588.75f, 266.25f, 25.5f, 20.25f), 0, false, false, Syncfusion.Drawing.Color.White, null, groupShape, document); //Create a BentUpArrow shape to connect with "Software" shape CreateChildShape(AutoShapeType.BentUpArrow, new RectangleF(129.5f, 286.5f, 60f, 33f), 180, false, false, Syncfusion.Drawing.Color.White, null, groupShape, document); //Create a BentUpArrow shape to connect with "Hardware" shape CreateChildShape(AutoShapeType.BentUpArrow, new RectangleF(190.5f, 286.5f, 60f, 33f), 180, true, false, Syncfusion.Drawing.Color.White, null, groupShape, document); //Create a BentUpArrow shape to connect with "Series" shape CreateChildShape(AutoShapeType.BentUpArrow, new RectangleF(336f, 287.25f, 60f, 33f), 180, false, false, Syncfusion.Drawing.Color.White, null, groupShape, document); //Create a BentUpArrow shape to connect with "Parts" shape CreateChildShape(AutoShapeType.BentUpArrow, new RectangleF(397f, 287.25f, 60f, 33f), 180, true, false, Syncfusion.Drawing.Color.White, null, groupShape, document); //Create a BentUpArrow shape to connect with "North" shape CreateChildShape(AutoShapeType.BentUpArrow, new RectangleF(541.5f, 288f, 60f, 33f), 180, false, false, Syncfusion.Drawing.Color.White, null, groupShape, document); //Create a BentUpArrow shape to connect with "South" shape CreateChildShape(AutoShapeType.BentUpArrow, new RectangleF(602.5f, 288f, 60f, 33f), 180, true, false, Syncfusion.Drawing.Color.White, null, groupShape, document); //Create a RoundedRectangle shape with "Software" text CreateChildShape(AutoShapeType.RoundedRectangle, new RectangleF(93f, 320.25f, 90f, 40f), 0, false, false, Syncfusion.Drawing.Color.FromArgb(23, 187, 189), "Software", groupShape, document); //Create a RoundedRectangle shape with "Hardware" text CreateChildShape(AutoShapeType.RoundedRectangle, new RectangleF(197.2f, 320.25f, 90f, 40f), 0, false, false, Syncfusion.Drawing.Color.FromArgb(24, 159, 106), "Hardware", groupShape, document); //Create a RoundedRectangle shape with "Series" text CreateChildShape(AutoShapeType.RoundedRectangle, new RectangleF(299.25f, 320.25f, 90f, 40f), 0, false, false, Syncfusion.Drawing.Color.FromArgb(23, 187, 189), "Series", groupShape, document); //Create a RoundedRectangle shape with "Parts" text CreateChildShape(AutoShapeType.RoundedRectangle, new RectangleF(404.2f, 320.25f, 90f, 40f), 0, false, false, Syncfusion.Drawing.Color.FromArgb(24, 159, 106), "Parts", groupShape, document); //Create a RoundedRectangle shape with "North" text CreateChildShape(AutoShapeType.RoundedRectangle, new RectangleF(505.5f, 321.75f, 90f, 40f), 0, false, false, Syncfusion.Drawing.Color.FromArgb(23, 187, 189), "North", groupShape, document); //Create a RoundedRectangle shape with "South" text CreateChildShape(AutoShapeType.RoundedRectangle, new RectangleF(609.7f, 321.75f, 90f, 40f), 0, false, false, Syncfusion.Drawing.Color.FromArgb(24, 159, 106), "South", groupShape, document); string fileName = null; string ContentType = null; MemoryStream ms = new MemoryStream(); if (pdfButton != null && (bool)pdfButton.IsChecked) { fileName = "GroupShapes.pdf"; ContentType = "application/pdf"; DocIORenderer renderer = new DocIORenderer(); PdfDocument pdfDoc = renderer.ConvertToPDF(document); pdfDoc.Save(ms); pdfDoc.Close(); } else { fileName = "GroupShapes.docx"; ContentType = "application/msword"; document.Save(ms, FormatType.Docx); } //Reset the stream position ms.Position = 0; //Close the document instance. document.Close(); if (ms != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save(fileName, ContentType, ms as MemoryStream); } }
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 = 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) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("SlidesPresentation.pptx", "application/mspowerpoint", stream); } }
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 = 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); IPicture picture1 = 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) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("ImagesPresentation.pptx", "application/mspowerpoint", stream); } }
void OnButtonClicked(object sender, EventArgs e) { //Create new PDF document. PdfDocument document = new PdfDocument(); //Add page to the PDF document. PdfPage page = document.Pages.Add(); PdfGraphics graphics = page.Graphics; //Create font object. PdfStandardFont font = new PdfStandardFont(PdfFontFamily.TimesRoman, 14f, PdfFontStyle.Bold); PdfBrush brush = PdfBrushes.Black; //Document security PdfSecurity security = document.Security; int algorithmindex = algorithmlist.IndexOf(algorithmfilterType); int keyindex; if (algorithmindex == 0) { keyindex = AESkeylist.IndexOf(keysizefilterType); security.Algorithm = PdfEncryptionAlgorithm.AES; if (keyindex == 0) { security.KeySize = PdfEncryptionKeySize.Key128Bit; } else if (keyindex == 1) { security.KeySize = PdfEncryptionKeySize.Key256Bit; } else if (keyindex == 2) { security.KeySize = PdfEncryptionKeySize.Key256BitRevision6; } } else { keyindex = RC4keylist.IndexOf(keysizefilterType); if (keyindex == 0) { security.KeySize = PdfEncryptionKeySize.Key40Bit; } else if (keyindex == 1) { security.KeySize = PdfEncryptionKeySize.Key128Bit; } } int optionIndex = options.IndexOf(optionType); if (optionIndex == 0) { security.EncryptionOptions = PdfEncryptionOptions.EncryptAllContents; } else if (optionIndex == 1) { security.EncryptionOptions = PdfEncryptionOptions.EncryptAllContentsExceptMetadata; } else if (optionIndex == 2) { //Read the file Stream file = typeof(DigitalSignatureValidation).GetTypeInfo().Assembly.GetManifestResourceStream("SampleBrowser.Samples.PDF.Assets.Products.xml"); //Creates an attachment PdfAttachment attachment = new PdfAttachment("Products.xml", file); attachment.ModificationDate = DateTime.Now; attachment.Description = "About Syncfusion"; attachment.MimeType = "application/txt"; //Adds the attachment to the document document.Attachments.Add(attachment); security.EncryptionOptions = PdfEncryptionOptions.EncryptOnlyAttachments; } security.Permissions = PdfPermissionsFlags.Print | PdfPermissionsFlags.FullQualityPrint; security.UserPassword = "******"; security.OwnerPassword = "******"; string text = "Security options:\n\n" + String.Format("KeySize: {0}\n\nEncryption Algorithm: {4}\n\nOwner Password: {1}\n\nPermissions: {2}\n\n" + "UserPassword: {3}", security.KeySize, security.OwnerPassword, security.Permissions, security.UserPassword, security.Algorithm); if (algorithmindex == 1) { if (keyindex == 2) { text += String.Format("\n\nRevision: {0}", "Revision 6"); } else if (keyindex == 1) { text += String.Format("\n\nRevision: {0}", "Revision 5"); } } // Draw String. graphics.DrawString("Document is Encrypted with following settings", font, brush, Syncfusion.Drawing.PointF.Empty); font = new PdfStandardFont(PdfFontFamily.TimesRoman, 11f, PdfFontStyle.Bold); graphics.DrawString(text, font, brush, new Syncfusion.Drawing.PointF(0, 40)); MemoryStream stream = new MemoryStream(); //Save the PDF document. document.Save(stream); document.Close(); if (stream != null) { stream.Position = 0; SaveiOS iosSave = new SaveiOS(); iosSave.Save("Secure.pdf", "application/pdf", stream); } }
void OnButtonClicked(object sender, EventArgs e) { //Create new PDF document. PdfDocument document = new PdfDocument(); //Add page to the PDF document. PdfPage page = document.Pages.Add(); PdfGraphics graphics = page.Graphics; //Create font object. PdfStandardFont font = new PdfStandardFont(PdfFontFamily.TimesRoman, 14f, PdfFontStyle.Bold); PdfBrush brush = PdfBrushes.Black; //Document security PdfSecurity security = document.Security; int algorithmindex = algorithmlist.IndexOf(algorithmfilterType); int keyindex; if (algorithmindex == 0) { keyindex = AESkeylist.IndexOf(keysizefilterType); security.Algorithm = PdfEncryptionAlgorithm.AES; if (keyindex == 0) { security.KeySize = PdfEncryptionKeySize.Key128Bit; } else if (keyindex == 1) { security.KeySize = PdfEncryptionKeySize.Key256Bit; } else if (keyindex == 2) { security.KeySize = PdfEncryptionKeySize.Key256BitRevision6; } } else { keyindex = RC4keylist.IndexOf(keysizefilterType); if (keyindex == 0) { security.KeySize = PdfEncryptionKeySize.Key40Bit; } else if (keyindex == 1) { security.KeySize = PdfEncryptionKeySize.Key128Bit; } } security.Permissions = PdfPermissionsFlags.Print | PdfPermissionsFlags.FullQualityPrint; security.UserPassword = "******"; security.OwnerPassword = "******"; string text = "Security options:\n\n" + String.Format("KeySize: {0}\n\nEncryption Algorithm: {4}\n\nOwner Password: {1}\n\nPermissions: {2}\n\n" + "UserPassword: {3}", security.KeySize, security.OwnerPassword, security.Permissions, security.UserPassword, security.Algorithm); if (algorithmindex == 1) { if (keyindex == 2) { text += String.Format("\n\nRevision: {0}", "Revision 6"); } else if (keyindex == 1) { text += String.Format("\n\nRevision: {0}", "Revision 5"); } } // Draw String. graphics.DrawString("Document is Encrypted with following settings", font, brush, Syncfusion.Drawing.PointF.Empty); font = new PdfStandardFont(PdfFontFamily.TimesRoman, 11f, PdfFontStyle.Bold); graphics.DrawString(text, font, brush, new Syncfusion.Drawing.PointF(0, 40)); MemoryStream stream = new MemoryStream(); //Save the PDF document. document.Save(stream); document.Close(); if (stream != null) { stream.Position = 0; SaveiOS iosSave = new SaveiOS(); iosSave.Save("Secure.pdf", "application/pdf", stream); } }
void OnButtonClicked(object sender, EventArgs e) { //Creates a new word document instance WordDocument document = new WordDocument(); //Adds new section to the document IWSection section = document.AddSection(); //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(); document.Save(stream, FormatType.Word2013); document.Close(); if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("CreateEquation.docx", "application/msword", stream); } }
void OnExportButtonClicked(object sender, EventArgs e) { ExcelEngine excelEngine = new ExcelEngine(); IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Excel2013; //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]; //Get DataGrid's datasource as DataTable System.Data.DataTable dataTable = (System.Data.DataTable)sfGrid.ItemsSource; //Import DataTable to Excel worksheet. sheet.ImportDataTable(dataTable, 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 workbook.Version = ExcelVersion.Excel2013; MemoryStream stream = new MemoryStream(); workbook.SaveAs(stream); workbook.Close(); excelEngine.Dispose(); if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("DataTable.xlsx", "application/msexcel", stream); } }
void OnButtonClicked(object sender, EventArgs e) { //Create an instance for PowerPoint IPresentation presentation = Presentation.Create(); //Add a blank slide to Presentation ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank); //Add header shape IShape headerTextBox = slide.Shapes.AddTextBox(255.60, 11.35, 315.33, 41.20); //Add a paragraph into the text box IParagraph paragraph = headerTextBox.TextBody.AddParagraph("Flow chart with connector"); //Set the font size of the paragraph paragraph.Font.FontSize = 28; //Add start shape to slide IShape startShape = slide.Shapes.AddShape(AutoShapeType.FlowChartTerminator, 343.69, 79.22, 101.34, 35.86); //Add a paragraph into the start shape text body AddParagraph(startShape, "Start"); //Add alarm shape to slide IShape alarmShape = slide.Shapes.AddShape(AutoShapeType.FlowChartProcess, 343.69, 151.35, 101.34, 44.93); //Add a paragraph into the alarm shape text body AddParagraph(alarmShape, "Alarm Rings"); //Add condition shape to slide IShape conditionShape = slide.Shapes.AddShape(AutoShapeType.FlowChartDecision, 343.69, 239.22, 101.34, 73.98); //Add a paragraph into the condition shape text body AddParagraph(conditionShape, "Ready to Get Up ?"); //Change font size of the paragraph conditionShape.TextBody.Paragraphs[0].Font.FontSize = 12; //Add wake up shape to slide IShape wakeUpShape = slide.Shapes.AddShape(AutoShapeType.FlowChartProcess, 343.69, 356.15, 101.34, 44.93); //Add a paragraph into the wake up shape text body AddParagraph(wakeUpShape, "Wake Up"); //Add end shape to slide IShape endShape = slide.Shapes.AddShape(AutoShapeType.FlowChartTerminator, 343.69, 447.93, 101.34, 35.86); //Add a paragraph into the end shape text body AddParagraph(endShape, "End"); //Add snooze shape to slide IShape snoozeShape = slide.Shapes.AddShape(AutoShapeType.FlowChartProcess, 545.09, 239.22, 101.34, 73.98); //Add a paragraph into the snooze shape text body AddParagraph(snoozeShape, "Hit Snooze button"); //Add relay shape to slide IShape relayShape = slide.Shapes.AddShape(AutoShapeType.FlowChartDelay, 545.09, 151.35, 101.34, 44.93); //Add a paragraph into the relay shape text body AddParagraph(relayShape, "Relay"); //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(470.97, 250.34, 35.67, 29.08); //Add a paragraph into the text box noTextBox.TextBody.AddParagraph("No"); //Add Yes textbox to slide IShape yesTextBox = slide.Shapes.AddTextBox(394.15, 314.92, 38.23, 29.08); //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) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("ConnectorsPresentation.pptx", "application/mspowerpoint", stream); } }
void OnButtonClicked(object sender, EventArgs e) { Assembly assembly = Assembly.GetExecutingAssembly(); Stream inputStream = assembly.GetManifestResourceStream("SampleBrowser.Samples.DocIO.Templates.ContentControlTemplate.docx"); //Creates an empty Word document instance. WordDocument document = new WordDocument(); //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) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("FormFillingAndProtection.docx", "application/msword", stream); } }
void OnButtonClicked(object sender, EventArgs e) { #region Workbook Initialize ExcelEngine engine = new ExcelEngine(); IApplication application = engine.Excel; application.DefaultVersion = ExcelVersion.Excel2016; IWorkbook workbook = application.Workbooks.Create(1); IWorksheet sheet = workbook.Worksheets[0]; sheet.EnableSheetCalculations(); sheet["A40"].Activate(); #endregion #region Worksheet Data sheet.Name = "Inventory"; sheet.IsGridLinesVisible = false; sheet["A1"].Text = "INVENTORY LIST"; sheet["A3"].Text = "TOTAL INVENTORY VALUE"; sheet["D3"].Text = "TOTAL ITEMS"; sheet["F3"].Text = "BIN COUNT"; sheet["A6"].Text = "ID"; sheet["B6"].Text = "Name"; sheet["C6"].Text = "Bin #"; sheet["D6"].Text = "Unit Price"; sheet["E6"].Text = "Quantity in Stock"; sheet["F6"].Text = "Inventory Value"; sheet["A7"].Text = "IN001"; sheet["B7"].Text = "Item 1"; sheet["C7"].Text = "T340"; sheet["D7"].Number = 51; sheet["E7:E26"].Number = 25; sheet["A8"].Text = "IN002"; sheet["B8"].Text = "Item 2"; sheet["C8"].Text = "T5780"; sheet["D8"].Number = 93; sheet["A9"].Text = "IN003"; sheet["B9"].Text = "Item 3"; sheet["C9"].Text = "T340"; sheet["D9"].Number = 57; sheet["A10"].Text = "IN004"; sheet["B10"].Text = "Item 4"; sheet["C10"].Text = "T908"; sheet["D10"].Number = 19; sheet["A11"].Text = "IN005"; sheet["B11"].Text = "Item 5"; sheet["C11"].Text = "T9845"; sheet["D11"].Number = 75; sheet["A12"].Text = "IN006"; sheet["B12"].Text = "Item 6"; sheet["C12"].Text = "T540"; sheet["D12"].Number = 11; sheet["A13"].Text = "IN007"; sheet["B13"].Text = "Item 7"; sheet["C13"].Text = "T5780"; sheet["D13"].Number = 56; sheet["A14"].Text = "IN008"; sheet["B14"].Text = "Item 8"; sheet["C14"].Text = "T340"; sheet["D14"].Number = 38; sheet["A15"].Text = "IN009"; sheet["B15"].Text = "Item 9"; sheet["C15"].Text = "T908"; sheet["D15"].Number = 59; sheet["A16"].Text = "IN010"; sheet["B16"].Text = "Item 10"; sheet["C16"].Text = "T9845"; sheet["D16"].Number = 50; sheet["A17"].Text = "IN011"; sheet["B17"].Text = "Item 11"; sheet["C17"].Text = "T306"; sheet["D17"].Number = 59; sheet["A18"].Text = "IN012"; sheet["B18"].Text = "Item 12"; sheet["C18"].Text = "T5780"; sheet["D18"].Number = 18; sheet["A19"].Text = "IN013"; sheet["B19"].Text = "Item 13"; sheet["C19"].Text = "T306"; sheet["D19"].Number = 26; sheet["A20"].Text = "IN014"; sheet["B20"].Text = "Item 14"; sheet["C20"].Text = "T908"; sheet["D20"].Number = 42; sheet["A21"].Text = "IN015"; sheet["B21"].Text = "Item 15"; sheet["C21"].Text = "T9845"; sheet["D21"].Number = 32; sheet["A22"].Text = "IN016"; sheet["B22"].Text = "Item 16"; sheet["C22"].Text = "T415"; sheet["D22"].Number = 90; sheet["A23"].Text = "IN017"; sheet["B23"].Text = "Item 17"; sheet["C23"].Text = "T5780"; sheet["D23"].Number = 12; sheet["A24"].Text = "IN018"; sheet["B24"].Text = "Item 18"; sheet["C24"].Text = "T340"; sheet["D24"].Number = 82; sheet["A25"].Text = "IN019"; sheet["B25"].Text = "Item 19"; sheet["C25"].Text = "T908"; sheet["D25"].Number = 16; sheet["A26"].Text = "IN020"; sheet["B26"].Text = "Item 20"; sheet["C26"].Text = "T9845"; sheet["D26"].Number = 11; sheet["A27"].Text = "Total"; #endregion #region Formatting sheet.Range["A1:F1"].Merge(); sheet.Range["A4:B4"].Merge(); sheet["A1"].CellStyle.Font.Bold = true; sheet["A1"].CellStyle.Font.FontName = "Calibri"; sheet["A1"].CellStyle.Font.Size = 18; sheet.Range["A1:F1"].CellStyle.IncludeBorder = true; sheet.Range["A1:F1"].CellStyle.Borders[ExcelBordersIndex.EdgeBottom].ColorRGB = COLOR.FromArgb(0, 204, 153); sheet.Range["A1:F1"].CellStyle.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Medium; sheet["A3:F3"].CellStyle.Font.Bold = true; sheet["A3:F3"].CellStyle.Font.FontName = "Calibri"; sheet["A3:F3"].CellStyle.Font.Size = 9; sheet["A4:F4"].CellStyle.Font.Bold = true; sheet["A4:F4"].CellStyle.Font.FontName = "Calibri"; sheet["A4:F4"].CellStyle.Font.Size = 14; sheet["A4:F4"].CellStyle.Font.RGBColor = COLOR.FromArgb(0, 204, 153); sheet["A4"].HorizontalAlignment = ExcelHAlign.HAlignCenter; sheet["A4"].NumberFormat = "_($* #,##0.00_)"; sheet["A6:F6"].CellStyle.Font.FontName = "Calibri"; sheet["A6:F6"].CellStyle.Font.Size = 11; sheet["A6:F6"].CellStyle.Font.Bold = true; sheet["A6:F6"].CellStyle.Font.RGBColor = COLOR.FromArgb(255, 255, 255); sheet["A6:F6"].WrapText = true; sheet["A6:F6"].VerticalAlignment = ExcelVAlign.VAlignTop; sheet.Range["A6:F6"].CellStyle.Color = COLOR.FromArgb(0, 204, 153); sheet["A6:F27"].CellStyle.Font.FontName = "Calibri"; sheet["A6:F27"].CellStyle.Font.Size = 11; sheet["D7:F27"].NumberFormat = "_($* #,##0.00_)"; sheet["D4:F4"].HorizontalAlignment = ExcelHAlign.HAlignLeft; sheet["A27:F27"].CellStyle.Font.FontName = "Calibri"; sheet["A27:F27"].CellStyle.Font.Size = 11; sheet["A27:F27"].CellStyle.Font.Bold = true; sheet.Range["A7:27"].CellStyle.IncludeBorder = true; sheet.Range["A7:F27"].CellStyle.Borders.ColorRGB = COLOR.FromArgb(112, 173, 71); sheet.Range["A7:F27"].CellStyle.Borders.LineStyle = ExcelLineStyle.Thin; sheet.Range["A7:F27"].CellStyle.Borders[ExcelBordersIndex.DiagonalUp].ShowDiagonalLine = false; sheet.Range["A7:F27"].CellStyle.Borders[ExcelBordersIndex.DiagonalDown].ShowDiagonalLine = false; sheet["A26:F26"].CellStyle.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Double; sheet.Range["A1:F1"].RowHeight = 24; sheet["A2"].RowHeight = 7.18; sheet["A3"].RowHeight = 23.5; sheet["A4"].RowHeight = 19.5; sheet["A5"].RowHeight = 6.8; sheet["A6"].RowHeight = 41.3; sheet["A1:B1"].ColumnWidth = 7.18; sheet["C1"].ColumnWidth = 6.91; sheet["D1"].ColumnWidth = 9.55; sheet["E1"].ColumnWidth = 8.91; sheet["F1"].ColumnWidth = 11.18; #endregion #region Formula sheet["D4"].Formula = "=COUNT(D7:D26)"; sheet["F4"].Formula = "=SUMPRODUCT(1/COUNTIF(C7:C26,C7:C26))"; for (int i = 7; i < 27; i++) { sheet["F" + i].Formula = "=D" + i + "*E" + i; } sheet["D27"].Formula = "SUM(D7:D26)"; sheet["E27"].Formula = "SUM(E7:E26)"; sheet["F27"].Formula = "SUM(F7:F26)"; sheet["A4"].Formula = "=F27"; #endregion workbook.Version = ExcelVersion.Excel2013; MemoryStream stream = new MemoryStream(); workbook.SaveAs(stream); workbook.Close(); engine.Dispose(); if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("Formulas.xlsx", "application/msexcel", stream); } }
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) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("CreateSheet.xlsx", "application/msexcel", stream); } }
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 string fileName = null; string ContentType = null; MemoryStream ms = new MemoryStream(); if (pdfButton != null && (bool)pdfButton.IsChecked) { fileName = "CreateEquation.pdf"; ContentType = "application/pdf"; DocIORenderer renderer = new DocIORenderer(); PdfDocument pdfDoc = renderer.ConvertToPDF(document); pdfDoc.Save(ms); pdfDoc.Close(); } else { fileName = "CreateEquation.docx"; ContentType = "application/msword"; document.Save(ms, FormatType.Docx); } //Reset the stream position ms.Position = 0; document.Close(); if (ms != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save(fileName, ContentType, ms as MemoryStream); } }
void OnButtonClicked(object sender, EventArgs e) { PdfDocument document = null; int index = layoutList.IndexOf(selectedLayout); if (index == 0) { //Create a new PDF document document = new PdfDocument(PdfConformanceLevel.Pdf_A1A); } else if (index == 1) { document = new PdfDocument(PdfConformanceLevel.Pdf_A1B); } else if (index == 2) { document = new PdfDocument(PdfConformanceLevel.Pdf_A2A); } else if (index == 3) { document = new PdfDocument(PdfConformanceLevel.Pdf_A2B); } else if (index == 4) { document = new PdfDocument(PdfConformanceLevel.Pdf_A2U); } else { if (index == 5) { document = new PdfDocument(PdfConformanceLevel.Pdf_A3A); } else if (index == 6) { document = new PdfDocument(PdfConformanceLevel.Pdf_A3B); } else if (index == 7) { document = new PdfDocument(PdfConformanceLevel.Pdf_A3U); } Stream imgStream = typeof(Conformance).GetTypeInfo().Assembly.GetManifestResourceStream("SampleBrowser.Samples.PDF.Assets.Products.xml"); PdfAttachment attachment = new PdfAttachment("PDF_A.xml", imgStream); attachment.Relationship = PdfAttachmentRelationship.Alternative; attachment.ModificationDate = DateTime.Now; attachment.Description = "PDF_A"; attachment.MimeType = "application/xml"; document.Attachments.Add(attachment); } PdfPage page = document.Pages.Add(); //Create font Stream arialFontStream = typeof(Conformance).GetTypeInfo().Assembly.GetManifestResourceStream("SampleBrowser.Samples.PDF.Assets.arial.ttf"); Stream imageStream = typeof(Conformance).GetTypeInfo().Assembly.GetManifestResourceStream("SampleBrowser.Samples.DocIO.Templates.AdventureCycle.jpg"); PdfFont font = new PdfTrueTypeFont(arialFontStream, 14); //Create PDF graphics for the page. PdfGraphics graphics = page.Graphics; //Load the image from the disk. PdfImage img = PdfImage.FromStream(imageStream); //Draw the image in the specified location and size. graphics.DrawImage(img, new RectangleF(150, 30, 200, 100)); PdfTextElement textElement = new PdfTextElement("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.") { Font = font }; PdfLayoutResult layoutResult = textElement.Draw(page, new RectangleF(0, 150, page.GetClientSize().Width, page.GetClientSize().Height)); MemoryStream stream = new MemoryStream(); //Save the PDF dcoument. document.Save(stream); //Close the PDF document. document.Close(); stream.Position = 0; if (stream != null) { SaveiOS iosSave = new SaveiOS(); iosSave.Save("PDF_Ab.pdf", "application/pdf", stream); } }
void OnButtonClicked(object sender, EventArgs e) { WordDocument document = new WordDocument(); IWParagraphStyle style = null; // Adding a new section to the document. WSection section = document.AddSection() as WSection; //Set Margin of the section section.PageSetup.Margins.All = 72; IWParagraph par = document.LastSection.AddParagraph(); WTextRange range = par.AppendText("Using CustomStyles") as WTextRange; range.CharacterFormat.TextBackgroundColor = Syncfusion.Drawing.Color.Red; range.CharacterFormat.TextColor = Syncfusion.Drawing.Color.White; range.CharacterFormat.FontSize = 18f; document.LastParagraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center; // Create Paragraph styles style = document.AddParagraphStyle("MyStyle_Normal"); style.CharacterFormat.FontName = "Bitstream Vera Serif"; style.CharacterFormat.FontSize = 10f; style.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Justify; style.CharacterFormat.TextColor = Syncfusion.Drawing.Color.FromArgb(0, 21, 84); style = document.AddParagraphStyle("MyStyle_Low"); style.CharacterFormat.FontName = "Times New Roman"; style.CharacterFormat.FontSize = 16f; style.CharacterFormat.Bold = true; style = document.AddParagraphStyle("MyStyle_Medium"); style.CharacterFormat.FontName = "Monotype Corsiva"; style.CharacterFormat.FontSize = 18f; style.CharacterFormat.Bold = true; style.CharacterFormat.TextColor = Syncfusion.Drawing.Color.FromArgb(51, 66, 125); style = document.AddParagraphStyle("Mystyle_High"); style.CharacterFormat.FontName = "Bitstream Vera Serif"; style.CharacterFormat.FontSize = 20f; style.CharacterFormat.Bold = true; style.CharacterFormat.TextColor = Syncfusion.Drawing.Color.FromArgb(242, 151, 50); IWParagraph paragraph = null; for (int i = 1; i < document.Styles.Count; i++) { //Skip to apply the document default styles and also paragraph style. if (document.Styles[i].Name == "Normal" || document.Styles[i].Name == "Default Paragraph Font" || document.Styles[i].StyleType != StyleType.ParagraphStyle) { continue; } // Getting styles from Document. style = (IWParagraphStyle)document.Styles[i]; // Adding a new paragraph section.AddParagraph(); paragraph = section.AddParagraph(); // Applying styles to the current paragraph. paragraph.ApplyStyle(style.Name); // Writing Text with the current style and formatting. paragraph.AppendText("Northwind Database with [" + style.Name + "] Style"); // Adding a new paragraph section.AddParagraph(); paragraph = section.AddParagraph(); // Applying another style to the current paragraph. paragraph.ApplyStyle("MyStyle_Normal"); // Writing text with current style. paragraph.AppendText("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. 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."); } #region Saving Document MemoryStream stream = new MemoryStream(); document.Save(stream, FormatType.Word2013); document.Close(); if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("CustomStyle.docx", "application/msword", stream); } #endregion }
void OnButtonClicked(object sender, EventArgs e) { ExcelEngine excelEngine = new ExcelEngine(); IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Excel2013; IWorkbook workbook = application.Workbooks.Create(1); IWorksheet worksheet = workbook.Worksheets[0]; IList <Brands> list = GetVehicleDetails(); int index = layoutList.IndexOf(selectedLayout); ExcelImportDataOptions importDataOptions = new ExcelImportDataOptions(); importDataOptions.FirstRow = 4; if (index == 0) { importDataOptions.NestedDataLayoutOptions = ExcelNestedDataLayoutOptions.Default; } else if (index == 1) { importDataOptions.NestedDataLayoutOptions = ExcelNestedDataLayoutOptions.Merge; } else if (index == 2) { importDataOptions.NestedDataLayoutOptions = ExcelNestedDataLayoutOptions.Repeat; } if (groupSwitch.Selected) { if (expandButton.IsChecked.Value) { importDataOptions.NestedDataGroupOptions = ExcelNestedDataGroupOptions.Expand; } else if (collapseButton.IsChecked.Value) { importDataOptions.NestedDataGroupOptions = ExcelNestedDataGroupOptions.Collapse; if (textField.Text != string.Empty) { importDataOptions.CollapseLevel = int.Parse(textField.Text); } } } worksheet.ImportData(list, importDataOptions); #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 = Color.FromArgb(0, 146, 208, 80); pageHeader.HorizontalAlignment = ExcelHAlign.HAlignCenter; pageHeader.VerticalAlignment = ExcelVAlign.VAlignCenter; tableHeader.Font.Bold = true; tableHeader.Font.FontName = "Calibri"; tableHeader.Color = Color.FromArgb(0, 146, 208, 80); #endregion #region Apply Styles // Apply style for header worksheet["A1:C2"].Merge(); worksheet["A1"].Text = "Automobile Brands in the US"; worksheet["A1"].CellStyle = pageHeader; worksheet["A4:C4"].CellStyle = tableHeader; worksheet["A1:C1"].CellStyle.Font.Bold = true; worksheet.UsedRange.AutofitColumns(); #endregion MemoryStream stream = new MemoryStream(); workbook.SaveAs(stream); workbook.Close(); excelEngine.Dispose(); if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("ImportData.xlsx", "application/msexcel", stream); } }
void OnButtonClicked(object sender, EventArgs e) { //Create an instance for PowerPoint IPresentation 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) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("ConnectorsPresentation.pptx", "application/mspowerpoint", stream); } }