Knowledgebase (2328)
Children categories
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.