.NET (1322)
Children categories
The sample demonstrates how to convert Excel workbook to PDF file via Spire.XLS.

Excel radar charts, also known as spider charts or web charts, are used to compare multiple data series in different categories. By plotting data points on a multi-axis chart, radar charts provide a clear and intuitive representation of data balance and skewness. This makes them particularly useful for visualizing performance metrics, market analysis, and other situations where multiple dimensions need to be compared. In this article, you will learn how to create a radar chart in Excel in C# using Spire.XLS for .NET.
Install Spire.XLS for .NET
To begin with, you need to add the DLL files included in the Spire.XLS for .NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.
PM> Install-Package Spire.XLS
Create a Simple Radar Chart in Excel in C#
Spire.XLS for .NET provides the Worksheet.Charts.Add(ExcelChartType.Radar) method to add a standard radar chart to an Excel worksheet. The following are the detailed steps:
- Create a Workbook instance.
- Get a specified worksheet using Workbook.Worksheets[sheetIndex] property.
- Add the chart data to specified cells and set the cell styles.
- Add a simple radar chart to the worksheet using Worksheet.Charts.Add(ExcelChartType.Radar) method.
- Set data range for the chart using Chart.DataRange property.
- Set the position, legend and title of the chart.
- Save the result file using Workbook.SaveToFile() method.
- C#
using Spire.Xls;
using System.Drawing;
namespace ExcelRadarChart
{
class Program
{
static void Main(string[] args)
{
//Create a Workbook instance
Workbook workbook = new Workbook();
//Get the first worksheet
Worksheet sheet = workbook.Worksheets[0];
//Add chart data to specified cells
sheet.Range["A1"].Value = "Rating";
sheet.Range["A2"].Value = "Communication";
sheet.Range["A3"].Value = "Experience";
sheet.Range["A4"].Value = "Work Efficiency";
sheet.Range["A5"].Value = "Leadership";
sheet.Range["A6"].Value = "Problem-solving";
sheet.Range["A7"].Value = "Teamwork";
sheet.Range["B1"].Value = "Jonathan";
sheet.Range["B2"].NumberValue = 4;
sheet.Range["B3"].NumberValue = 3;
sheet.Range["B4"].NumberValue = 4;
sheet.Range["B5"].NumberValue = 3;
sheet.Range["B6"].NumberValue = 5;
sheet.Range["B7"].NumberValue = 5;
sheet.Range["C1"].Value = "Ryan";
sheet.Range["C2"].NumberValue = 2;
sheet.Range["C3"].NumberValue = 5;
sheet.Range["C4"].NumberValue = 4;
sheet.Range["C5"].NumberValue = 4;
sheet.Range["C6"].NumberValue = 3;
sheet.Range["C7"].NumberValue = 3;
//Set font styles
sheet.Range["A1:C1"].Style.Font.IsBold = true;
sheet.Range["A1:C1"].Style.Font.Size = 11;
sheet.Range["A1:C1"].Style.Font.Color = Color.White;
//Set row height and column width
sheet.Rows[0].RowHeight = 20;
sheet.Range["A1:C7"].Columns[0].ColumnWidth = 15;
//Set cell styles
sheet.Range["A1:C1"].Style.Color = Color.DarkBlue;
sheet.Range["A2:C7"].Borders[BordersLineType.EdgeBottom].LineStyle = LineStyleType.Thin;
sheet.Range["A2:C7"].Style.Borders[BordersLineType.EdgeBottom].Color = Color.DarkBlue;
sheet.Range["B1:C7"].HorizontalAlignment = HorizontalAlignType.Center;
sheet.Range["A1:C7"].VerticalAlignment = VerticalAlignType.Center;
//Add a radar chart to the worksheet
Chart chart = sheet.Charts.Add(ExcelChartType.Radar);
//Set position of chart
chart.LeftColumn = 4;
chart.TopRow = 4;
chart.RightColumn = 14;
chart.BottomRow = 29;
//Set data range for the chart
chart.DataRange = sheet.Range["A1:C7"];
chart.SeriesDataFromRange = false;
//Set and format chart title
chart.ChartTitle = "Employee Performance Appraisal";
chart.ChartTitleArea.IsBold = true;
chart.ChartTitleArea.Size = 14;
//Set position of chart legend
chart.Legend.Position = LegendPositionType.Corner;
//Save the result file
workbook.SaveToFile("ExcelRadarChart.xlsx", ExcelVersion.Version2016);
}
}
}

Create a Filled Radar Chart in Excel in C#
A filled radar chart is a variation of a standard radar chart, with the difference that the area between each data point is filled with color. The following are the steps to create a filled radar chart using C#:
- Create a Workbook instance.
- Get a specified worksheet using Workbook.Worksheets[sheetIndex] property.
- Add the chart data to specified cells and set the cell styles.
- Add a filled radar chart to the worksheet using Worksheet.Charts.Add(ExcelChartType.RadarFilled) method.
- Set data range for the chart using Chart.DataRange property.
- Set the position, legend and title of the chart.
- Save the result file using Workbook.SaveToFile() method.
- C#
using Spire.Xls;
using System.Drawing;
namespace ExcelRadarChart
{
class Program
{
static void Main(string[] args)
{
//Create a Workbook instance
Workbook workbook = new Workbook();
//Get the first worksheet
Worksheet sheet = workbook.Worksheets[0];
//Add chart data to specified cells
sheet.Range["A1"].Value = "Rating";
sheet.Range["A2"].Value = "Communication";
sheet.Range["A3"].Value = "Experience";
sheet.Range["A4"].Value = "Work Efficiency";
sheet.Range["A5"].Value = "Leadership";
sheet.Range["A6"].Value = "Problem-solving";
sheet.Range["A7"].Value = "Teamwork";
sheet.Range["B1"].Value = "Jonathan";
sheet.Range["B2"].NumberValue = 4;
sheet.Range["B3"].NumberValue = 3;
sheet.Range["B4"].NumberValue = 4;
sheet.Range["B5"].NumberValue = 3;
sheet.Range["B6"].NumberValue = 5;
sheet.Range["B7"].NumberValue = 5;
sheet.Range["C1"].Value = "Ryan";
sheet.Range["C2"].NumberValue = 2;
sheet.Range["C3"].NumberValue = 5;
sheet.Range["C4"].NumberValue = 4;
sheet.Range["C5"].NumberValue = 4;
sheet.Range["C6"].NumberValue = 3;
sheet.Range["C7"].NumberValue = 3;
//Set font styles
sheet.Range["A1:C1"].Style.Font.IsBold = true;
sheet.Range["A1:C1"].Style.Font.Size = 11;
sheet.Range["A1:C1"].Style.Font.Color = Color.White;
//Set row height and column width
sheet.Rows[0].RowHeight = 20;
sheet.Range["A1:C7"].Columns[0].ColumnWidth = 15;
//Set cell styles
sheet.Range["A1:C1"].Style.Color = Color.DarkBlue;
sheet.Range["A2:C7"].Borders[BordersLineType.EdgeBottom].LineStyle = LineStyleType.Thin;
sheet.Range["A2:C7"].Style.Borders[BordersLineType.EdgeBottom].Color = Color.DarkBlue;
sheet.Range["B1:C7"].HorizontalAlignment = HorizontalAlignType.Center;
sheet.Range["A1:C7"].VerticalAlignment = VerticalAlignType.Center;
//Add a filled radar chart to the worksheet
Chart chart = sheet.Charts.Add(ExcelChartType.RadarFilled);
//Set position of chart
chart.LeftColumn = 4;
chart.TopRow = 4;
chart.RightColumn = 14;
chart.BottomRow = 29;
//Set data range for the chart
chart.DataRange = sheet.Range["A1:C7"];
chart.SeriesDataFromRange = false;
//Set and format chart title
chart.ChartTitle = "Employee Performance Appraisal";
chart.ChartTitleArea.IsBold = true;
chart.ChartTitleArea.Size = 14;
//Set position of chart legend
chart.Legend.Position = LegendPositionType.Corner;
//Save the result file
workbook.SaveToFile("FilledRadarChart.xlsx", ExcelVersion.Version2016);
}
}
}

Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.
A line chart, also known as a line graph, is a type of chart that displays information as a series of data points connected by straight line segments. It is generally used to show the changes of information over a period of time, such as years, months or days. In this article, you will learn how to create a line chart in Excel in C# and VB.NET using Spire.XLS for .NET.
Install Spire.XLS for .NET
To begin with, you need to add the DLL files included in the Spire.XLS for .NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.
PM> Install-Package Spire.XLS
Create a Line Chart in Excel using C# and VB.NET
The following are the main steps to create a line chart:
- Create an instance of Workbook class.
- Get the first worksheet by its index (zero-based) though Workbook.Worksheets[sheetIndex] property.
- Add some data to the worksheet.
- Add a line chart to the worksheet using Worksheet.Charts.Add(ExcelChartType.Line) method.
- Set data range for the chart through Chart.DataRange property.
- Set position, title, category axis title and value axis title for the chart.
- Loop through the data series of the chart, show data labels for the data points of each data series by setting the ChartSerie.DataPoints.DefaultDataPoint.DataLabels.HasValue property as true.
- Set the position of chart legend through Chart.Legend.Position property.
- Save the result file using Workbook.SaveToFile() method.
- C#
- VB.NET
using Spire.Xls;
using Spire.Xls.Charts;
using System.Drawing;
namespace CreateLineChart
{
class Program
{
static void Main(string[] args)
{
//Create a Workbook instance
Workbook workbook = new Workbook();
//Get the first worksheet
Worksheet sheet = workbook.Worksheets[0];
//Set sheet name
sheet.Name = "Line Chart";
//Hide gridlines
sheet.GridLinesVisible = false;
//Add some data to the the worksheet
sheet.Range["A1"].Value = "Country";
sheet.Range["A2"].Value = "Cuba";
sheet.Range["A3"].Value = "Mexico";
sheet.Range["A4"].Value = "France";
sheet.Range["A5"].Value = "German";
sheet.Range["B1"].Value = "Jun";
sheet.Range["B2"].NumberValue = 3300;
sheet.Range["B3"].NumberValue = 2300;
sheet.Range["B4"].NumberValue = 4500;
sheet.Range["B5"].NumberValue = 6700;
sheet.Range["C1"].Value = "Jul";
sheet.Range["C2"].NumberValue = 7500;
sheet.Range["C3"].NumberValue = 2900;
sheet.Range["C4"].NumberValue = 2300;
sheet.Range["C5"].NumberValue = 4200;
sheet.Range["D1"].Value = "Aug";
sheet.Range["D2"].NumberValue = 7700;
sheet.Range["D3"].NumberValue = 6900;
sheet.Range["D4"].NumberValue = 8400;
sheet.Range["D5"].NumberValue = 4200;
sheet.Range["E1"].Value = "Sep";
sheet.Range["E2"].NumberValue = 8000;
sheet.Range["E3"].NumberValue = 7200;
sheet.Range["E4"].NumberValue = 8300;
sheet.Range["E5"].NumberValue = 5600;
//Set font and fill color for specified cells
sheet.Range["A1:E1"].Style.Font.IsBold = true;
sheet.Range["A2:E2"].Style.KnownColor = ExcelColors.LightYellow;
sheet.Range["A3:E3"].Style.KnownColor = ExcelColors.LightGreen1;
sheet.Range["A4:E4"].Style.KnownColor = ExcelColors.LightOrange;
sheet.Range["A5:E5"].Style.KnownColor = ExcelColors.LightTurquoise;
//Set cell borders
sheet.Range["A1:E5"].Style.Borders[BordersLineType.EdgeTop].Color = Color.FromArgb(0, 0, 128);
sheet.Range["A1:E5"].Style.Borders[BordersLineType.EdgeTop].LineStyle = LineStyleType.Thin;
sheet.Range["A1:E5"].Style.Borders[BordersLineType.EdgeBottom].Color = Color.FromArgb(0, 0, 128);
sheet.Range["A1:E5"].Style.Borders[BordersLineType.EdgeBottom].LineStyle = LineStyleType.Thin;
sheet.Range["A1:E5"].Style.Borders[BordersLineType.EdgeLeft].Color = Color.FromArgb(0, 0, 128);
sheet.Range["A1:E5"].Style.Borders[BordersLineType.EdgeLeft].LineStyle = LineStyleType.Thin;
sheet.Range["A1:E5"].Style.Borders[BordersLineType.EdgeRight].Color = Color.FromArgb(0, 0, 128);
sheet.Range["A1:E5"].Style.Borders[BordersLineType.EdgeRight].LineStyle = LineStyleType.Thin;
//Set number format
sheet.Range["B2:D5"].Style.NumberFormat = "\"$\"#,##0";
//Add a line chart to the worksheet
Chart chart = sheet.Charts.Add(ExcelChartType.Line);
//Set data range for the chart
chart.DataRange = sheet.Range["A1:E5"];
//Set position of the chart
chart.LeftColumn = 1;
chart.TopRow = 6;
chart.RightColumn = 11;
chart.BottomRow = 29;
//Set and format chart title
chart.ChartTitle = "Sales Report";
chart.ChartTitleArea.IsBold = true;
chart.ChartTitleArea.Size = 12;
//Set and format category axis title
chart.PrimaryCategoryAxis.Title = "Month";
chart.PrimaryCategoryAxis.Font.IsBold = true;
chart.PrimaryCategoryAxis.TitleArea.IsBold = true;
//Set and format value axis title
chart.PrimaryValueAxis.Title = "Sales (in USD)";
chart.PrimaryValueAxis.HasMajorGridLines = false;
chart.PrimaryValueAxis.TitleArea.TextRotationAngle = -90;
chart.PrimaryValueAxis.MinValue = 1000;
chart.PrimaryValueAxis.TitleArea.IsBold = true;
//Loop through the data series of the chart
foreach (ChartSerie cs in chart.Series)
{
cs.Format.Options.IsVaryColor = true;
//Show data labels for data points
cs.DataPoints.DefaultDataPoint.DataLabels.HasValue = true;
}
//Set position of chart legend
chart.Legend.Position = LegendPositionType.Top;
//Save the result file
workbook.SaveToFile("LineChart.xlsx", ExcelVersion.Version2016);
}
}
}

Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.
Why Export Datatable to RTF?
RTF is a Microsoft specification and certified file format used with DOC and DOCX. It is a core part of the Microsoft Office system. RTF usually used for cut and paste, including paste special and used when opening documents into Word. RTF does not cause document corruption.
RTF allows Workshare tremendous flexibility in successfully translating between any number of document types because of its ubiquity. Workshare products can not only maintain document fidelity, but provide portability advantages when moving around different Microsoft Word systems, or translating to other document types.
How to Export DataTable to RTF through DataGridView?
Download Spire.DataExport (or Spire.Office) with .NET Framework together. Only 2 Simple steps you can finish the whole datatable to RTF exporting process.
Step 1: Load Data Information
Before exporting data from DataTable, we should load data information from data source. And select which information we need export. Through DataGridVew, we even can preview and modify data information. So, in this step, our job is to prepare data which is about to be exported out.
private void btnLoad_Click(object sender, EventArgs e)
{
oleDbConnection.ConnectionString = this.textBox1.Text;
OleDbCommand oleDbCommand = new OleDbCommand();
oleDbCommand.CommandText = this.textBox2.Text;
oleDbCommand.Connection = oleDbConnection;
using (OleDbDataAdapter da = new OleDbDataAdapter(oleDbCommand))
{
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;
}
}
Effect Screenshot

Step 2: Set Export into RTF
Spire.DataExport allows user to export data into most popular file formats including MS Excel, RTF, HTML, PDF, XML, CSV, DBF, DIF, etc. Here we need set it as RTF format. Spire.DataExport will create a new RTF file and through DataGridView export data into RTF file. You also can rename the file as you like.
private void btnRun_Click(object sender, EventArgs e)
{
Spire.DataExport.RTF.RTFExport RTFExport = new Spire.DataExport.RTF.RTFExport();
RTFExport.DataSource = Spire.DataExport.Common.ExportSource.DataTable;
RTFExport.DataTable = this.dataGridView1.DataSource as DataTable;
RTFExport.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
RTFExport.FileName = "RTF0722.rtf";
RTFExport.SaveToFile();
}
Effect Screenshot

When we export data out from Database we may have requirements of exporting data from Datatable to CSV because CSV is a simple file format that is widely supported. CSV (The comma-separated values) file format is a set of file formats used to store tabular data in which numbers and text are stored in plain textual form that can be read in a text editor. Lines in the text file represent rows of a table, and commas in a line separate what are fields in the table row.
Here we mainly discuss how to Export Datatable to CSV with Spire.DataExport for .NET.
Download Spire.DataExport (or Spire.Office) with .NET Framework together. Only 2 Simple steps you can finish the whole datatable to CSV exporting process.
Step 1: Load Data Information
Before exporting data from DataTable, we should load data information from data source. And select which information we need export. Through DataGridVew, we even can preview and modify data information. So, in this step, our job is to prepare data which is about to be exported out.
private void btnLoad_Click(object sender, EventArgs e)
{
using (OleDbConnection oleDbConnection = new OleDbConnection())
{
oleDbConnection.ConnectionString = this.textBox1.Text;
OleDbCommand oleDbCommand = new OleDbCommand();
oleDbCommand.CommandText = this.textBox2.Text;
oleDbCommand.Connection = oleDbConnection;
using (OleDbDataAdapter da = new OleDbDataAdapter(oleDbCommand))
{
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;
}
}
}
Effect Screenshot

Step 2: Set Export into CSV
Spire.DataExport allows user to export data into most popular file formats including MS Excel, MS Word, HTML, PDF, XML, CSV, DBF, DIF, etc. Here we need set it as CSV format. Spire.DataExport will create a new CSV file and through DataGridView export data into CSV file. You also can rename the file as you like.
private void btnRUN_Click(object sender, EventArgs e)
{
TXTExport CSVExport = new TXTExport();
CSVExport.DataSource = Spire.DataExport.Common.ExportSource.DataTable;
CSVExport.DataTable = this.dataGridView1.DataSource as DataTable;
CSVExport.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
CSVExport.FileName = "CSV0721.csv";
CSVExport.SaveToFile();
}
Effect Screenshot

A bar chart in Excel is a data visualization tool that presents data using horizontal bars. The length of each bar in the chart is proportional to the value it represents. Using a bar chart, you can easily compare values across two or more categories. In this article, you will learn how to create bar chart in Excel in C# and VB.NET using Spire.XLS for .NET.
Install Spire.XLS for .NET
To begin with, you need to add the DLL files included in the Spire.XLS for .NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.
PM> Install-Package Spire.XLS
Create Bar Chart in Excel in C# and VB.NET
The following are the main steps to create a bar chart:
- Create an instance of Workbook class.
- Get the first worksheet by its index (zero-based) though Workbook.Worksheets[sheetIndex] property.
- Add some data to the worksheet.
- Add a clustered bar chart to the worksheet using Worksheet.Charts.Add(ExcelChartType.BarClustered) method.
- Set data range for the chart through Chart.DataRange property.
- Set position, title, category axis title and value axis title for the chart.
- Loop through the data series of the chart, show data labels for the data points of each data series by setting the ChartSerie.DataPoints.DefaultDataPoint.DataLabels.HasValue property as true.
- Set the position of chart legend through Chart.Legend.Position property.
- Save the result file using Workbook.SaveToFile() method.
- C#
- VB.NET
using Spire.Xls;
using Spire.Xls.Charts;
using System.Drawing;
namespace CreateBarChart
{
class Program
{
static void Main(string[] args)
{
//Create a Workbook instance
Workbook workbook = new Workbook();
//Get the first worksheet
Worksheet sheet = workbook.Worksheets[0];
//Set sheet name
sheet.Name = "Bar Chart";
//Hide gridlines
sheet.GridLinesVisible = false;
//Add data to the the worksheet
sheet.Range["A1"].Value = "Country";
sheet.Range["A2"].Value = "Cuba";
sheet.Range["A3"].Value = "Mexico";
sheet.Range["A4"].Value = "France";
sheet.Range["A5"].Value = "German";
sheet.Range["B1"].Value = "Jun";
sheet.Range["B2"].NumberValue = 6000;
sheet.Range["B3"].NumberValue = 8000;
sheet.Range["B4"].NumberValue = 9000;
sheet.Range["B5"].NumberValue = 8500;
sheet.Range["C1"].Value = "Aug";
sheet.Range["C2"].NumberValue = 3000;
sheet.Range["C3"].NumberValue = 2000;
sheet.Range["C4"].NumberValue = 2300;
sheet.Range["C5"].NumberValue = 4200;
//Set cell styles
sheet.Range["A1:C1"].Style.Font.IsBold = true;
sheet.Range["A2:C2"].Style.KnownColor = ExcelColors.LightYellow;
sheet.Range["A3:C3"].Style.KnownColor = ExcelColors.LightGreen1;
sheet.Range["A4:C4"].Style.KnownColor = ExcelColors.LightOrange;
sheet.Range["A5:C5"].Style.KnownColor = ExcelColors.LightTurquoise;
//Set cell borders
sheet.Range["A1:C5"].Style.Borders[BordersLineType.EdgeTop].Color = Color.FromArgb(0, 0, 128);
sheet.Range["A1:C5"].Style.Borders[BordersLineType.EdgeTop].LineStyle = LineStyleType.Thin;
sheet.Range["A1:C5"].Style.Borders[BordersLineType.EdgeBottom].Color = Color.FromArgb(0, 0, 128);
sheet.Range["A1:C5"].Style.Borders[BordersLineType.EdgeBottom].LineStyle = LineStyleType.Thin;
sheet.Range["A1:C5"].Style.Borders[BordersLineType.EdgeLeft].Color = Color.FromArgb(0, 0, 128);
sheet.Range["A1:C5"].Style.Borders[BordersLineType.EdgeLeft].LineStyle = LineStyleType.Thin;
sheet.Range["A1:C5"].Style.Borders[BordersLineType.EdgeRight].Color = Color.FromArgb(0, 0, 128);
sheet.Range["A1:C5"].Style.Borders[BordersLineType.EdgeRight].LineStyle = LineStyleType.Thin;
//Set number format
sheet.Range["B2:C5"].Style.NumberFormat = "\"$\"#,##0";
//Add a clustered bar chart to the worksheet
Chart chart = sheet.Charts.Add(ExcelChartType.BarClustered);
//Set data range for the chart
chart.DataRange = sheet.Range["A1:C5"];
chart.SeriesDataFromRange = false;
//Set position of the chart
chart.LeftColumn = 1;
chart.TopRow = 6;
chart.RightColumn = 11;
chart.BottomRow = 29;
//Set and format chart title
chart.ChartTitle = "Sales Report";
chart.ChartTitleArea.IsBold = true;
chart.ChartTitleArea.Size = 12;
//Set and format category axis title
chart.PrimaryCategoryAxis.Title = "Country";
chart.PrimaryCategoryAxis.Font.IsBold = true;
chart.PrimaryCategoryAxis.TitleArea.IsBold = true;
chart.PrimaryCategoryAxis.TitleArea.TextRotationAngle = 90;
//Set and format value axis title
chart.PrimaryValueAxis.Title = "Sales(in USD)";
chart.PrimaryValueAxis.HasMajorGridLines = false;
chart.PrimaryValueAxis.MinValue = 1000;
chart.PrimaryValueAxis.TitleArea.IsBold = true;
//Show data labels for data points
foreach (ChartSerie cs in chart.Series)
{
cs.Format.Options.IsVaryColor = true;
cs.DataPoints.DefaultDataPoint.DataLabels.HasValue = true;
}
//Set position of chart legend
chart.Legend.Position = LegendPositionType.Top;
//Save the result file
workbook.SaveToFile("CreateBarChart.xlsx", ExcelVersion.Version2016);
}
}
}

Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.
DBF is a format created by Ashton-Tate and can be recognized by ACT, Lipper, FoxPro, Arago, Wordtech, Xbase and other programs related with Database. Although MS Excel has been the most popular data form software application, DBF format data form files still used widely. So sometimes we may have requirements to export data from datatable to DBF. And with Spire.DataExport, we can export datatable to DBF through DataGridView effortlessly!
Download Spire.DataExport (or Spire.Office) with .NET Framework together. Only 2 Simple steps you can finish the whole datatable to DBF exporting process.
Step 1: Load Data Information
Before exporting data from DataTable, we should load data information from data source. And select which information we need export. Through DataGridVew, we even can preview and modify data information. So, in this step, our job is to prepare data which are about to be exported out.
private void btnLoad_Click(object sender, EventArgs e)
{
using (OleDbConnection oleDbConnection = new OleDbConnection())
{
oleDbConnection.ConnectionString = this.textBox1.Text;
OleDbCommand oleDbCommand = new OleDbCommand();
oleDbCommand.CommandText = this.textBox2.Text;
oleDbCommand.Connection = oleDbConnection;
using (OleDbDataAdapter da = new OleDbDataAdapter(oleDbCommand))
{
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;
}
}
}
Effect Screenshot

Step 2: Set Export into DBF
Spire.DataExport allows user to export data into most popular file formats including MS Excel, MS Word, HTML, PDF, XML, CSV, DBF, DIF, etc. Here we need set it as DBF format. Spire.DataExport will create a new DBF file and through DataGridView export data into DBF file. You also can rename the file as you like.
private void btnRun_Click(object sender, EventArgs e)
{
Spire.DataExport.DBF.DBFExport DBFExport = new Spire.DataExport.DBF.DBFExport();
DBFExport.DataSource = Spire.DataExport.Common.ExportSource.DataTable;
DBFExport.DataTable = this.dataGridView1.DataSource as DataTable;
DBFExport.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
DBFExport.FileName = "DBF0401.dbf";
DBFExport.SaveToFile();
}
Effect Screenshot

This article will show you how to use Spire.DataExport to Export Datatable to PDF through DataGridView. Through DataGridView, users can preview data information and modify the information if they think it’s not correct before exporting data. With Spire.DataExport, this whole exporting process could be fast and easy.
Download Spire.DataExport (or Spire.Office) with .NET Framework together. Only 2 Simple steps you can finish the whole datatable to PDF exporting process.
Step 1: Load Data Information
Before exporting data from DataTable, we should load data information from data source. And select which information we need export. Through DataGridVew, we even can preview and modify data information. So, in this step, our job is to prepare data which is about to be exported out.
private void btnLoad_Click(object sender, EventArgs e)
{
using (OleDbConnection oleDbConnection = new OleDbConnection())
{
oleDbConnection.ConnectionString = this.tbCS.Text;
OleDbCommand oleDbCommand = new OleDbCommand();
oleDbCommand.CommandText = this.tbCT.Text;
oleDbCommand.Connection = oleDbConnection;
using (OleDbDataAdapter da = new OleDbDataAdapter(oleDbCommand))
{
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView.DataSource = dt;
}
}
}
Effect Screenshot

Step 2: Set Export into PDF
Spire.DataExport allows user to export data into most popular file formats including MS Excel, MS Word, HTML, PDF, XML, CSV, DBF, DIF, etc. Here we need set it as PDF format. Spire.DataExport will create a new PDF file and through DataGridView export data into PDF file. You also can rename the file as you like.
private void btnRun_Click(object sender, EventArgs e)
{
Spire.DataExport.PDF.PDFExport PDFExport = new Spire.DataExport.PDF.PDFExport();
PDFExport.DataSource = Spire.DataExport.Common.ExportSource.DataTable;
PDFExport.DataTable = this.dataGridView.DataSource as DataTable;
PDFExport.ActionAfterExport = Spire.DataExport.Common.ActionType.OpenView;
PDFExport.SaveToFile("20110223.pdf");
}
Effect Screenshot

In daily work, you may come across some situations where you need to convert Excel to images, such as attaching a cell range to a PowerPoint presentation or safely sending your spreadsheet data via email. This article will show you how to programmatically convert Excel to images from the following two aspects using Spire.XLS for .NET.
Install Spire.XLS for .NET
To begin with, you need to add the DLL files included in the Spire.XLS for .NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.
PM> Install-Package Spire.XLS
Convert a Whole Excel Worksheet to an Image
The following are steps to convert a whole Excel worksheet to an image.
- Create a Workbook instance.
- Load an Excel sample document using Workbook.LoadFromFile() method.
- Get a specific worksheet of the document using Workbook.Worksheets[] property.
- Save the worksheet as an image using Worksheet.SaveToImage() method.
- C#
- VB.NET
using Spire.Xls;
namespace Xls2Image
{
class Program
{
static void Main(string[] args)
{
//Create a Workbook instance
Workbook workbook = new Workbook();
//Load an Excel sample document
workbook.LoadFromFile(@"sample.xlsx");
//Get the first worksheet
Worksheet sheet = workbook.Worksheets[0];
//Save the worksheet as an image
sheet.SaveToImage("XlsToImage.jpg");
}
}
}

Convert a Specific Cell Range to an Image
In addition to converting a whole worksheet to an image, Spire.XLS for .NET also supports converting a specific cell range of a worksheet to an image. Detailed steps are listed below.
- Create a Workbook instance.
- Load an Excel sample document using Workbook.LoadFromFile() method.
- Get a specific worksheet of the document using Workbook.Worksheets[] property.
- Specify a cell range and save it as the Image object using Worksheet.ToImage() method, and then save the object as a certain image format using Image.Save() method.
- C#
- VB.NET
using Spire.Xls;
using System.Drawing.Imaging;
namespace SpecificCellsToImage
{
class Program
{
static void Main(string[] args)
{
//Create a Workbook instance
Workbook workbook = new Workbook();
//Load an Excel sample document
workbook.LoadFromFile(@"sample.xlsx");
//Get the first worksheet
Worksheet sheet = workbook.Worksheets[0];
//Specify a cell range and save it to a certain image format
sheet.ToImage(1, 1, 6, 4).Save("CellRangeToImage.png", ImageFormat.Png);
}
}
}

Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.
Open XML is an XML-based file format developed by Microsoft that allows users to store and exchange various types of files such as word processing documents, spreadsheets, presentations, charts, and diagrams. It is widely recognized and supported by various applications, making it a reliable choice for long-term data preservation.
In some cases, it may be necessary to convert Excel files to Open XML format to ensure that these files can be opened and read by other software. On the other hand, there may be situations where users need to convert Open XML files to Excel format to take advantage of the data analysis tools available in Excel, such as pivot tables and charts. In this article, we will introduce how to convert Excel to Open XML or Open XML to Excel in C# and VB.NET using Spire.XLS for .NET.
Install Spire.XLS for .NET
To begin with, you need to add the DLL files included in the Spire.XLS for .NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.
PM> Install-Package Spire.XLS
Convert Excel to Open XML in C# and VB.NET
To convert an Excel file to Open XML, you need to load the Excel file using the Workbook.LoadFromFile(string fileName) method, then call the Workbook.SaveAsXml(string fileName) method to save it in Open XML format.
The following steps demonstrate how to convert an Excel file to Open XML:
- Initialize an instance of the Workbook class.
- Load an Excel file using the Workbook.LoadFromFile(string fileName) method.
- Call the Workbook.SaveAsXml(string fileName) method to save the Excel file in Open XML format.
- C#
- VB.NET
using Spire.Xls;
namespace ConvertExcelToOpenXML
{
internal class Program
{
static void Main(string[] args)
{
//Initialize an instance of the Workbook class
Workbook workbook = new Workbook();
//Load an Excel file
workbook.LoadFromFile("Sample.xlsx");
//Save the Excel file in Open XML file format
workbook.SaveAsXml("ExcelToXML.xml");
}
}
}

Convert Open XML to Excel in C# and VB.NET
To convert an Open XML file to Excel, you need to load the Open XML file using the Workbook.LoadFromXml(string fileName) method, then call the Workbook.SaveToFile(string fileName, ExcelVersion version) method to save it in Excel format.
The following are the steps to convert an Open XML file to Excel:
- Initialize an instance of the Workbook class.
- Load an Open XML file using the Workbook.LoadFromXml(string fileName) method.
- Call the Workbook.SaveToFile(string fileName, ExcelVersion version) method to save the Open XML file in Excel format.
- C#
- VB.NET
using Spire.Xls;
namespace ConvertOpenXMLToExcel
{
internal class Program
{
static void Main(string[] args)
{
//Initialize an instance of the Workbook class
Workbook workbook = new Workbook();
//Load an Open XML file
workbook.LoadFromXml("ExcelToXML.xml");
//Save the Open XML file in Excel XLSX file format
workbook.SaveToFile("XMLToExcel.xlsx", ExcelVersion.Version2016);
}
}
}

Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.