string strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +
fileName + ";Extended Properties=\"Excel 12.0 Xml;HDR=Yes;IMES=1;\"";
using (OleDbConnection conn = new OleDbConnection(strConn))
{
conn.Open();
DataTable dt = dataset.Tables[0];
OleDbCommand cmd = new OleDbCommand(getCreateTableCommand(dt), conn);
cmd.ExecuteNonQuery();
conn.Close();
}
/*method - getCreateTableCommand returns something like this -
{CREATE TABLE [Results] ([name1] STRING,[name2] STRING,[name3] STRING,[name4] STRING}*/
输出很好。问题是-我希望 excel 列具有适当的宽度。换句话说,我想得到更宽的列,有时甚至比写列名所需的空间还要宽。如何调整列的大小?