0
我需要打开特定位置的Excel表格(d:\temp\emp.xls
),然后加粗列标题并保存文件。如何访问Excel中的excel文件#
我想这样做,但没有得到如何打开文件并访问1行,并使他们在C#中的粗体?
我需要打开特定位置的Excel表格(d:\temp\emp.xls
),然后加粗列标题并保存文件。如何访问Excel中的excel文件#
我想这样做,但没有得到如何打开文件并访问1行,并使他们在C#中的粗体?
string connectionString =“Provider = Microsoft.Jet.OleDb.4.0; data source = c:\ customers.xls; Extended Properties = Excel 8.0;”;
// Select using a Named Range
//string selectString = "SELECT * FROM Customers";
// Select using a Worksheet name
string selectString = "SELECT * FROM [Sheet1$]";
OleDbConnection con = new OleDbConnection(connectionString);
OleDbCommand cmd = new OleDbCommand(selectString,con);
try
{
con.Open();
OleDbDataReader theData = cmd.ExecuteReader();
while (theData.Read())
{
Console.WriteLine("{0}: {1} ({2}) - {3} ({4})", theData.GetString(0),theData.GetString(1),theData.GetString(2),theData.GetString(3),theData.GetString(4));
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
con.Dispose();
}
[从C#创建的Excel(.XLS和.XLSX)文件(的
可能重复http://stackoverflow.com/questions/151005/create-excel-xls-and-xlsx-file-from- c-sharp) – 2012-01-15 13:23:43
我已经使用SSIS包导入了数据,现在Excel表包含数据。现在我正在编写一个脚本任务,以便可以访问该文件更改列宽并使其变为粗体 – happysmile 2012-01-15 13:28:21