[codes=C#]private void Form4_Load(object sender, EventArgs e)
{
object oMissing = Missing.Value;
Microsoft.Office.Interop.Excel.Application ExcelObj =
new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook WBook;
Microsoft.Office.Interop.Excel.Worksheet WSheet;
Microsoft.Office.Interop.Excel.Range Selection;
WBook = ExcelObj.Workbooks.Open(@"c:\test\1.xlsx",
oMissing, oMissing, oMissing, oMissing, oMissing,
oMissing, oMissing, oMissing, oMissing, oMissing,
oMissing, oMissing, oMissing, oMissing);
WSheet = (Microsoft.Office.Interop.Excel.Worksheet)WBook.Sheets.get_Item(1);
// Conversion
Selection = WSheet.Cells;
Selection.Select();
Selection.NumberFormat = "@";
WBook.Save();
string ConnectionString =
"Provider=Microsoft.ACE.OLEDB.12.0;" +
"Data Source=" + @"c:\test\1.xlsx;" +
"Excel 12.0;HDR=YES;";
OleDbConnection ExcelConnection = new OleDbConnection(ConnectionString);
OleDbDataAdapter ad = new OleDbDataAdapter();
ad.SelectCommand = new OleDbCommand("SELECT * FROM [Sheet1$]", ExcelConnection);
DataTable dt = new DataTable();
ad.Fill(dt);
this.dataGridView1.DataSource = dt;
}
[/codes]
作者:Else 's Blog
地址:http://www.aixq.com/post/1077/
版权所有。转载时必须链接形式注明作者和原始出处及本声明! 在
中查看更多“Excel to DataGridView using excel 2007”相关内容
在
中查看更多“Excel to DataGridView using excel 2007”相关内容
在
中查看更多“Excel to DataGridView using excel 2007”相关内容
在
中查看更多“Excel to DataGridView using excel 2007”相关内容
在
中查看更多“Excel to DataGridView using excel 2007”相关内容
在
中查看更多“Excel to DataGridView using excel 2007”相关内容
最后编辑: Else 编辑于2008/06/20 17:20
{
object oMissing = Missing.Value;
Microsoft.Office.Interop.Excel.Application ExcelObj =
new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook WBook;
Microsoft.Office.Interop.Excel.Worksheet WSheet;
Microsoft.Office.Interop.Excel.Range Selection;
WBook = ExcelObj.Workbooks.Open(@"c:\test\1.xlsx",
oMissing, oMissing, oMissing, oMissing, oMissing,
oMissing, oMissing, oMissing, oMissing, oMissing,
oMissing, oMissing, oMissing, oMissing);
WSheet = (Microsoft.Office.Interop.Excel.Worksheet)WBook.Sheets.get_Item(1);
// Conversion
Selection = WSheet.Cells;
Selection.Select();
Selection.NumberFormat = "@";
WBook.Save();
string ConnectionString =
"Provider=Microsoft.ACE.OLEDB.12.0;" +
"Data Source=" + @"c:\test\1.xlsx;" +
"Excel 12.0;HDR=YES;";
OleDbConnection ExcelConnection = new OleDbConnection(ConnectionString);
OleDbDataAdapter ad = new OleDbDataAdapter();
ad.SelectCommand = new OleDbCommand("SELECT * FROM [Sheet1$]", ExcelConnection);
DataTable dt = new DataTable();
ad.Fill(dt);
this.dataGridView1.DataSource = dt;
}
[/codes]
作者:Else 's Blog
地址:http://www.aixq.com/post/1077/
版权所有。转载时必须链接形式注明作者和原始出处及本声明!
中查看更多“Excel to DataGridView using excel 2007”相关内容
中查看更多“Excel to DataGridView using excel 2007”相关内容
中查看更多“Excel to DataGridView using excel 2007”相关内容
中查看更多“Excel to DataGridView using excel 2007”相关内容
中查看更多“Excel to DataGridView using excel 2007”相关内容
中查看更多“Excel to DataGridView using excel 2007”相关内容最后编辑: Else 编辑于2008/06/20 17:20
選擇文件 c#
php-et 分页的类写好了


2008/06/20 17:14 | by 
