rivate void bntPrint_Click(object sender, System.EventArgs e)
{
try
{
ProcessExcelTemplate oReport = new ProcessExcelTemplate();
oReport.ReportTemplate = Server.MapPath("../../Report/ForestCover.xls");
oReport.ReportName ="ヒユヨンハミノュチヨクイクヌヌ鯀・;
oReport.TotalReportIndex=1;
oReport.ProcessFileFirst();
oReport.ReportIndex=1;
oReport.ProcessActiveSheet();
oReport.ProcessName("ヒユヨンハミノュチヨヌ鯀イクヌア・); int row=0;
int col=0; oReport.ProcessFileMain("2","A","ト・ン");
oReport.ProcessFileMain("2","B",txtYear.Text);
for(int i=0;i<gridFC.Rows.Count;i++)
for(int j=1;j<gridFC.Columns.Count;j++)
{
row=i+7;
col=64+j;
oReport.ProcessFileMain(row.ToString(),((char)col).ToString(),gridFC.Rows[i].Cells[j].Text);
}
oReport.ProcessFileLast();
}
catch(Exception E)
{
WebCommon.ExceptionMessage(E);
}
}

解决方案 »

  1.   

    string strCon = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = c:\\FileName.xls; Extended Properties = Excel 8.0";
    OleDbConnection myConn = new OleDbConnection(strCon);
    string strCom = " SELECT * FROM [Sheet1$]";
    myConn.Open();
    OleDbDataAdapter myCommand = new OleDbDataAdapter(strCom, myConn);
    dataSet_ = new DataSet("Sheet1");
    myCommand.Fill(dataSet_, "Sheet1");
    myConn.Close();
    就可以了.
      

  2.   

    Sheet1$??
    如果第一个表名不是Sheet1的时候,会出错哦
      

  3.   

    也不是, 它会在filename.xls文件中找Sheet1导进来
      

  4.   

    所以FileName.xls文件中要有一个Sheet1就可以了.
      

  5.   

    用SQL Server直接去导吧,多方便
      

  6.   

    http://blog.csdn.net/cocosoft/archive/2004/04/12/19138.aspx