diff --git a/Editing Excel cells/Set Cell Values/.NET/Set Cell Values/Set Cell Values.slnx b/Editing Excel cells/Set Cell Values/.NET/Set Cell Values/Set Cell Values.slnx new file mode 100644 index 00000000..78b4bf91 --- /dev/null +++ b/Editing Excel cells/Set Cell Values/.NET/Set Cell Values/Set Cell Values.slnx @@ -0,0 +1,3 @@ + + + diff --git a/Editing Excel cells/Set Cell Values/.NET/Set Cell Values/Set Cell Values/Data/Input.xlsx b/Editing Excel cells/Set Cell Values/.NET/Set Cell Values/Set Cell Values/Data/Input.xlsx new file mode 100644 index 00000000..99ca09b4 Binary files /dev/null and b/Editing Excel cells/Set Cell Values/.NET/Set Cell Values/Set Cell Values/Data/Input.xlsx differ diff --git a/Editing Excel cells/Set Cell Values/.NET/Set Cell Values/Set Cell Values/Output/.gitkeep b/Editing Excel cells/Set Cell Values/.NET/Set Cell Values/Set Cell Values/Output/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Editing Excel cells/Set Cell Values/.NET/Set Cell Values/Set Cell Values/Program.cs b/Editing Excel cells/Set Cell Values/.NET/Set Cell Values/Set Cell Values/Program.cs new file mode 100644 index 00000000..0157570a --- /dev/null +++ b/Editing Excel cells/Set Cell Values/.NET/Set Cell Values/Set Cell Values/Program.cs @@ -0,0 +1,67 @@ +using Syncfusion.XlsIO; + +namespace Set_Cell_Values +{ + class Program + { + static void Main() + { + using (ExcelEngine excelEngine = new ExcelEngine()) + { + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/Input.xlsx")); + IWorksheet sheet = workbook.Worksheets[0]; + + sheet.Range["D1"].Text = "In Stock"; + sheet.Range["E1"].Text = "Total Price"; + sheet.Range["F1"].Text = "Discount (10%)"; + sheet.Range["G1"].Text = "Final Price"; + + sheet.Range["D2"].Boolean = true; + sheet.Range["D3"].Boolean = true; + + sheet.Range["A4"].Text = "Bag"; + sheet.Range["B4"].Number = 500; + sheet.Range["C4"].Number = 5; + sheet.Range["D4"].Boolean = false; + + sheet.Range["A5"].Text = "Bottle"; + sheet.Range["B5"].Number = 100; + sheet.Range["C5"].Number = 10; + sheet.Range["D5"].Boolean = true; + + sheet.Range["E2"].Formula = "B2*C2"; + sheet.Range["F2"].Formula = "E2*0.1"; + sheet.Range["G2"].Formula = "E2-F2"; + + sheet.Range["E3"].Formula = "B3*C3"; + sheet.Range["F3"].Formula = "E3*0.1"; + sheet.Range["G3"].Formula = "E3-F3"; + + sheet.Range["E4"].Formula = "B4*C4"; + sheet.Range["F4"].Formula = "E4*0.1"; + sheet.Range["G4"].Formula = "E4-F4"; + + sheet.Range["E5"].Formula = "B5*C5"; + sheet.Range["F5"].Formula = "E5*0.1"; + sheet.Range["G5"].Formula = "E5-F5"; + + sheet.Range["A6"].Text = "Totals"; + sheet.Range["E6"].Formula = "SUM(E2:E5)"; + sheet.Range["F6"].Formula = "SUM(F2:F5)"; + sheet.Range["G6"].Formula = "SUM(G2:G5)"; + + sheet.Range["A1:G1"].CellStyle.Font.Bold = true; + sheet.Range["A1:G6"].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignCenter; + + IListObject table = sheet.ListObjects.Create("SalesTable", sheet.Range["A1:G6"]); + table.BuiltInTableStyle = TableBuiltInStyles.TableStyleMedium23; + + workbook.SaveAs(Path.GetFullPath(@"Output/Output.xlsx")); + workbook.Close(); + } + } + } +} diff --git a/Editing Excel cells/Set Cell Values/.NET/Set Cell Values/Set Cell Values/Set Cell Values.csproj b/Editing Excel cells/Set Cell Values/.NET/Set Cell Values/Set Cell Values/Set Cell Values.csproj new file mode 100644 index 00000000..915225a5 --- /dev/null +++ b/Editing Excel cells/Set Cell Values/.NET/Set Cell Values/Set Cell Values/Set Cell Values.csproj @@ -0,0 +1,24 @@ + + + + Exe + net10.0 + Set_Cell_Values + enable + enable + + + + + + + + + Always + + + Always + + + + diff --git a/Excel Shapes/Form Controls/.NET/Form Controls/Form Controls.slnx b/Excel Shapes/Form Controls/.NET/Form Controls/Form Controls.slnx new file mode 100644 index 00000000..34a95db7 --- /dev/null +++ b/Excel Shapes/Form Controls/.NET/Form Controls/Form Controls.slnx @@ -0,0 +1,3 @@ + + + diff --git a/Excel Shapes/Form Controls/.NET/Form Controls/Form Controls/Form Controls.csproj b/Excel Shapes/Form Controls/.NET/Form Controls/Form Controls/Form Controls.csproj new file mode 100644 index 00000000..89d47b69 --- /dev/null +++ b/Excel Shapes/Form Controls/.NET/Form Controls/Form Controls/Form Controls.csproj @@ -0,0 +1,21 @@ + + + + Exe + net10.0 + Form_Controls + enable + enable + + + + + + + + + Always + + + + diff --git a/Excel Shapes/Form Controls/.NET/Form Controls/Form Controls/Output/.gitkeep b/Excel Shapes/Form Controls/.NET/Form Controls/Form Controls/Output/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Excel Shapes/Form Controls/.NET/Form Controls/Form Controls/Program.cs b/Excel Shapes/Form Controls/.NET/Form Controls/Form Controls/Program.cs new file mode 100644 index 00000000..c25ddc2f --- /dev/null +++ b/Excel Shapes/Form Controls/.NET/Form Controls/Form Controls/Program.cs @@ -0,0 +1,175 @@ +using Syncfusion.XlsIO; +using Syncfusion.Drawing; +using System.IO; + +namespace Form_Controls +{ + class Program + { + static void Main() + { + using (ExcelEngine excelEngine = new ExcelEngine()) + { + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + + // Create workbook with 2 worksheets + IWorkbook workbook = application.Workbooks.Create(2); + IWorksheet sheet = workbook.Worksheets[0]; + IWorksheet sheet2 = workbook.Worksheets[1]; + + // Payment options for combo box + string[] onlinePayments = { "Credit Card", "Net Banking" }; + for (int i = 0; i < onlinePayments.Length; i++) + sheet2.SetValue(i + 1, 1, onlinePayments[i]); + + // CONTACT SALES section + sheet[2, 3].Text = "CONTACT SALES"; + sheet[2, 3].CellStyle.Font.Bold = true; + sheet[2, 3].CellStyle.Font.Size = 14; + sheet[2, 3].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignCenter; + + sheet[4, 3].Text = "Phone"; + sheet[4, 3].CellStyle.Font.Bold = true; + sheet[5, 3].Text = "Toll Free"; + sheet[5, 5].Text = "1-888-9DOTNET"; + sheet[6, 5].Text = "1-888-936-8638"; + sheet[7, 5].Text = "1-919-481-1974"; + + sheet[8, 3].Text = "Fax"; + sheet[8, 5].Text = "1-919-573-0306"; + + sheet[9, 3].Text = "Email"; + sheet[10, 3].Text = "Sales"; + + IHyperLink link = sheet.HyperLinks.Add(sheet[10, 5]); + link.Type = ExcelHyperLinkType.Url; + link.Address = "mailto:sales@syncfusion.com"; + sheet[10, 5].Text = "sales@syncfusion.com"; + sheet[10, 5].CellStyle.Font.Color = ExcelKnownColors.Blue; + sheet[10, 5].CellStyle.Font.Underline = ExcelUnderline.Single; + + sheet[12, 3].Text = "Please fill out all required fields."; + sheet[12, 3].CellStyle.Font.Italic = true; + sheet[12, 3].CellStyle.Font.Color = ExcelKnownColors.Grey_80_percent; + + // Form controls + sheet[14, 5].Text = "First Name*"; sheet[14, 5].CellStyle.Font.Bold = true; + sheet[14, 8].Text = "Last Name*"; sheet[14, 8].CellStyle.Font.Bold = true; + + ITextBoxShape textBoxShape = sheet.TextBoxes.AddTextBox(15, 5, 23, 190); + textBoxShape.Fill.FillType = ExcelFillType.SolidColor; + textBoxShape.Fill.ForeColor = Color.LightYellow; + + textBoxShape = sheet.TextBoxes.AddTextBox(15, 8, 23, 195); + textBoxShape.Fill.FillType = ExcelFillType.SolidColor; + textBoxShape.Fill.ForeColor = Color.LightYellow; + + sheet[17, 3].Text = "Company*"; + textBoxShape = sheet.TextBoxes.AddTextBox(17, 5, 23, 385); + textBoxShape.Fill.FillType = ExcelFillType.SolidColor; + textBoxShape.Fill.ForeColor = Color.LightYellow; + + sheet[19, 3].Text = "Phone*"; + textBoxShape = sheet.TextBoxes.AddTextBox(19, 5, 23, 385); + textBoxShape.Fill.FillType = ExcelFillType.SolidColor; + textBoxShape.Fill.ForeColor = Color.LightYellow; + + sheet[21, 3].Text = "Email*"; + textBoxShape = sheet.TextBoxes.AddTextBox(21, 5, 23, 385); + textBoxShape.Fill.FillType = ExcelFillType.SolidColor; + textBoxShape.Fill.ForeColor = Color.LightYellow; + + sheet[23, 3].Text = "Website"; + textBoxShape = sheet.TextBoxes.AddTextBox(23, 5, 23, 385); + textBoxShape.Fill.FillType = ExcelFillType.SolidColor; + textBoxShape.Fill.ForeColor = Color.LightYellow; + + // Multiple products + sheet[25, 3].Text = "Multiple products?"; + ICheckBoxShape chkBoxProducts = sheet.CheckBoxes.AddCheckBox(25, 5, 20, 75); + chkBoxProducts.CheckState = ExcelCheckState.Mixed; + + // Product(s) section + sheet[27, 3, 28, 3].Merge(); + sheet[27, 3].Text = "Product(s)*"; + sheet[27, 3].MergeArea.CellStyle.VerticalAlignment = ExcelVAlign.VAlignCenter; + + ICheckBoxShape chkBoxProduct; + chkBoxProduct = sheet.CheckBoxes.AddCheckBox(27, 5, 20, 75); chkBoxProduct.Text = "Studio"; + chkBoxProduct = sheet.CheckBoxes.AddCheckBox(27, 6, 20, 75); chkBoxProduct.Text = "Calculate"; + chkBoxProduct = sheet.CheckBoxes.AddCheckBox(27, 7, 20, 75); chkBoxProduct.Text = "Chart"; + chkBoxProduct = sheet.CheckBoxes.AddCheckBox(27, 8, 20, 75); chkBoxProduct.Text = "Diagram"; + chkBoxProduct = sheet.CheckBoxes.AddCheckBox(27, 9, 20, 75); chkBoxProduct.Text = "Edit"; + chkBoxProduct = sheet.CheckBoxes.AddCheckBox(27, 10, 20, 75); chkBoxProduct.Text = "XlsIO"; + chkBoxProduct = sheet.CheckBoxes.AddCheckBox(28, 5, 20, 75); chkBoxProduct.Text = "Grid"; + chkBoxProduct = sheet.CheckBoxes.AddCheckBox(28, 6, 20, 75); chkBoxProduct.Text = "Grouping"; + chkBoxProduct = sheet.CheckBoxes.AddCheckBox(28, 7, 20, 75); chkBoxProduct.Text = "HTMLUI"; + chkBoxProduct = sheet.CheckBoxes.AddCheckBox(28, 8, 20, 75); chkBoxProduct.Text = "PDF"; + chkBoxProduct = sheet.CheckBoxes.AddCheckBox(28, 9, 20, 75); chkBoxProduct.Text = "Tools"; + chkBoxProduct = sheet.CheckBoxes.AddCheckBox(28, 10, 20, 75); chkBoxProduct.Text = "DocIO"; + + // Link checkboxes to hidden cells and formulas + GenerateFormula(excelEngine); + + // Selected products count + sheet[30, 3].Text = "Selected Products Count"; + sheet[30, 5].Formula = "SUM(AA2:AA13)"; + sheet[30, 5].CellStyle.HorizontalAlignment = ExcelHAlign.HAlignLeft; + + // Additional Information + sheet[35, 3].Text = "Additional Information"; + sheet.TextBoxes.AddTextBox(32, 5, 150, 385); + + // Combo box + sheet[43, 3].Text = "Online Payment"; + IComboBoxShape comboBox1 = sheet.ComboBoxes.AddComboBox(43, 5, 20, 100); + comboBox1.ListFillRange = sheet2["A1:A2"]; + comboBox1.SelectedIndex = 1; + + // Option buttons + sheet[46, 3].Text = "Card Type"; + IOptionButtonShape optionButton1 = sheet.OptionButtons.AddOptionButton(46, 5); + optionButton1.Text = "American Express"; + optionButton1.CheckState = ExcelCheckState.Checked; + + optionButton1 = sheet.OptionButtons.AddOptionButton(46, 7); + optionButton1.Text = "Master Card"; + + optionButton1 = sheet.OptionButtons.AddOptionButton(46, 9); + optionButton1.Text = "Visa"; + + // Styling + sheet.Columns[0].AutofitColumns(); + sheet.Columns[3].ColumnWidth = 12; + sheet.Columns[4].ColumnWidth = 10; + sheet.Columns[5].ColumnWidth = 10; + sheet.IsGridLinesVisible = false; + + // Delete unused rows + sheet.DeleteRow(40); + sheet.DeleteRow(41); + sheet.DeleteRow(42); + sheet.DeleteRow(45); + + // Save workbook + workbook.SaveAs(Path.GetFullPath("Output/FormControls.xlsx")); + } + } + + private static void GenerateFormula(ExcelEngine excelEngine) + { + IWorksheet worksheet = excelEngine.Excel.Workbooks[0].Worksheets[0]; + ICheckBoxes checkBoxes = worksheet.CheckBoxes; + string formula; + + for (int i = 1; i < checkBoxes.Count; i++) + { + IRange range = worksheet["Z" + (i + 1)]; + checkBoxes[i].LinkedCell = range; + formula = "IF(" + range.AddressLocal + ",1,0)"; + worksheet["AA" + (i + 1)].Formula = formula; + } + } + } +} \ No newline at end of file diff --git a/Excel to PDF/Excel to Tagged PDF/.NET/Excel to Tagged PDF/Excel to Tagged PDF.slnx b/Excel to PDF/Excel to Tagged PDF/.NET/Excel to Tagged PDF/Excel to Tagged PDF.slnx new file mode 100644 index 00000000..83bf5432 --- /dev/null +++ b/Excel to PDF/Excel to Tagged PDF/.NET/Excel to Tagged PDF/Excel to Tagged PDF.slnx @@ -0,0 +1,3 @@ + + + diff --git a/Excel to PDF/Excel to Tagged PDF/.NET/Excel to Tagged PDF/Excel to Tagged PDF/Data/InputTemplate.xlsx b/Excel to PDF/Excel to Tagged PDF/.NET/Excel to Tagged PDF/Excel to Tagged PDF/Data/InputTemplate.xlsx new file mode 100644 index 00000000..bd99748f Binary files /dev/null and b/Excel to PDF/Excel to Tagged PDF/.NET/Excel to Tagged PDF/Excel to Tagged PDF/Data/InputTemplate.xlsx differ diff --git a/Excel to PDF/Excel to Tagged PDF/.NET/Excel to Tagged PDF/Excel to Tagged PDF/Excel to Tagged PDF.csproj b/Excel to PDF/Excel to Tagged PDF/.NET/Excel to Tagged PDF/Excel to Tagged PDF/Excel to Tagged PDF.csproj new file mode 100644 index 00000000..21773436 --- /dev/null +++ b/Excel to PDF/Excel to Tagged PDF/.NET/Excel to Tagged PDF/Excel to Tagged PDF/Excel to Tagged PDF.csproj @@ -0,0 +1,24 @@ + + + + Exe + net10.0 + Excel_to_Tagged_PDF + enable + enable + + + + + + + + + Always + + + Always + + + + diff --git a/Excel to PDF/Excel to Tagged PDF/.NET/Excel to Tagged PDF/Excel to Tagged PDF/Output/.gitkeep b/Excel to PDF/Excel to Tagged PDF/.NET/Excel to Tagged PDF/Excel to Tagged PDF/Output/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Excel to PDF/Excel to Tagged PDF/.NET/Excel to Tagged PDF/Excel to Tagged PDF/Program.cs b/Excel to PDF/Excel to Tagged PDF/.NET/Excel to Tagged PDF/Excel to Tagged PDF/Program.cs new file mode 100644 index 00000000..cbba54b6 --- /dev/null +++ b/Excel to PDF/Excel to Tagged PDF/.NET/Excel to Tagged PDF/Excel to Tagged PDF/Program.cs @@ -0,0 +1,34 @@ +using Syncfusion.Pdf; +using Syncfusion.XlsIO; +using Syncfusion.XlsIORenderer; + +namespace Excel_to_Tagged_PDF +{ + class Program + { + static void Main() + { + using (ExcelEngine excelEngine = new ExcelEngine()) + { + IApplication application = excelEngine.Excel; + application.DefaultVersion = ExcelVersion.Xlsx; + IWorkbook workbook = application.Workbooks.Open(Path.GetFullPath(@"Data/InputTemplate.xlsx")); + + //Initialize XlsIORendererSettings + XlsIORendererSettings settings = new XlsIORendererSettings(); + + //Set AutoTag to true to create a tagged PDF + settings.AutoTag = true; + + //Initialize XlsIORenderer + XlsIORenderer renderer = new XlsIORenderer(); + + //Convert the Excel document to PDF with renderer settings + PdfDocument pdfDocument = renderer.ConvertToPDF(workbook, settings); + + //Save the PDF document + pdfDocument.Save(Path.GetFullPath(@"Output/Output.pdf")); + } + } + } +} \ No newline at end of file