C# 从数据库中导出到excel文件的:
using NPOI.HSSF.UserModel;
using System;
using System.Data;
using System.Data.SqlClient;
using System.IO;
namespace shuju
{
class Program
{
static void Main(string[] args)
{
string connectString = "Data Source=.;Initial Catalog=dictionary_editor_pro;Integrated Security=True";
SqlConnection sqlCnt = new SqlConnection(connectString);
sqlCnt.Open();
HSSFWorkbook workbook = new HSSFWorkbook();
//创建工作表
var sheet = workbook.CreateSheet("信息表");
//创建标题行(重点)
var row = sheet.CreateRow(0);
SqlDataAdapter myDataAdapter = new SqlDataAdapter("select * from dictionary_backup", sqlCnt);
DataSet