展开全部
可以借助第三方控件spire.DataExport,将datatable的数据导出为32313133353236313431303231363533e58685e5aeb931333365643464pdf, excel, word.
导出为PDF,参考下面的代码://连接数据库,将数据存入datatable
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;
}
}
}
//将datatable的数据写入PDF
private void btnRun_Click(object sender, EventArgs e)