日期:2014-05-18 浏览次数:20960 次
public static readonly string CONN_STRING = "Data Source=210.1.1.1;Initial Catalog=qq;Persist Security Info=True;User ID=dsh;Password=123456;"
string strQuery = string.Empty; if (blIsMoreThan) { strQuery = "select top "+this.dbSheetSize +" "+strSql+" from "+ strTablName + " where ["+fldName+"] >(select max (["+ fldName + "]) from (select top " + dbSheetSize * (intSheetNumber - 1) + " ["+ strSql + "] from [" + strTablName + "] where 1=1 " + strWhere + " order by [" + fldName +"] asc "+ ") as tblTmp) and 1=1 " + @strWhere + " " + " order by [" + fldName +"] asc "; } else { strQuery = "select top " + this.dbSheetSize + strSql+" from ["+ strTablName + "] where 1=1 " + strWhere + " "+"order by [" + fldName +"] asc "; } m_objSheet = (Excel._Worksheet)(m_objSheets.get_Item(intSheetNumber)); m_objSheet.Cells[1,1] = strMastTitle; m_objSheet.Cells[2,1] = "打印日期"+DateTime.Now.ToShortDateString(); for(int i = 1;i<=strTitle.Length;i++) { m_objSheet.Cells[4,i] = strTitle[i-1].ToString(); } m_objRange = m_objSheet.get_Range("A5", m_objOpt); [color=#FF0000]m_objQryTable = m_objSheet.QueryTables.Add("OLEDB;Provider=SQLOLEDB.1;" + sqlConn.ConnectionString, m_objRange, strQuery);[/color] m_objQryTable.RefreshStyle = Excel.XlCellInsertionMode.xlInsertEntireRows; m_objQryTable.FieldNames = false; m_objQryTable.Refresh(false);