Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Solution>
<Project Path="Set Cell Values/Set Cell Values.csproj" />
</Solution>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>Set_Cell_Values</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.XlsIO.Net.Core" Version="*" />
</ItemGroup>

<ItemGroup>
<None Update="Data\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Output\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Solution>
<Project Path="Form Controls/Form Controls.csproj" />
</Solution>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>Form_Controls</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.XlsIO.Net.Core" Version="*" />
</ItemGroup>

<ItemGroup>
<None Update="Output\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
175 changes: 175 additions & 0 deletions Excel Shapes/Form Controls/.NET/Form Controls/Form Controls/Program.cs
Original file line number Diff line number Diff line change
@@ -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:[email protected]";
sheet[10, 5].Text = "[email protected]";
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;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Solution>
<Project Path="Excel to Tagged PDF/Excel to Tagged PDF.csproj" />
</Solution>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>Excel_to_Tagged_PDF</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.XlsIORenderer.Net.Core" Version="*" />
</ItemGroup>

<ItemGroup>
<None Update="Data\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Output\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -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"));
}
}
}
}
Loading