Skip to content

Commit 08796a1

Browse files
committed
924528-Add-Readme-Files
1 parent 1795d11 commit 08796a1

File tree

14 files changed

+824
-21
lines changed
  • CSV to Excel/CSV to Excel/.NET/CSV to Excel
  • Convert Excel to JSON/Workbook to JSON with Schema/.NET/Workbook to JSON with Schema
  • Create and Edit Charts/Create Chart/.NET/Create Chart
  • Create and Edit Table/Create Table/.NET/Create Table
  • Data Validation/List Validation/.NET/List Validation
  • Excel to CSV/Excel to CSV/.NET/Excel to CSV
  • Excel to PDF/Workbook to PDF/.NET/Workbook to PDF
  • Getting Started/Console/.NET/Create Excel
  • Import Data to Template/Import Data Table/.NET/Import Data Table
  • Import and Export Data/DataTable to Worksheet/.NET/DataTable to Worksheet
  • Pivot Table/Create Pivot Table/.NET/Create Pivot Table
  • Threaded Comments/Add Comment/.NET/Add Comment
  • Worksheet to Image/Worksheet to Image/.NET/Worksheet to Image
  • XlsIO-Excel-Protect-UnProtect/Protect-Workbook/.NET/Protect-Workbook

14 files changed

+824
-21
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# How to convert a CSV to an Excel file??
2+
3+
Step 1: Create a new C# Console Application project.
4+
5+
Step 2: Name the project.
6+
7+
Step 3: Install the [Syncfusion.XlsIO.Net.Core](https://www.nuget.org/packages/Syncfusion.XlsIO.Net.Core) NuGet package as reference to your .NET Standard applications from [NuGet.org](https://www.nuget.org).
8+
9+
Step 4: Include the following namespaces in the **Program.cs** file.
10+
{% tabs %}
11+
{% highlight c# tabtitle="C#" %}
12+
using Syncfusion.XlsIO;
13+
{% endhighlight %}
14+
{% endtabs %}
15+
16+
Step 5: Include the below code snippet in **Program.cs** to convert a CSV to an Excel fil.
17+
{% tabs %}
18+
{% highlight c# tabtitle="C#" %}
19+
using (ExcelEngine excelEngine = new ExcelEngine())
20+
{
21+
IApplication application = excelEngine.Excel;
22+
application.DefaultVersion = ExcelVersion.Xlsx;
23+
FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.csv"), FileMode.Open, FileAccess.Read);
24+
25+
//Open the CSV file
26+
IWorkbook workbook = application.Workbooks.Open(inputStream, ",");
27+
IWorksheet worksheet = workbook.Worksheets[0];
28+
29+
//Saving the workbook as stream
30+
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Output.xlsx"), FileMode.Create, FileAccess.Write);
31+
workbook.SaveAs(outputStream);
32+
33+
//Dispose streams
34+
outputStream.Dispose();
35+
inputStream.Dispose();
36+
}
37+
{% endhighlight %}
38+
{% endtabs %}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# How to convert an Excel workbook to a JSON file with schema?
2+
3+
Step 1: Create a new C# Console Application project.
4+
5+
Step 2: Name the project.
6+
7+
Step 3: Install the [Syncfusion.XlsIO.Net.Core](https://www.nuget.org/packages/Syncfusion.XlsIO.Net.Core) NuGet package as reference to your .NET Standard applications from [NuGet.org](https://www.nuget.org).
8+
9+
Step 4: Include the following namespaces in the **Program.cs** file.
10+
{% tabs %}
11+
{% highlight c# tabtitle="C#" %}
12+
using System;
13+
using System.IO;
14+
using Syncfusion.XlsIO;
15+
{% endhighlight %}
16+
{% endtabs %}
17+
18+
Step 5: Include the below code snippet in **Program.cs** to convert an Excel workbook to a JSON file with schema.
19+
{% tabs %}
20+
{% highlight c# tabtitle="C#" %}
21+
using (ExcelEngine excelEngine = new ExcelEngine())
22+
{
23+
IApplication application = excelEngine.Excel;
24+
application.DefaultVersion = ExcelVersion.Xlsx;
25+
FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read);
26+
IWorkbook workbook = application.Workbooks.Open(inputStream);
27+
IWorksheet worksheet = workbook.Worksheets[0];
28+
29+
#region save as JSON
30+
//Saves the workbook to a JSON filestream, as schema by default
31+
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Excel-Workbook-To-JSON-as-schema-default.json"), FileMode.Create, FileAccess.ReadWrite);
32+
workbook.SaveAsJson(outputStream);
33+
34+
//Saves the workbook to a JSON filestream as schema
35+
FileStream stream1 = new FileStream(Path.GetFullPath("Output/Excel-Workbook-To-JSON-as-schema.json"), FileMode.Create, FileAccess.ReadWrite);
36+
workbook.SaveAsJson(stream1, true);
37+
#endregion
38+
39+
//Dispose streams
40+
outputStream.Dispose();
41+
stream1.Dispose();
42+
inputStream.Dispose();
43+
44+
#region Open JSON
45+
//Open default JSON
46+
47+
//Open JSON with Schema
48+
#endregion
49+
}
50+
{% endhighlight %}
51+
{% endtabs %}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# How to create a chart in the worksheet?
2+
3+
Step 1: Create a new C# Console Application project.
4+
5+
Step 2: Name the project.
6+
7+
Step 3: Install the [Syncfusion.XlsIO.Net.Core](https://www.nuget.org/packages/Syncfusion.XlsIO.Net.Core) NuGet package as reference to your .NET Standard applications from [NuGet.org](https://www.nuget.org).
8+
9+
Step 4: Include the following namespaces in the **Program.cs** file.
10+
{% tabs %}
11+
{% highlight c# tabtitle="C#" %}
12+
using System.IO;
13+
using Syncfusion.XlsIO;
14+
{% endhighlight %}
15+
{% endtabs %}
16+
17+
Step 5: Include the below code snippet in **Program.cs** to create a chart in the worksheet.
18+
{% tabs %}
19+
{% highlight c# tabtitle="C#" %}
20+
using (ExcelEngine excelEngine = new ExcelEngine())
21+
{
22+
IApplication application = excelEngine.Excel;
23+
application.DefaultVersion = ExcelVersion.Xlsx;
24+
FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read);
25+
IWorkbook workbook = application.Workbooks.Open(inputStream, ExcelOpenType.Automatic);
26+
IWorksheet sheet = workbook.Worksheets[0];
27+
28+
//Create a Chart
29+
IChartShape chart = sheet.Charts.Add();
30+
31+
//Set Chart Type
32+
chart.ChartType = ExcelChartType.Column_Clustered;
33+
34+
//Set data range in the worksheet
35+
chart.DataRange = sheet.Range["A1:C6"];
36+
chart.IsSeriesInRows = false;
37+
38+
//Set Datalabels
39+
IChartSerie serie1 = chart.Series[0];
40+
IChartSerie serie2 = chart.Series[1];
41+
42+
serie1.DataPoints.DefaultDataPoint.DataLabels.IsValue = true;
43+
serie2.DataPoints.DefaultDataPoint.DataLabels.IsValue = true;
44+
serie1.DataPoints.DefaultDataPoint.DataLabels.Position = ExcelDataLabelPosition.Outside;
45+
serie2.DataPoints.DefaultDataPoint.DataLabels.Position = ExcelDataLabelPosition.Outside;
46+
47+
//Set Legend
48+
chart.HasLegend = true;
49+
chart.Legend.Position = ExcelLegendPosition.Bottom;
50+
51+
//Positioning the chart in the worksheet
52+
chart.TopRow = 8;
53+
chart.LeftColumn = 1;
54+
chart.BottomRow = 23;
55+
chart.RightColumn = 8;
56+
57+
#region Save
58+
//Saving the workbook
59+
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Chart.xlsx"), FileMode.Create, FileAccess.Write);
60+
workbook.SaveAs(outputStream);
61+
#endregion
62+
63+
//Dispose streams
64+
outputStream.Dispose();
65+
inputStream.Dispose();
66+
}
67+
{% endhighlight %}
68+
{% endtabs %}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# How to create a table in the worksheet?
2+
3+
Step 1: Create a new C# Console Application project.
4+
5+
Step 2: Name the project.
6+
7+
Step 3: Install the [Syncfusion.XlsIO.Net.Core](https://www.nuget.org/packages/Syncfusion.XlsIO.Net.Core) NuGet package as reference to your .NET Standard applications from [NuGet.org](https://www.nuget.org).
8+
9+
Step 4: Include the following namespaces in the **Program.cs** file.
10+
{% tabs %}
11+
{% highlight c# tabtitle="C#" %}
12+
using System;
13+
using System.IO;
14+
using Syncfusion.XlsIO;
15+
{% endhighlight %}
16+
{% endtabs %}
17+
18+
Step 5: Include the below code snippet in **Program.cs** to create a table in the worksheet.
19+
{% tabs %}
20+
{% highlight c# tabtitle="C#" %}
21+
using (ExcelEngine excelEngine = new ExcelEngine())
22+
{
23+
IApplication application = excelEngine.Excel;
24+
application.DefaultVersion = ExcelVersion.Xlsx;
25+
FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read);
26+
IWorkbook workbook = application.Workbooks.Open(inputStream);
27+
IWorksheet worksheet = workbook.Worksheets[0];
28+
29+
//Create for the given data
30+
IListObject table = worksheet.ListObjects.Create("Table1", worksheet["A1:C5"]);
31+
32+
#region Save
33+
//Saving the workbook
34+
FileStream outputStream = new FileStream(Path.GetFullPath("Output/CreateTable.xlsx"), FileMode.Create, FileAccess.Write);
35+
workbook.SaveAs(outputStream);
36+
#endregion
37+
38+
//Dispose streams
39+
inputStream.Dispose();
40+
outputStream.Dispose();
41+
}
42+
{% endhighlight %}
43+
{% endtabs %}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# How to set list data validation in Excel?
2+
3+
Step 1: Create a new C# Console Application project.
4+
5+
Step 2: Name the project.
6+
7+
Step 3: Install the [Syncfusion.XlsIO.Net.Core](https://www.nuget.org/packages/Syncfusion.XlsIO.Net.Core) NuGet package as reference to your .NET Standard applications from [NuGet.org](https://www.nuget.org).
8+
9+
Step 4: Include the following namespaces in the **Program.cs** file.
10+
{% tabs %}
11+
{% highlight c# tabtitle="C#" %}
12+
using System.IO;
13+
using Syncfusion.XlsIO;
14+
{% endhighlight %}
15+
{% endtabs %}
16+
17+
Step 5: Include the below code snippet in **Program.cs** to set list data validation in Excel.
18+
{% tabs %}
19+
{% highlight c# tabtitle="C#" %}
20+
using (ExcelEngine excelEngine = new ExcelEngine())
21+
{
22+
IApplication application = excelEngine.Excel;
23+
application.DefaultVersion = ExcelVersion.Xlsx;
24+
IWorkbook workbook = application.Workbooks.Create(1);
25+
IWorksheet worksheet = workbook.Worksheets[0];
26+
27+
//Data Validation for List
28+
IDataValidation listValidation = worksheet.Range["C3"].DataValidation;
29+
worksheet.Range["C1"].Text = "Data Validation List in C3";
30+
worksheet.Range["C1"].AutofitColumns();
31+
listValidation.ListOfValues = new string[] { "ListItem1", "ListItem2", "ListItem3" };
32+
33+
//Shows the error message
34+
listValidation.ErrorBoxText = "Choose the value from the list";
35+
listValidation.ErrorBoxTitle = "ERROR";
36+
listValidation.PromptBoxText = "Data validation for list";
37+
listValidation.IsPromptBoxVisible = true;
38+
listValidation.ShowPromptBox = true;
39+
40+
#region Save
41+
//Saving the workbook
42+
FileStream outputStream = new FileStream(Path.GetFullPath("Output/ListValidation.xlsx"), FileMode.Create, FileAccess.Write);
43+
workbook.SaveAs(outputStream);
44+
#endregion
45+
46+
//Dispose streams
47+
outputStream.Dispose();
48+
}
49+
{% endhighlight %}
50+
{% endtabs %}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# How to convert an Excel file to CSV?
2+
3+
Step 1: Create a new C# Console Application project.
4+
5+
Step 2: Name the project.
6+
7+
Step 3: Install the [Syncfusion.XlsIO.Net.Core](https://www.nuget.org/packages/Syncfusion.XlsIO.Net.Core) NuGet package as reference to your .NET Standard applications from [NuGet.org](https://www.nuget.org).
8+
9+
Step 4: Include the following namespaces in the **Program.cs** file.
10+
{% tabs %}
11+
{% highlight c# tabtitle="C#" %}
12+
using Syncfusion.XlsIO;
13+
{% endhighlight %}
14+
{% endtabs %}
15+
16+
Step 5: Include the below code snippet in **Program.cs** to convert an Excel file to CSV.
17+
{% tabs %}
18+
{% highlight c# tabtitle="C#" %}
19+
using (ExcelEngine excelEngine = new ExcelEngine())
20+
{
21+
IApplication application = excelEngine.Excel;
22+
application.DefaultVersion = ExcelVersion.Xlsx;
23+
FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read);
24+
IWorkbook workbook = application.Workbooks.Open(inputStream);
25+
26+
//Saving the workbook as streams
27+
FileStream outputStream = new FileStream(Path.GetFullPath("Output/Sample.csv"), FileMode.Create, FileAccess.ReadWrite);
28+
workbook.SaveAs(outputStream, ",");
29+
30+
//Dispose streams
31+
outputStream.Dispose();
32+
inputStream.Dispose();
33+
}
34+
{% endhighlight %}
35+
{% endtabs %}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# How to convert an Excel workbook to PDF?
2+
3+
Step 1: Create a new C# Console Application project.
4+
5+
Step 2: Name the project.
6+
7+
Step 3: Install the [Syncfusion.XlsIO.Net.Core](https://www.nuget.org/packages/Syncfusion.XlsIO.Net.Core) NuGet package as reference to your .NET Standard applications from [NuGet.org](https://www.nuget.org).
8+
9+
Step 4: Include the following namespaces in the **Program.cs** file.
10+
{% tabs %}
11+
{% highlight c# tabtitle="C#" %}
12+
using System.IO;
13+
using Syncfusion.XlsIO;
14+
using Syncfusion.XlsIORenderer;
15+
using Syncfusion.Pdf;
16+
{% endhighlight %}
17+
{% endtabs %}
18+
19+
Step 5: Include the below code snippet in **Program.cs** to convert an Excel workbook to PDF.
20+
{% tabs %}
21+
{% highlight c# tabtitle="C#" %}
22+
using (ExcelEngine excelEngine = new ExcelEngine())
23+
{
24+
IApplication application = excelEngine.Excel;
25+
application.DefaultVersion = ExcelVersion.Xlsx;
26+
FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/InputTemplate.xlsx"), FileMode.Open, FileAccess.Read);
27+
IWorkbook workbook = application.Workbooks.Open(inputStream);
28+
29+
//Initialize XlsIO renderer.
30+
XlsIORenderer renderer = new XlsIORenderer();
31+
32+
//Convert Excel document into PDF document
33+
PdfDocument pdfDocument = renderer.ConvertToPDF(workbook);
34+
35+
#region Save
36+
//Saving the workbook
37+
FileStream outputStream = new FileStream(Path.GetFullPath("Output/WorkbookToPDF.pdf"), FileMode.Create, FileAccess.Write);
38+
pdfDocument.Save(outputStream);
39+
#endregion
40+
41+
//Dispose streams
42+
outputStream.Dispose();
43+
inputStream.Dispose();
44+
}
45+
{% endhighlight %}
46+
{% endtabs %}

0 commit comments

Comments
 (0)