c# 中实现 选中 excel 的sheet 的问题
private void ggexcelconn(string gangGuSheet)
{
OleDbConnection myConn = null;
DataSet thisDataSet = null;
Excel.Application myExcel = null;
Excel.Workbooks myWorkbooks = null;
Excel._Workbook myWorkbook = null;
Excel._Worksheet myWorksheet = null;
try
{
myExcel = new Excel.Application();
myExcel.UserControl = true;
myWorkbooks = myExcel.Workbooks;
myWorkbook = myWorkbooks.Open(@"D:\localserver\filename", Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value);
myWorksheet = (Excel._Worksheet)myWorkbook.Worksheets[gangGuSheet];
myExcel.Cells[1, 1] = "日期";
myExcel.Application.DisplayAlerts = false;
myExcel.Visible = true;
myWorkbook.Save();
}
catch (Exception ex)
{
}
finally
{
if (myExcel != null)
{
myExcel.Quit();
}
}
gangGuSheet 作为 sheet 名传进来 为什么我每次修改的值 都是第一页的值 这个excel表有两个 sheet
------解决方案--------------------
遍历WorkSheet,用名字去找
http://www.cnblogs.com/lixx/archive/2008/05/05/1183881.html
也许这个可以给你帮助